Commit 41baa7f8 authored by sletz's avatar sletz
Browse files

Add a resample quality parameter in audioadapter.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3291 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 9cf490ad
......@@ -23,6 +23,10 @@ Michael Voigt
Jackdmp changes log
---------------------------
2009-02-05 Stephane Letz <letz@grame.fr>
* Add a resample quality parameter in audioadapter.
2009-02-01 Stephane Letz <letz@grame.fr>
* Add a JACK_INTERNAL_DIR environment variable to be used for internal clients.
......
......@@ -139,9 +139,9 @@ namespace Jack
fCaptureRingBuffer = new JackResampler*[fCaptureChannels];
fPlaybackRingBuffer = new JackResampler*[fPlaybackChannels];
for ( i = 0; i < fCaptureChannels; i++ )
fCaptureRingBuffer[i] = new JackLibSampleRateResampler();
fCaptureRingBuffer[i] = new JackLibSampleRateResampler(fAudioAdapter->GetQuality());
for ( i = 0; i < fPlaybackChannels; i++ )
fPlaybackRingBuffer[i] = new JackLibSampleRateResampler();
fPlaybackRingBuffer[i] = new JackLibSampleRateResampler(fAudioAdapter->GetQuality());
fAudioAdapter->SetRingBuffers ( fCaptureRingBuffer, fPlaybackRingBuffer );
if ( fCaptureChannels )
jack_log ( "ReadSpace = %ld", fCaptureRingBuffer[0]->ReadSpace() );
......
......@@ -92,6 +92,8 @@ namespace Jack
JackResampler** fCaptureRingBuffer;
JackResampler** fPlaybackRingBuffer;
unsigned int fQuality;
bool fRunning;
......@@ -106,6 +108,7 @@ namespace Jack
fAdaptedSampleRate ( sample_rate ),
fHostDLL ( buffer_size, sample_rate ),
fAdaptedDLL ( buffer_size, sample_rate ),
fQuality(0),
fRunning ( false )
{}
......@@ -129,6 +132,11 @@ namespace Jack
}
void ResetRingBuffers();
unsigned int GetQuality()
{
return fQuality;
}
virtual int Open();
virtual int Close();
......
......@@ -231,7 +231,7 @@ int JackAudioDriver::ProcessSync()
{
// Read input buffers for the current cycle
if (Read() < 0) {
jack_error("ProcessSync: read error, skip cycle");
jack_error("JackAudioDriver::ProcessSync: read error, skip cycle");
return 0; // Skip cycle, but continue processing...
}
......
......@@ -27,7 +27,37 @@ JackLibSampleRateResampler::JackLibSampleRateResampler()
{
int error;
fResampler = src_new(SRC_LINEAR, 1, &error);
//fResampler = src_new(SRC_SINC_BEST_QUALITY, 1, &error);
if (error != 0)
jack_error("JackLibSampleRateResampler::JackLibSampleRateResampler err = %s", src_strerror(error));
}
JackLibSampleRateResampler::JackLibSampleRateResampler(unsigned int quality)
:JackResampler(),fRatio(1)
{
switch (quality) {
case 0:
quality = SRC_LINEAR;
break;
case 1:
quality = SRC_ZERO_ORDER_HOLD;
break;
case 2:
quality = SRC_SINC_FASTEST;
break;
case 3:
quality = SRC_SINC_MEDIUM_QUALITY;
break;
case 4:
quality = SRC_SINC_BEST_QUALITY;
break;
default:
quality = SRC_LINEAR;
jack_error("Out of range resample quality");
break;
}
int error;
fResampler = src_new(quality, 1, &error);
if (error != 0)
jack_error("JackLibSampleRateResampler::JackLibSampleRateResampler err = %s", src_strerror(error));
}
......
......@@ -46,6 +46,7 @@ class JackLibSampleRateResampler : public JackResampler
public:
JackLibSampleRateResampler();
JackLibSampleRateResampler(unsigned int quality);
virtual ~JackLibSampleRateResampler();
unsigned int ReadResample(float* buffer, unsigned int frames);
......
......@@ -71,6 +71,9 @@ namespace Jack
case 'p':
SetAdaptedBufferSize ( param->value.ui );
break;
case 'q':
fQuality = param->value.ui;
break;
}
}
......@@ -211,16 +214,14 @@ extern "C"
SERVER_EXPORT jack_driver_desc_t* jack_get_descriptor()
{
jack_driver_desc_t *desc;
jack_driver_param_desc_t * params;
unsigned int i;
desc = ( jack_driver_desc_t* ) calloc ( 1, sizeof ( jack_driver_desc_t ) );
strcpy ( desc->name, "audioadapter" ); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy ( desc->desc, "netjack audio <==> net backend adapter" ); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 9;
params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) );
desc->nparams = 10;
desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) );
i = 0;
strcpy ( params[i].name, "capture" );
......@@ -298,8 +299,16 @@ extern "C"
strcpy ( params[i].short_desc,
"Number of playback channels (defaults to hardware max)" );
strcpy ( params[i].long_desc, params[i].short_desc );
i++;
strcpy(desc->params[i].name, "quality");
desc->params[i].character = 'q';
desc->params[i].type = JackDriverParamInt;
desc->params[i].value.ui = 0;
strcpy(desc->params[i].short_desc, "Resample algorithm quality (0 - 4)");
strcpy(desc->params[i].long_desc, desc->params[i].short_desc);
desc->params = params;
return desc;
}
......
......@@ -388,6 +388,10 @@ OSStatus JackCoreAudioAdapter::Render(void *inRefCon,
case 'l':
DisplayDeviceNames();
break;
case 'q':
fQuality = param->value.ui;
break;
}
}
......@@ -993,7 +997,7 @@ extern "C"
strcpy(desc->name, "audioadapter"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "netjack audio <==> net backend adapter"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 10;
desc->nparams = 11;
desc->params = (jack_driver_param_desc_t*)calloc(desc->nparams, sizeof(jack_driver_param_desc_t));
i = 0;
......@@ -1075,6 +1079,14 @@ extern "C"
desc->params[i].value.i = TRUE;
strcpy(desc->params[i].short_desc, "Display available CoreAudio devices");
strcpy(desc->params[i].long_desc, desc->params[i].short_desc);
i++;
strcpy(desc->params[i].name, "quality");
desc->params[i].character = 'q';
desc->params[i].type = JackDriverParamInt;
desc->params[i].value.ui = 0;
strcpy(desc->params[i].short_desc, "Resample algorithm quality (0 - 4)");
strcpy(desc->params[i].long_desc, desc->params[i].short_desc);
return desc;
}
......
......@@ -125,6 +125,9 @@ namespace Jack
case 'l' :
fPaDevices.DisplayDevicesNames();
break;
case 'q':
fQuality = param->value.ui;
break;
}
}
......@@ -244,7 +247,7 @@ extern "C"
strcpy(desc->name, "audioadapter"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "netjack audio <==> net backend adapter"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 8;
desc->nparams = 9;
desc->params = (jack_driver_param_desc_t*)calloc(desc->nparams, sizeof(jack_driver_param_desc_t));
i = 0;
......@@ -311,6 +314,14 @@ extern "C"
desc->params[i].value.i = TRUE;
strcpy(desc->params[i].short_desc, "Display available PortAudio devices");
strcpy(desc->params[i].long_desc, desc->params[i].short_desc);
i++;
strcpy(desc->params[i].name, "quality");
desc->params[i].character = 'q';
desc->params[i].type = JackDriverParamInt;
desc->params[i].value.ui = 0;
strcpy(desc->params[i].short_desc, "Resample algorithm quality (0 - 4)");
strcpy(desc->params[i].long_desc, desc->params[i].short_desc);
return desc;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment