2 Copyright (C) 2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackAudioAdapterInterface__
21 #define __JackAudioAdapterInterface__
23 #include "JackResampler.h"
24 #include "JackFilters.h"
25 #include "JackConstants.h"
32 #define TABLE_MAX 100000
48 Measure fTable
[TABLE_MAX
];
51 MeasureTable() :fCount ( 0 )
54 void Write ( int time1
, int time2
, float r1
, float r2
, int pos1
, int pos2
);
62 \brief Base class for audio adapters.
65 class JackAudioAdapterInterface
75 int fPlaybackChannels
;
78 jack_nframes_t fHostBufferSize
;
79 jack_nframes_t fHostSampleRate
;
82 jack_nframes_t fAdaptedBufferSize
;
83 jack_nframes_t fAdaptedSampleRate
;
86 JackAtomicDelayLockedLoop fHostDLL
;
87 JackAtomicDelayLockedLoop fAdaptedDLL
;
89 JackResampler
** fCaptureRingBuffer
;
90 JackResampler
** fPlaybackRingBuffer
;
92 unsigned int fQuality
;
98 JackAudioAdapterInterface ( jack_nframes_t buffer_size
, jack_nframes_t sample_rate
) :
99 fCaptureChannels ( 0 ),
100 fPlaybackChannels ( 0 ),
101 fHostBufferSize ( buffer_size
),
102 fHostSampleRate ( sample_rate
),
103 fAdaptedBufferSize ( buffer_size
),
104 fAdaptedSampleRate ( sample_rate
),
105 fHostDLL ( buffer_size
, sample_rate
),
106 fAdaptedDLL ( buffer_size
, sample_rate
),
111 virtual ~JackAudioAdapterInterface()
114 void SetRingBuffers ( JackResampler
** input
, JackResampler
** output
)
116 fCaptureRingBuffer
= input
;
117 fPlaybackRingBuffer
= output
;
130 void ResetRingBuffers();
132 unsigned int GetQuality()
140 virtual int SetHostBufferSize ( jack_nframes_t buffer_size
)
142 fHostBufferSize
= buffer_size
;
143 fHostDLL
.Init ( fHostBufferSize
, fHostSampleRate
);
147 virtual int SetAdaptedBufferSize ( jack_nframes_t buffer_size
)
149 fAdaptedBufferSize
= buffer_size
;
150 fAdaptedDLL
.Init ( fAdaptedBufferSize
, fAdaptedSampleRate
);
154 virtual int SetBufferSize ( jack_nframes_t buffer_size
)
156 SetHostBufferSize ( buffer_size
);
157 SetAdaptedBufferSize ( buffer_size
);
161 virtual int SetHostSampleRate ( jack_nframes_t sample_rate
)
163 fHostSampleRate
= sample_rate
;
164 fHostDLL
.Init ( fHostBufferSize
, fHostSampleRate
);
168 virtual int SetAdaptedSampleRate ( jack_nframes_t sample_rate
)
170 fAdaptedSampleRate
= sample_rate
;
171 fAdaptedDLL
.Init ( fAdaptedBufferSize
, fAdaptedSampleRate
);
175 virtual int SetSampleRate ( jack_nframes_t sample_rate
)
177 SetHostSampleRate ( sample_rate
);
178 SetAdaptedSampleRate ( sample_rate
);
182 virtual void SetCallbackTime ( jack_time_t callback_usec
)
184 fHostDLL
.IncFrame ( callback_usec
);
187 void ResampleFactor ( jack_nframes_t
& frame1
, jack_nframes_t
& frame2
);
189 void SetInputs ( int inputs
)
191 jack_log ( "JackAudioAdapterInterface::SetInputs %d", inputs
);
192 fCaptureChannels
= inputs
;
195 void SetOutputs ( int outputs
)
197 jack_log ( "JackAudioAdapterInterface::SetOutputs %d", outputs
);
198 fPlaybackChannels
= outputs
;
203 jack_log ( "JackAudioAdapterInterface::GetInputs %d", fCaptureChannels
);
204 return fCaptureChannels
;
209 jack_log ( "JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels
);
210 return fPlaybackChannels
;