Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00039 #ifndef __JACKAUDIOINTERFACE_H__
00040 #define __JACKAUDIOINTERFACE_H__
00041
00042 #include <iostream>
00043 #include <tr1/memory>
00044 #include <functional>
00045 #include <jack/jack.h>
00046
00047 #include <QVector>
00048 #include <QVarLengthArray>
00049 #include <QMutex>
00050
00051
00052 #include "jacktrip_types.h"
00053 #include "ProcessPlugin.h"
00054
00055 class JackTrip;
00056
00057
00063 class JackAudioInterface
00064 {
00065 public:
00066
00069 enum audioBitResolutionT {
00070 BIT8 = 1,
00071 BIT16 = 2,
00072 BIT24 = 3,
00073 BIT32 = 4
00074 };
00075
00077 enum samplingRateT {
00078 SR22,
00079 SR32,
00080 SR44,
00081 SR48,
00082 SR88,
00083 SR96,
00084 SR192,
00085 UNDEF
00086 };
00087
00095 JackAudioInterface(JackTrip* jacktrip,
00096 int NumInChans, int NumOutChans,
00097 audioBitResolutionT AudioBitResolution = BIT16,
00098 const char* ClientName = "JackTrip");
00099
00102 virtual ~JackAudioInterface();
00103
00106 void setup();
00107
00110 uint32_t getSampleRate() const;
00111
00115 samplingRateT getSampleRateType() const;
00116
00122 static int getSampleRateFromType(samplingRateT rate_type);
00123
00126 uint32_t getBufferSizeInSamples() const;
00127
00130 uint32_t getBufferSizeInBytes() const
00131 {
00132 return (getBufferSizeInSamples() * getAudioBitResolution()/8);
00133 }
00134
00139 int getAudioBitResolution() const;
00140
00142 int getNumInputChannels() const;
00143
00145 int getNumOutputChannels() const;
00146
00148 size_t getSizeInBytesPerChannel() const;
00149
00154 int startProcess() const;
00155
00159 int stopProcess() const;
00160
00171
00172
00173
00174
00175
00182
00183 void appendProcessPlugin(ProcessPlugin* plugin);
00184
00192 static void fromSampleToBitConversion(const sample_t* const input,
00193 int8_t* output,
00194 const audioBitResolutionT targetBitResolution);
00195
00203 static void fromBitToSampleConversion(const int8_t* const input,
00204 sample_t* output,
00205 const audioBitResolutionT sourceBitResolution);
00206
00208 void connectDefaultPorts();
00209
00211 void setClientName(const char* ClientName)
00212 { mClientName = ClientName; }
00213
00214 private:
00215
00224 void setupClient();
00225
00228 void createChannels();
00229
00233 static void jackShutdown(void*);
00234
00236
00237
00239 void computeNetworkProcessFromNetwork();
00240
00242 void computeNetworkProcessToNetwork();
00243
00247 void setProcessCallback();
00248
00259 int processCallback(jack_nframes_t nframes);
00260
00272
00273 static int wrapperProcessCallback(jack_nframes_t nframes, void *arg) ;
00274
00275
00276 int mNumInChans;
00277 int mNumOutChans;
00278 int mNumFrames;
00279 int mAudioBitResolution;
00280 audioBitResolutionT mBitResolutionMode;
00281
00282 jack_client_t* mClient;
00283 const char* mClientName;
00284 QVarLengthArray<jack_port_t*> mInPorts;
00285 QVarLengthArray<jack_port_t*> mOutPorts;
00286
00287
00288 QVarLengthArray<sample_t*> mInBuffer;
00289 QVarLengthArray<sample_t*> mOutBuffer;
00290
00291 QVarLengthArray<sample_t*> mInProcessBuffer;
00292 QVarLengthArray<sample_t*> mOutProcessBuffer;
00293
00294 int8_t* mInputPacket;
00295 int8_t* mOutputPacket;
00296 size_t mSizeInBytesPerChannel;
00297
00298 QVector<ProcessPlugin*> mProcessPlugins;
00299 JackTrip* mJackTrip;
00300
00301 static QMutex sJackMutex;
00302 };
00303
00304
00305 #endif