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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* This file is part of the KDE project
Copyright (C) 2003 Arnold Krille <arnold@arnoldarts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KAUDIOPLAYSTREAM_H
#define KAUDIOPLAYSTREAM_H
#include <tqobject.h>
#include <tqcstring.h>
#include <stdsynthmodule.h>
#include <tdelibs_export.h>
class KArtsServer;
namespace Arts { class StereoEffectStack; }
class KAudioPlayStreamPrivate;
/**
* @brief A wrapper around ByteSoundProducer/ByteStreamToAudio/Synth_AMAN_PLAY.
*
* @author Arnold Krille <arnold@arnoldarts.de>
* @since 3.2
*/
class KDE_ARTS_EXPORT KAudioPlayStream : public TQObject {
TQ_OBJECT
public:
/**
* Creates a KAudioPlayStream on server with a title. You should pass the KArtsServer also
* as parent to be sure this object is deleted before the server is.
*
* @param server The server where it should play to.
* @param title The title that is shown in the AudioManager.
* @param parent You will propably want to pass the server as parent to so this stream gets deleted before the server disappears.
* @param name The name of the stream.
*/
KAudioPlayStream( KArtsServer* server, const TQString title, TQObject* parent=0, const char* name=0 );
/**
* Destructs the KAudioPlayStream.
*/
~KAudioPlayStream();
/**
* Controls wether this Stream should poll the data from you via the signal requestData()
* or you use write() to fill the inputbuffer.
*
* Default is true
*/
void setPolling( bool );
/**
* Returns the polling state.
* @see setPolling
*/
bool polling() const;
/**
* @return wether this stream is running ("on air") or not.
*/
bool running() const;
/**
* @return The Arts::StereoEffectStack right before the Synth_AMAN_PLAY.
*/
Arts::StereoEffectStack effectStack() const;
public slots:
/**
* Start the stream.
* @param samplingRate how many samples per second ( typically 11000/22050/44100/48000 )
* @param bits how many bits per sample ( 8 / 16 )
* @param channels how many channels ( 1 or 2 )
*/
void start( int samplingRate, int bits, int channels );
/**
* Stops the stream.
*/
void stop();
/**
* Write data into the inputbuffer.
* If you ignore the signal noData() it will play 0 ( silence ).
*/
void write( TQByteArray& data );
signals:
/**
* This signal is emitted when audio should be played.
* You have to fill the array with data.
*/
void requestData( TQByteArray& );
/**
* Is emitted when the state changes.
*/
void running( bool );
/**
* Is emitted if the inputbuffer runs dry and polling os off.
*/
void noData();
public:
/**
* @internal
*/
void fillData( Arts::DataPacket<Arts::mcopbyte> *packet );
private:
KAudioPlayStreamPrivate* d;
};
#endif // KAUDIOPLAYSTREAM_H
|