~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to krec/krecexport_template.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

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