1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/***************************************************************************
copyright : (C) 2003 by Arnold Krille
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License. *
* *
***************************************************************************/
#include "krecexport_template.h"
#include "krecexport_template.moc"
#include "krecglobal.h"
#include <tqtimer.h>
#include <kdebug.h>
KRecExportItem::KRecExportItem( TQObject* p, const char* n, const TQStringList& ) : TQObject( p,n ), _running( false ) {
//kdDebug( 60005 ) << k_funcinfo << endl;
}
KRecExportItem::~KRecExportItem() {
//kdDebug( 60005 ) << k_funcinfo << endl;
}
int KRecExportItem::samplingRate() const {
//kdDebug( 60005 ) << k_funcinfo << _samplingRate << endl;
return _samplingRate;
}
int KRecExportItem::bits() const {
//kdDebug( 60005 ) << k_funcinfo << _bits << endl;
return _bits;
}
int KRecExportItem::channels() const {
//kdDebug( 60005 ) << k_funcinfo << _channels << endl;
return _channels;
}
void KRecExportItem::registerAtGlobal( KRecExportItem* item ) {
//kdDebug( 60005 ) << k_funcinfo << endl;
bool registered = false;
if ( !registered ) registered = KRecGlobal::the()->registerExport( item );
//if ( registered ) kdDebug( 60005 ) << "Register successful!" << endl;
// else kdDebug( 60005 ) << "Register NOT successful!" << endl;
}
void KRecExportItem::initialize( int samplingRate, int bits, int channels ) {
kdDebug( 60005 ) << k_funcinfo << "samplingRate:" << samplingRate << " bits:" << bits << " channels:" << channels << endl;
_samplingRate = samplingRate;
_bits = bits;
_channels = channels;
}
bool KRecExportItem::start() {
kdDebug( 60005 ) << k_funcinfo << endl;
if ( !running() ) {
if ( process() ) {
_running = true;
TQTimer::singleShot( 0, this, TQ_SLOT( process() ) );
emit running( running() );
}
return true;
} else return false;
}
void KRecExportItem::stop() {
kdDebug( 60005 ) << k_funcinfo << endl;
_running = false;
emit running( running() );
}
TQ_INT16 KRecExportItem::read16( char* array, int index ) {
TQ_INT16 tmp;
tmp = array[ index ] + ( array[ index + 1 ] << 8 ) & 0xff;
return tmp;
}
/// Helper: writes an integer into an char* formated for wave-files
void KRecExportItem::write16( char* array, TQ_INT16 value, int index ) {
array[ index ] = ( value >> 0 ) & 0xff;
array[ index + 1 ] = ( value >> 8 ) & 0xff;
}
void KRecExportItem::write32( char* array, TQ_INT32 value, int index ) {
write16( array, value, index );
array[ index + 2 ] = ( value >> 16 ) & 0xff;
array[ index + 3 ] = ( value >> 24 ) & 0xff;
}
|