git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4182 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.7
| @@ -37,6 +37,7 @@ Valerio Pilo | |||||
| 2011-03-11 Stephane Letz <letz@grame.fr> | 2011-03-11 Stephane Letz <letz@grame.fr> | ||||
| * Correct JackNetMaster::SetBufferSize. | * Correct JackNetMaster::SetBufferSize. | ||||
| * Use jack_default_audio_sample_t instead of float consistently. | |||||
| 2011-03-10 Stephane Letz <letz@grame.fr> | 2011-03-10 Stephane Letz <letz@grame.fr> | ||||
| @@ -36,17 +36,17 @@ namespace Jack | |||||
| int JackAudioAdapter::Process (jack_nframes_t frames, void* arg) | int JackAudioAdapter::Process (jack_nframes_t frames, void* arg) | ||||
| { | { | ||||
| JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg); | JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg); | ||||
| float* inputBuffer[adapter->fAudioAdapter->GetInputs()]; | |||||
| float* outputBuffer[adapter->fAudioAdapter->GetOutputs()]; | |||||
| jack_default_audio_sample_t* inputBuffer[adapter->fAudioAdapter->GetInputs()]; | |||||
| jack_default_audio_sample_t* outputBuffer[adapter->fAudioAdapter->GetOutputs()]; | |||||
| // Always clear output | // Always clear output | ||||
| for (int i = 0; i < adapter->fAudioAdapter->GetInputs(); i++) { | for (int i = 0; i < adapter->fAudioAdapter->GetInputs(); i++) { | ||||
| inputBuffer[i] = (float*)jack_port_get_buffer(adapter->fCapturePortList[i], frames); | |||||
| memset(inputBuffer[i], 0, frames * sizeof(float)); | |||||
| inputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fCapturePortList[i], frames); | |||||
| memset(inputBuffer[i], 0, frames * sizeof(jack_default_audio_sample_t)); | |||||
| } | } | ||||
| for (int i = 0; i < adapter->fAudioAdapter->GetOutputs(); i++) { | for (int i = 0; i < adapter->fAudioAdapter->GetOutputs(); i++) { | ||||
| outputBuffer[i] = (float*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames); | |||||
| outputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames); | |||||
| } | } | ||||
| adapter->fAudioAdapter->PullAndPush(inputBuffer, outputBuffer, frames); | adapter->fAudioAdapter->PullAndPush(inputBuffer, outputBuffer, frames); | ||||
| @@ -88,18 +88,18 @@ namespace Jack | |||||
| JackResampler** fCaptureRingBuffer; | JackResampler** fCaptureRingBuffer; | ||||
| JackResampler** fPlaybackRingBuffer; | JackResampler** fPlaybackRingBuffer; | ||||
| unsigned int fQuality; | unsigned int fQuality; | ||||
| unsigned int fRingbufferCurSize; | unsigned int fRingbufferCurSize; | ||||
| jack_time_t fPullAndPushTime; | jack_time_t fPullAndPushTime; | ||||
| bool fRunning; | bool fRunning; | ||||
| bool fAdaptative; | bool fAdaptative; | ||||
| void ResetRingBuffers(); | void ResetRingBuffers(); | ||||
| void AdaptRingBufferSize(); | void AdaptRingBufferSize(); | ||||
| void GrowRingBufferSize(); | void GrowRingBufferSize(); | ||||
| public: | public: | ||||
| JackAudioAdapterInterface ( jack_nframes_t buffer_size, jack_nframes_t sample_rate ): | JackAudioAdapterInterface ( jack_nframes_t buffer_size, jack_nframes_t sample_rate ): | ||||
| @@ -122,15 +122,15 @@ namespace Jack | |||||
| {} | {} | ||||
| virtual void Reset(); | virtual void Reset(); | ||||
| void Create(); | void Create(); | ||||
| void Destroy(); | void Destroy(); | ||||
| virtual int Open() | virtual int Open() | ||||
| { | { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| virtual int Close() | virtual int Close() | ||||
| { | { | ||||
| return 0; | return 0; | ||||
| @@ -139,7 +139,7 @@ namespace Jack | |||||
| virtual int SetHostBufferSize ( jack_nframes_t buffer_size ) | virtual int SetHostBufferSize ( jack_nframes_t buffer_size ) | ||||
| { | { | ||||
| fHostBufferSize = buffer_size; | fHostBufferSize = buffer_size; | ||||
| if (fAdaptative) | |||||
| if (fAdaptative) | |||||
| AdaptRingBufferSize(); | AdaptRingBufferSize(); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -147,7 +147,7 @@ namespace Jack | |||||
| virtual int SetAdaptedBufferSize ( jack_nframes_t buffer_size ) | virtual int SetAdaptedBufferSize ( jack_nframes_t buffer_size ) | ||||
| { | { | ||||
| fAdaptedBufferSize = buffer_size; | fAdaptedBufferSize = buffer_size; | ||||
| if (fAdaptative) | |||||
| if (fAdaptative) | |||||
| AdaptRingBufferSize(); | AdaptRingBufferSize(); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -179,7 +179,7 @@ namespace Jack | |||||
| SetAdaptedSampleRate ( sample_rate ); | SetAdaptedSampleRate ( sample_rate ); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| void SetInputs ( int inputs ) | void SetInputs ( int inputs ) | ||||
| { | { | ||||
| jack_log ( "JackAudioAdapterInterface::SetInputs %d", inputs ); | jack_log ( "JackAudioAdapterInterface::SetInputs %d", inputs ); | ||||
| @@ -203,10 +203,10 @@ namespace Jack | |||||
| jack_log ( "JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels ); | jack_log ( "JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels ); | ||||
| return fPlaybackChannels; | return fPlaybackChannels; | ||||
| } | } | ||||
| int PushAndPull(float** inputBuffer, float** outputBuffer, unsigned int inNumberFrames); | |||||
| int PullAndPush(float** inputBuffer, float** outputBuffer, unsigned int inNumberFrames); | |||||
| int PushAndPull(jack_default_audio_sample_t** inputBuffer, jack_default_audio_sample_t** outputBuffer, unsigned int inNumberFrames); | |||||
| int PullAndPush(jack_default_audio_sample_t** inputBuffer, jack_default_audio_sample_t** outputBuffer, unsigned int inNumberFrames); | |||||
| }; | }; | ||||
| } | } | ||||
| @@ -178,8 +178,8 @@ int JackAudioDriver::Write() | |||||
| { | { | ||||
| for (int i = 0; i < fPlaybackChannels; i++) { | for (int i = 0; i < fPlaybackChannels; i++) { | ||||
| if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) { | if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) { | ||||
| float* buffer = GetOutputBuffer(i); | |||||
| int size = sizeof(float) * fEngineControl->fBufferSize; | |||||
| jack_default_audio_sample_t* buffer = GetOutputBuffer(i); | |||||
| int size = sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize; | |||||
| // Monitor ports | // Monitor ports | ||||
| if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[i]) > 0) | if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[i]) > 0) | ||||
| memcpy(GetMonitorBuffer(i), buffer, size); | memcpy(GetMonitorBuffer(i), buffer, size); | ||||
| @@ -38,11 +38,11 @@ static void AudioBufferInit(void* buffer, size_t buffer_size, jack_nframes_t) | |||||
| memset(buffer, 0, buffer_size); | memset(buffer, 0, buffer_size); | ||||
| } | } | ||||
| static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_t frames) | |||||
| static inline void MixAudioBuffer(jack_default_audio_sample_t* mixbuffer, jack_default_audio_sample_t* buffer, jack_nframes_t frames) | |||||
| { | { | ||||
| #ifdef __APPLE__ | #ifdef __APPLE__ | ||||
| // It seems that a vector mult only operation does not exist... | // It seems that a vector mult only operation does not exist... | ||||
| float gain = 1.0f; | |||||
| jack_default_audio_sample_t gain = jack_default_audio_sample_t(1.0); | |||||
| vDSP_vsma(buffer, 1, &gain, mixbuffer, 1, mixbuffer, 1, frames); | vDSP_vsma(buffer, 1, &gain, mixbuffer, 1, mixbuffer, 1, frames); | ||||
| #else | #else | ||||
| jack_nframes_t frames_group = frames / 4; | jack_nframes_t frames_group = frames / 4; | ||||
| @@ -57,14 +57,14 @@ static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_ | |||||
| buffer += 4; | buffer += 4; | ||||
| frames_group--; | frames_group--; | ||||
| #else | #else | ||||
| register float mixFloat1 = *mixbuffer; | |||||
| register float sourceFloat1 = *buffer; | |||||
| register float mixFloat2 = *(mixbuffer + 1); | |||||
| register float sourceFloat2 = *(buffer + 1); | |||||
| register float mixFloat3 = *(mixbuffer + 2); | |||||
| register float sourceFloat3 = *(buffer + 2); | |||||
| register float mixFloat4 = *(mixbuffer + 3); | |||||
| register float sourceFloat4 = *(buffer + 3); | |||||
| register jack_default_audio_sample_t mixFloat1 = *mixbuffer; | |||||
| register jack_default_audio_sample_t sourceFloat1 = *buffer; | |||||
| register jack_default_audio_sample_t mixFloat2 = *(mixbuffer + 1); | |||||
| register jack_default_audio_sample_t sourceFloat2 = *(buffer + 1); | |||||
| register jack_default_audio_sample_t mixFloat3 = *(mixbuffer + 2); | |||||
| register jack_default_audio_sample_t sourceFloat3 = *(buffer + 2); | |||||
| register jack_default_audio_sample_t mixFloat4 = *(mixbuffer + 3); | |||||
| register jack_default_audio_sample_t sourceFloat4 = *(buffer + 3); | |||||
| buffer += 4; | buffer += 4; | ||||
| frames_group--; | frames_group--; | ||||
| @@ -84,8 +84,8 @@ static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_ | |||||
| } | } | ||||
| while (frames > 0) { | while (frames > 0) { | ||||
| register float mixFloat1 = *mixbuffer; | |||||
| register float sourceFloat1 = *buffer; | |||||
| register jack_default_audio_sample_t mixFloat1 = *mixbuffer; | |||||
| register jack_default_audio_sample_t sourceFloat1 = *buffer; | |||||
| buffer++; | buffer++; | ||||
| frames--; | frames--; | ||||
| mixFloat1 += sourceFloat1; | mixFloat1 += sourceFloat1; | ||||
| @@ -104,8 +104,8 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun | |||||
| jack_nframes_t frames_group = nframes / 4; | jack_nframes_t frames_group = nframes / 4; | ||||
| jack_nframes_t remaining_frames = nframes % 4; | jack_nframes_t remaining_frames = nframes % 4; | ||||
| float * source = static_cast<float*>(src_buffers[0]); | |||||
| float * target = static_cast<float*>(mixbuffer); | |||||
| jack_default_audio_sample_t * source = static_cast<jack_default_audio_sample_t*>(src_buffers[0]); | |||||
| jack_default_audio_sample_t * target = static_cast<jack_default_audio_sample_t*>(mixbuffer); | |||||
| while (frames_group > 0) | while (frames_group > 0) | ||||
| { | { | ||||
| @@ -120,19 +120,19 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun | |||||
| target[i] = source[i]; | target[i] = source[i]; | ||||
| #else | #else | ||||
| memcpy(mixbuffer, src_buffers[0], nframes * sizeof(float)); | |||||
| memcpy(mixbuffer, src_buffers[0], nframes * sizeof(jack_default_audio_sample_t)); | |||||
| #endif | #endif | ||||
| // Mix remaining buffers | // Mix remaining buffers | ||||
| for (int i = 1; i < src_count; ++i) { | for (int i = 1; i < src_count; ++i) { | ||||
| buffer = src_buffers[i]; | buffer = src_buffers[i]; | ||||
| MixAudioBuffer(static_cast<float*>(mixbuffer), static_cast<float*>(buffer), nframes); | |||||
| MixAudioBuffer(static_cast<jack_default_audio_sample_t*>(mixbuffer), static_cast<jack_default_audio_sample_t*>(buffer), nframes); | |||||
| } | } | ||||
| } | } | ||||
| static size_t AudioBufferSize() | static size_t AudioBufferSize() | ||||
| { | { | ||||
| return GetEngineControl()->fBufferSize * sizeof(float); | |||||
| return GetEngineControl()->fBufferSize * sizeof(jack_default_audio_sample_t); | |||||
| } | } | ||||
| const JackPortType gAudioPortType = | const JackPortType gAudioPortType = | ||||
| @@ -77,7 +77,7 @@ JackPort* JackGraphManager::GetPort(jack_port_id_t port_index) | |||||
| return &fPortArray[port_index]; | return &fPortArray[port_index]; | ||||
| } | } | ||||
| float* JackGraphManager::GetBuffer(jack_port_id_t port_index) | |||||
| jack_default_audio_sample_t* JackGraphManager::GetBuffer(jack_port_id_t port_index) | |||||
| { | { | ||||
| return fPortArray[port_index].GetBuffer(); | return fPortArray[port_index].GetBuffer(); | ||||
| } | } | ||||
| @@ -49,7 +49,7 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState | |||||
| jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); | jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); | ||||
| void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); | void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); | ||||
| void GetPortsAux(const char** matching_ports, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | void GetPortsAux(const char** matching_ports, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); | ||||
| float* GetBuffer(jack_port_id_t port_index); | |||||
| jack_default_audio_sample_t* GetBuffer(jack_port_id_t port_index); | |||||
| void* GetBufferAux(JackConnectionManager* manager, jack_port_id_t port_index, jack_nframes_t frames); | void* GetBufferAux(JackConnectionManager* manager, jack_port_id_t port_index, jack_nframes_t frames); | ||||
| jack_nframes_t ComputeTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count); | jack_nframes_t ComputeTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count); | ||||
| void RecalculateLatencyAux(jack_port_id_t port_index, jack_latency_callback_mode_t mode); | void RecalculateLatencyAux(jack_port_id_t port_index, jack_latency_callback_mode_t mode); | ||||
| @@ -27,7 +27,7 @@ JackLibSampleRateResampler::JackLibSampleRateResampler() | |||||
| { | { | ||||
| int error; | int error; | ||||
| fResampler = src_new(SRC_LINEAR, 1, &error); | fResampler = src_new(SRC_LINEAR, 1, &error); | ||||
| if (error != 0) | |||||
| if (error != 0) | |||||
| jack_error("JackLibSampleRateResampler::JackLibSampleRateResampler err = %s", src_strerror(error)); | jack_error("JackLibSampleRateResampler::JackLibSampleRateResampler err = %s", src_strerror(error)); | ||||
| } | } | ||||
| @@ -50,7 +50,7 @@ JackLibSampleRateResampler::JackLibSampleRateResampler(unsigned int quality) | |||||
| case 4: | case 4: | ||||
| quality = SRC_SINC_BEST_QUALITY; | quality = SRC_SINC_BEST_QUALITY; | ||||
| break; | break; | ||||
| default: | |||||
| default: | |||||
| quality = SRC_LINEAR; | quality = SRC_LINEAR; | ||||
| jack_error("Out of range resample quality"); | jack_error("Out of range resample quality"); | ||||
| break; | break; | ||||
| @@ -58,7 +58,7 @@ JackLibSampleRateResampler::JackLibSampleRateResampler(unsigned int quality) | |||||
| int error; | int error; | ||||
| fResampler = src_new(quality, 1, &error); | fResampler = src_new(quality, 1, &error); | ||||
| if (error != 0) | |||||
| if (error != 0) | |||||
| jack_error("JackLibSampleRateResampler::JackLibSampleRateResampler err = %s", src_strerror(error)); | jack_error("JackLibSampleRateResampler::JackLibSampleRateResampler err = %s", src_strerror(error)); | ||||
| } | } | ||||
| @@ -73,103 +73,103 @@ void JackLibSampleRateResampler::Reset(unsigned int new_size) | |||||
| src_reset(fResampler); | src_reset(fResampler); | ||||
| } | } | ||||
| unsigned int JackLibSampleRateResampler::ReadResample(float* buffer, unsigned int frames) | |||||
| unsigned int JackLibSampleRateResampler::ReadResample(jack_default_audio_sample_t* buffer, unsigned int frames) | |||||
| { | { | ||||
| jack_ringbuffer_data_t ring_buffer_data[2]; | jack_ringbuffer_data_t ring_buffer_data[2]; | ||||
| SRC_DATA src_data; | SRC_DATA src_data; | ||||
| unsigned int frames_to_write = frames; | unsigned int frames_to_write = frames; | ||||
| unsigned int written_frames = 0; | unsigned int written_frames = 0; | ||||
| int res; | int res; | ||||
| jack_ringbuffer_get_read_vector(fRingBuffer, ring_buffer_data); | jack_ringbuffer_get_read_vector(fRingBuffer, ring_buffer_data); | ||||
| unsigned int available_frames = (ring_buffer_data[0].len + ring_buffer_data[1].len) / sizeof(float); | |||||
| unsigned int available_frames = (ring_buffer_data[0].len + ring_buffer_data[1].len) / sizeof(jack_default_audio_sample_t); | |||||
| jack_log("Output available = %ld", available_frames); | jack_log("Output available = %ld", available_frames); | ||||
| for (int j = 0; j < 2; j++) { | for (int j = 0; j < 2; j++) { | ||||
| if (ring_buffer_data[j].len > 0) { | if (ring_buffer_data[j].len > 0) { | ||||
| src_data.data_in = (float*)ring_buffer_data[j].buf; | |||||
| src_data.data_in = (jack_default_audio_sample_t*)ring_buffer_data[j].buf; | |||||
| src_data.data_out = &buffer[written_frames]; | src_data.data_out = &buffer[written_frames]; | ||||
| src_data.input_frames = ring_buffer_data[j].len / sizeof(float); | |||||
| src_data.input_frames = ring_buffer_data[j].len / sizeof(jack_default_audio_sample_t); | |||||
| src_data.output_frames = frames_to_write; | src_data.output_frames = frames_to_write; | ||||
| src_data.end_of_input = 0; | src_data.end_of_input = 0; | ||||
| src_data.src_ratio = fRatio; | src_data.src_ratio = fRatio; | ||||
| res = src_process(fResampler, &src_data); | res = src_process(fResampler, &src_data); | ||||
| if (res != 0) { | if (res != 0) { | ||||
| jack_error("JackLibSampleRateResampler::ReadResample ratio = %f err = %s", fRatio, src_strerror(res)); | jack_error("JackLibSampleRateResampler::ReadResample ratio = %f err = %s", fRatio, src_strerror(res)); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| frames_to_write -= src_data.output_frames_gen; | frames_to_write -= src_data.output_frames_gen; | ||||
| written_frames += src_data.output_frames_gen; | written_frames += src_data.output_frames_gen; | ||||
| if ((src_data.input_frames_used == 0 || src_data.output_frames_gen == 0) && j == 0) { | if ((src_data.input_frames_used == 0 || src_data.output_frames_gen == 0) && j == 0) { | ||||
| jack_log("Output : j = %d input_frames_used = %ld output_frames_gen = %ld frames1 = %lu frames2 = %lu" | jack_log("Output : j = %d input_frames_used = %ld output_frames_gen = %ld frames1 = %lu frames2 = %lu" | ||||
| , j, src_data.input_frames_used, src_data.output_frames_gen, ring_buffer_data[0].len, ring_buffer_data[1].len); | , j, src_data.input_frames_used, src_data.output_frames_gen, ring_buffer_data[0].len, ring_buffer_data[1].len); | ||||
| } | } | ||||
| jack_log("Output : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | jack_log("Output : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | ||||
| jack_ringbuffer_read_advance(fRingBuffer, src_data.input_frames_used * sizeof(float)); | |||||
| jack_ringbuffer_read_advance(fRingBuffer, src_data.input_frames_used * sizeof(jack_default_audio_sample_t)); | |||||
| } | } | ||||
| } | } | ||||
| if (written_frames < frames) { | if (written_frames < frames) { | ||||
| jack_error("Output available = %ld", available_frames); | jack_error("Output available = %ld", available_frames); | ||||
| jack_error("JackLibSampleRateResampler::ReadResample error written_frames = %ld", written_frames); | jack_error("JackLibSampleRateResampler::ReadResample error written_frames = %ld", written_frames); | ||||
| } | } | ||||
| return written_frames; | return written_frames; | ||||
| } | } | ||||
| unsigned int JackLibSampleRateResampler::WriteResample(float* buffer, unsigned int frames) | |||||
| unsigned int JackLibSampleRateResampler::WriteResample(jack_default_audio_sample_t* buffer, unsigned int frames) | |||||
| { | { | ||||
| jack_ringbuffer_data_t ring_buffer_data[2]; | jack_ringbuffer_data_t ring_buffer_data[2]; | ||||
| SRC_DATA src_data; | SRC_DATA src_data; | ||||
| unsigned int frames_to_read = frames; | unsigned int frames_to_read = frames; | ||||
| unsigned int read_frames = 0; | unsigned int read_frames = 0; | ||||
| int res; | int res; | ||||
| jack_ringbuffer_get_write_vector(fRingBuffer, ring_buffer_data); | jack_ringbuffer_get_write_vector(fRingBuffer, ring_buffer_data); | ||||
| unsigned int available_frames = (ring_buffer_data[0].len + ring_buffer_data[1].len) / sizeof(float); | |||||
| unsigned int available_frames = (ring_buffer_data[0].len + ring_buffer_data[1].len) / sizeof(jack_default_audio_sample_t); | |||||
| jack_log("Input available = %ld", available_frames); | jack_log("Input available = %ld", available_frames); | ||||
| for (int j = 0; j < 2; j++) { | for (int j = 0; j < 2; j++) { | ||||
| if (ring_buffer_data[j].len > 0) { | if (ring_buffer_data[j].len > 0) { | ||||
| src_data.data_in = &buffer[read_frames]; | src_data.data_in = &buffer[read_frames]; | ||||
| src_data.data_out = (float*)ring_buffer_data[j].buf; | |||||
| src_data.data_out = (jack_default_audio_sample_t*)ring_buffer_data[j].buf; | |||||
| src_data.input_frames = frames_to_read; | src_data.input_frames = frames_to_read; | ||||
| src_data.output_frames = (ring_buffer_data[j].len / sizeof(float)); | |||||
| src_data.output_frames = (ring_buffer_data[j].len / sizeof(jack_default_audio_sample_t)); | |||||
| src_data.end_of_input = 0; | src_data.end_of_input = 0; | ||||
| src_data.src_ratio = fRatio; | src_data.src_ratio = fRatio; | ||||
| res = src_process(fResampler, &src_data); | res = src_process(fResampler, &src_data); | ||||
| if (res != 0) { | if (res != 0) { | ||||
| jack_error("JackLibSampleRateResampler::ReadResample ratio = %f err = %s", fRatio, src_strerror(res)); | jack_error("JackLibSampleRateResampler::ReadResample ratio = %f err = %s", fRatio, src_strerror(res)); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| frames_to_read -= src_data.input_frames_used; | frames_to_read -= src_data.input_frames_used; | ||||
| read_frames += src_data.input_frames_used; | read_frames += src_data.input_frames_used; | ||||
| if ((src_data.input_frames_used == 0 || src_data.output_frames_gen == 0) && j == 0) { | if ((src_data.input_frames_used == 0 || src_data.output_frames_gen == 0) && j == 0) { | ||||
| jack_log("Input : j = %d input_frames_used = %ld output_frames_gen = %ld frames1 = %lu frames2 = %lu" | jack_log("Input : j = %d input_frames_used = %ld output_frames_gen = %ld frames1 = %lu frames2 = %lu" | ||||
| , j, src_data.input_frames_used, src_data.output_frames_gen, ring_buffer_data[0].len, ring_buffer_data[1].len); | , j, src_data.input_frames_used, src_data.output_frames_gen, ring_buffer_data[0].len, ring_buffer_data[1].len); | ||||
| } | } | ||||
| jack_log("Input : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | jack_log("Input : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | ||||
| jack_ringbuffer_write_advance(fRingBuffer, src_data.output_frames_gen * sizeof(float)); | |||||
| jack_ringbuffer_write_advance(fRingBuffer, src_data.output_frames_gen * sizeof(jack_default_audio_sample_t)); | |||||
| } | } | ||||
| } | } | ||||
| if (read_frames < frames) { | if (read_frames < frames) { | ||||
| jack_error("Input available = %ld", available_frames); | jack_error("Input available = %ld", available_frames); | ||||
| jack_error("JackLibSampleRateResampler::ReadResample error read_frames = %ld", read_frames); | jack_error("JackLibSampleRateResampler::ReadResample error read_frames = %ld", read_frames); | ||||
| } | } | ||||
| return read_frames; | return read_frames; | ||||
| } | } | ||||
| @@ -21,6 +21,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| #define __JackLibSampleRateResampler__ | #define __JackLibSampleRateResampler__ | ||||
| #include "JackResampler.h" | #include "JackResampler.h" | ||||
| #include "types.h" | |||||
| #include <samplerate.h> | #include <samplerate.h> | ||||
| namespace Jack | namespace Jack | ||||
| @@ -34,20 +36,20 @@ class JackLibSampleRateResampler : public JackResampler | |||||
| { | { | ||||
| private: | private: | ||||
| SRC_STATE* fResampler; | SRC_STATE* fResampler; | ||||
| public: | public: | ||||
| JackLibSampleRateResampler(); | JackLibSampleRateResampler(); | ||||
| JackLibSampleRateResampler(unsigned int quality); | JackLibSampleRateResampler(unsigned int quality); | ||||
| virtual ~JackLibSampleRateResampler(); | virtual ~JackLibSampleRateResampler(); | ||||
| unsigned int ReadResample(float* buffer, unsigned int frames); | |||||
| unsigned int WriteResample(float* buffer, unsigned int frames); | |||||
| unsigned int ReadResample(jack_default_audio_sample_t* buffer, unsigned int frames); | |||||
| unsigned int WriteResample(jack_default_audio_sample_t* buffer, unsigned int frames); | |||||
| void Reset(unsigned int new_size); | void Reset(unsigned int new_size); | ||||
| }; | }; | ||||
| } | } | ||||
| @@ -34,7 +34,7 @@ int JackLoopbackDriver::Process() | |||||
| { | { | ||||
| // Loopback copy | // Loopback copy | ||||
| for (int i = 0; i < fCaptureChannels; i++) { | for (int i = 0; i < fCaptureChannels; i++) { | ||||
| memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(float) * fEngineControl->fBufferSize); | |||||
| memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); | |||||
| } | } | ||||
| fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients | fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients | ||||
| @@ -54,7 +54,7 @@ extern "C" | |||||
| { | { | ||||
| #endif | #endif | ||||
| SERVER_EXPORT jack_driver_desc_t * driver_get_descriptor() | |||||
| SERVER_EXPORT jack_driver_desc_t * driver_get_descriptor() | |||||
| { | { | ||||
| jack_driver_desc_t * desc; | jack_driver_desc_t * desc; | ||||
| unsigned int i; | unsigned int i; | ||||
| @@ -65,7 +65,7 @@ extern "C" | |||||
| desc->nparams = 1; | desc->nparams = 1; | ||||
| desc->params = (jack_driver_param_desc_t*)calloc (desc->nparams, sizeof (jack_driver_param_desc_t)); | desc->params = (jack_driver_param_desc_t*)calloc (desc->nparams, sizeof (jack_driver_param_desc_t)); | ||||
| i = 0; | i = 0; | ||||
| strcpy(desc->params[i].name, "channels"); | strcpy(desc->params[i].name, "channels"); | ||||
| desc->params[i].character = 'c'; | desc->params[i].character = 'c'; | ||||
| @@ -77,12 +77,12 @@ extern "C" | |||||
| return desc; | return desc; | ||||
| } | } | ||||
| SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params) | |||||
| SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params) | |||||
| { | { | ||||
| const JSList * node; | const JSList * node; | ||||
| const jack_driver_param_t * param; | const jack_driver_param_t * param; | ||||
| int channels = 2; | int channels = 2; | ||||
| for (node = params; node; node = jack_slist_next (node)) { | for (node = params; node; node = jack_slist_next (node)) { | ||||
| param = (const jack_driver_param_t *) node->data; | param = (const jack_driver_param_t *) node->data; | ||||
| @@ -93,7 +93,7 @@ extern "C" | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Jack::JackDriverClientInterface* driver = new Jack::JackLoopbackDriver(engine, table); | Jack::JackDriverClientInterface* driver = new Jack::JackLoopbackDriver(engine, table); | ||||
| if (driver->Open(1, 1, channels, channels, false, "loopback", "loopback", 0, 0) == 0) { | if (driver->Open(1, 1, channels, channels, false, "loopback", "loopback", 0, 0) == 0) { | ||||
| return driver; | return driver; | ||||
| @@ -60,11 +60,11 @@ int JackMidiDriver::Open(bool capturing, | |||||
| { | { | ||||
| fCaptureChannels = inchannels; | fCaptureChannels = inchannels; | ||||
| fPlaybackChannels = outchannels; | fPlaybackChannels = outchannels; | ||||
| for (int i = 0; i < fCaptureChannels; i++) { | for (int i = 0; i < fCaptureChannels; i++) { | ||||
| fRingBuffer[i] = jack_ringbuffer_create(sizeof(float) * BUFFER_SIZE_MAX); | |||||
| fRingBuffer[i] = jack_ringbuffer_create(sizeof(jack_default_audio_sample_t) * BUFFER_SIZE_MAX); | |||||
| } | } | ||||
| return JackDriver::Open(capturing, playing, inchannels, outchannels, monitor, capture_driver_name, playback_driver_name, capture_latency, playback_latency); | return JackDriver::Open(capturing, playing, inchannels, outchannels, monitor, capture_driver_name, playback_driver_name, capture_latency, playback_latency); | ||||
| } | } | ||||
| @@ -141,11 +141,11 @@ int JackMidiDriver::ProcessNull() | |||||
| int JackMidiDriver::Process() | int JackMidiDriver::Process() | ||||
| { | { | ||||
| // Read input buffers for the current cycle | // Read input buffers for the current cycle | ||||
| if (Read() < 0) { | |||||
| if (Read() < 0) { | |||||
| jack_error("JackMidiDriver::Process: read error, skip cycle"); | jack_error("JackMidiDriver::Process: read error, skip cycle"); | ||||
| return 0; // Skip cycle, but continue processing... | return 0; // Skip cycle, but continue processing... | ||||
| } | } | ||||
| fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); | fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); | ||||
| if (fEngineControl->fSyncMode) { | if (fEngineControl->fSyncMode) { | ||||
| if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) { | if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) { | ||||
| @@ -153,13 +153,13 @@ int JackMidiDriver::Process() | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| } | } | ||||
| // Write output buffers for the current cycle | // Write output buffers for the current cycle | ||||
| if (Write() < 0) { | |||||
| if (Write() < 0) { | |||||
| jack_error("JackMidiDriver::Process: write error, skip cycle"); | jack_error("JackMidiDriver::Process: write error, skip cycle"); | ||||
| return 0; // Skip cycle, but continue processing... | return 0; // Skip cycle, but continue processing... | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -72,7 +72,7 @@ static void MidiBufferInit(void* buffer, size_t buffer_size, jack_nframes_t nfra | |||||
| JackMidiBuffer* midi = (JackMidiBuffer*)buffer; | JackMidiBuffer* midi = (JackMidiBuffer*)buffer; | ||||
| midi->magic = JackMidiBuffer::MAGIC; | midi->magic = JackMidiBuffer::MAGIC; | ||||
| /* Since port buffer has actually always BUFFER_SIZE_MAX frames, we can safely use all the size */ | /* Since port buffer has actually always BUFFER_SIZE_MAX frames, we can safely use all the size */ | ||||
| midi->buffer_size = BUFFER_SIZE_MAX * sizeof(float); | |||||
| midi->buffer_size = BUFFER_SIZE_MAX * sizeof(jack_default_audio_sample_t); | |||||
| midi->Reset(nframes); | midi->Reset(nframes); | ||||
| } | } | ||||
| @@ -135,7 +135,7 @@ static void MidiBufferMixdown(void* mixbuffer, void** src_buffers, int src_count | |||||
| static size_t MidiBufferSize() | static size_t MidiBufferSize() | ||||
| { | { | ||||
| return BUFFER_SIZE_MAX * sizeof(float); | |||||
| return BUFFER_SIZE_MAX * sizeof(jack_default_audio_sample_t); | |||||
| } | } | ||||
| const JackPortType gMidiPortType = | const JackPortType gMidiPortType = | ||||
| @@ -743,8 +743,8 @@ namespace Jack | |||||
| // audio port, encode celt data. | // audio port, encode celt data. | ||||
| int encoded_bytes; | int encoded_bytes; | ||||
| float *floatbuf = (float *)alloca (sizeof(float) * nframes ); | |||||
| memcpy( floatbuf, buf, nframes*sizeof(float) ); | |||||
| jack_default_audio_sample_t *floatbuf = (jack_default_audio_sample_t *)alloca (sizeof(jack_default_audio_sample_t) * nframes ); | |||||
| memcpy( floatbuf, buf, nframes * sizeof(jack_default_audio_sample_t) ); | |||||
| CELTEncoder *encoder = (CELTEncoder *)src_node->data; | CELTEncoder *encoder = (CELTEncoder *)src_node->data; | ||||
| encoded_bytes = celt_encode_float( encoder, floatbuf, NULL, packet_bufX, net_period_up ); | encoded_bytes = celt_encode_float( encoder, floatbuf, NULL, packet_bufX, net_period_up ); | ||||
| if( encoded_bytes != (int)net_period_up ) | if( encoded_bytes != (int)net_period_up ) | ||||
| @@ -77,14 +77,14 @@ namespace Jack | |||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) | for ( int port_index = 0; port_index < fNPorts; port_index++ ) | ||||
| { | { | ||||
| char* write_pos = fBuffer + pos; | char* write_pos = fBuffer + pos; | ||||
| copy_size = sizeof ( JackMidiBuffer ) + fPortBuffer[port_index]->event_count * sizeof ( JackMidiEvent ); | copy_size = sizeof ( JackMidiBuffer ) + fPortBuffer[port_index]->event_count * sizeof ( JackMidiEvent ); | ||||
| memcpy ( fBuffer + pos, fPortBuffer[port_index], copy_size ); | memcpy ( fBuffer + pos, fPortBuffer[port_index], copy_size ); | ||||
| pos += copy_size; | pos += copy_size; | ||||
| memcpy ( fBuffer + pos, fPortBuffer[port_index] + ( fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos ), | memcpy ( fBuffer + pos, fPortBuffer[port_index] + ( fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos ), | ||||
| fPortBuffer[port_index]->write_pos ); | fPortBuffer[port_index]->write_pos ); | ||||
| pos += fPortBuffer[port_index]->write_pos; | pos += fPortBuffer[port_index]->write_pos; | ||||
| JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(write_pos); | JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(write_pos); | ||||
| MidiBufferHToN(midi_buffer, midi_buffer); | MidiBufferHToN(midi_buffer, midi_buffer); | ||||
| } | } | ||||
| @@ -99,7 +99,7 @@ namespace Jack | |||||
| { | { | ||||
| JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(fBuffer + pos); | JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(fBuffer + pos); | ||||
| MidiBufferNToH(midi_buffer, midi_buffer); | MidiBufferNToH(midi_buffer, midi_buffer); | ||||
| copy_size = sizeof ( JackMidiBuffer ) + reinterpret_cast<JackMidiBuffer*> ( fBuffer + pos )->event_count * sizeof ( JackMidiEvent ); | copy_size = sizeof ( JackMidiBuffer ) + reinterpret_cast<JackMidiBuffer*> ( fBuffer + pos )->event_count * sizeof ( JackMidiEvent ); | ||||
| memcpy ( fPortBuffer[port_index], fBuffer + pos, copy_size ); | memcpy ( fPortBuffer[port_index], fBuffer + pos, copy_size ); | ||||
| pos += copy_size; | pos += copy_size; | ||||
| @@ -109,7 +109,7 @@ namespace Jack | |||||
| } | } | ||||
| return pos; | return pos; | ||||
| } | } | ||||
| int NetMidiBuffer::RenderFromNetwork ( int subcycle, size_t copy_size ) | int NetMidiBuffer::RenderFromNetwork ( int subcycle, size_t copy_size ) | ||||
| { | { | ||||
| memcpy ( fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size ); | memcpy ( fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size ); | ||||
| @@ -161,11 +161,11 @@ namespace Jack | |||||
| #ifdef __BIG_ENDIAN__ | #ifdef __BIG_ENDIAN__ | ||||
| static inline float SwapFloat(float f) | |||||
| static inline jack_default_audio_sample_t SwapFloat(jack_default_audio_sample_t f) | |||||
| { | { | ||||
| union | union | ||||
| { | { | ||||
| float f; | |||||
| jack_default_audio_sample_t f; | |||||
| unsigned char b[4]; | unsigned char b[4]; | ||||
| } dat1, dat2; | } dat1, dat2; | ||||
| @@ -180,9 +180,9 @@ namespace Jack | |||||
| void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) | void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) | ||||
| { | { | ||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) { | for ( int port_index = 0; port_index < fNPorts; port_index++ ) { | ||||
| float* src = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); | |||||
| float* dst = (float*)(fNetBuffer + port_index * fSubPeriodBytesSize); | |||||
| for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) { | |||||
| jack_default_audio_sample_t* src = (jack_default_audio_sample_t*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); | |||||
| jack_default_audio_sample_t* dst = (jack_default_audio_sample_t*)(fNetBuffer + port_index * fSubPeriodBytesSize); | |||||
| for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(jack_default_audio_sample_t); sample++) { | |||||
| dst[sample] = SwapFloat(src[sample]); | dst[sample] = SwapFloat(src[sample]); | ||||
| } | } | ||||
| } | } | ||||
| @@ -191,14 +191,14 @@ namespace Jack | |||||
| void NetAudioBuffer::RenderToJackPorts ( int subcycle ) | void NetAudioBuffer::RenderToJackPorts ( int subcycle ) | ||||
| { | { | ||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) { | for ( int port_index = 0; port_index < fNPorts; port_index++ ) { | ||||
| float* src = (float*)(fNetBuffer + port_index * fSubPeriodBytesSize); | |||||
| float* dst = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); | |||||
| for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) { | |||||
| jack_default_audio_sample_t* src = (jack_default_audio_sample_t*)(fNetBuffer + port_index * fSubPeriodBytesSize); | |||||
| jack_default_audio_sample_t* dst = (jack_default_audio_sample_t*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); | |||||
| for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(jack_default_audio_sample_t); sample++) { | |||||
| dst[sample] = SwapFloat(src[sample]); | dst[sample] = SwapFloat(src[sample]); | ||||
| } | } | ||||
| } | |||||
| } | |||||
| } | } | ||||
| #else | #else | ||||
| void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) | void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) | ||||
| @@ -376,7 +376,7 @@ namespace Jack | |||||
| jack_info ( "Bitdepth : %s", bitdepth ); | jack_info ( "Bitdepth : %s", bitdepth ); | ||||
| jack_info ( "**********************************************" ); | jack_info ( "**********************************************" ); | ||||
| } | } | ||||
| SERVER_EXPORT void NetTransportDataDisplay ( net_transport_data_t* data ) | SERVER_EXPORT void NetTransportDataDisplay ( net_transport_data_t* data ) | ||||
| { | { | ||||
| jack_info ( "********************Network Transport********************" ); | jack_info ( "********************Network Transport********************" ); | ||||
| @@ -385,7 +385,7 @@ namespace Jack | |||||
| jack_info ( "Transport cycle state : %u", data->fState ); | jack_info ( "Transport cycle state : %u", data->fState ); | ||||
| jack_info ( "**********************************************" ); | jack_info ( "**********************************************" ); | ||||
| } | } | ||||
| SERVER_EXPORT void MidiBufferHToN ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer ) | SERVER_EXPORT void MidiBufferHToN ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer ) | ||||
| { | { | ||||
| dst_buffer->magic = htonl(src_buffer->magic); | dst_buffer->magic = htonl(src_buffer->magic); | ||||
| @@ -396,7 +396,7 @@ namespace Jack | |||||
| dst_buffer->lost_events = htonl(src_buffer->lost_events); | dst_buffer->lost_events = htonl(src_buffer->lost_events); | ||||
| dst_buffer->mix_index = htonl(src_buffer->mix_index); | dst_buffer->mix_index = htonl(src_buffer->mix_index); | ||||
| } | } | ||||
| SERVER_EXPORT void MidiBufferNToH ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer ) | SERVER_EXPORT void MidiBufferNToH ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer ) | ||||
| { | { | ||||
| dst_buffer->magic = ntohl(src_buffer->magic); | dst_buffer->magic = ntohl(src_buffer->magic); | ||||
| @@ -407,7 +407,7 @@ namespace Jack | |||||
| dst_buffer->lost_events = ntohl(src_buffer->lost_events); | dst_buffer->lost_events = ntohl(src_buffer->lost_events); | ||||
| dst_buffer->mix_index = ntohl(src_buffer->mix_index); | dst_buffer->mix_index = ntohl(src_buffer->mix_index); | ||||
| } | } | ||||
| SERVER_EXPORT void TransportDataHToN ( net_transport_data_t* src_params, net_transport_data_t* dst_params ) | SERVER_EXPORT void TransportDataHToN ( net_transport_data_t* src_params, net_transport_data_t* dst_params ) | ||||
| { | { | ||||
| dst_params->fNewState = htonl(src_params->fNewState); | dst_params->fNewState = htonl(src_params->fNewState); | ||||
| @@ -433,7 +433,7 @@ namespace Jack | |||||
| dst_params->fPosition.video_offset = htonl(src_params->fPosition.video_offset); | dst_params->fPosition.video_offset = htonl(src_params->fPosition.video_offset); | ||||
| dst_params->fPosition.unique_2 = htonll(src_params->fPosition.unique_2); | dst_params->fPosition.unique_2 = htonll(src_params->fPosition.unique_2); | ||||
| } | } | ||||
| SERVER_EXPORT void TransportDataNToH ( net_transport_data_t* src_params, net_transport_data_t* dst_params ) | SERVER_EXPORT void TransportDataNToH ( net_transport_data_t* src_params, net_transport_data_t* dst_params ) | ||||
| { | { | ||||
| dst_params->fNewState = ntohl(src_params->fNewState); | dst_params->fNewState = ntohl(src_params->fNewState); | ||||
| @@ -286,7 +286,7 @@ int JackPort::UnsetAlias(const char* alias) | |||||
| void JackPort::ClearBuffer(jack_nframes_t frames) | void JackPort::ClearBuffer(jack_nframes_t frames) | ||||
| { | { | ||||
| const JackPortType* type = GetPortType(fTypeId); | const JackPortType* type = GetPortType(fTypeId); | ||||
| (type->init)(GetBuffer(), frames * sizeof(float), frames); | |||||
| (type->init)(GetBuffer(), frames * sizeof(jack_default_audio_sample_t), frames); | |||||
| } | } | ||||
| void JackPort::MixBuffers(void** src_buffers, int src_count, jack_nframes_t buffer_size) | void JackPort::MixBuffers(void** src_buffers, int src_count, jack_nframes_t buffer_size) | ||||
| @@ -57,7 +57,7 @@ class SERVER_EXPORT JackPort | |||||
| bool fInUse; | bool fInUse; | ||||
| jack_port_id_t fTied; // Locally tied source port | jack_port_id_t fTied; // Locally tied source port | ||||
| float fBuffer[BUFFER_SIZE_MAX + 4]; | |||||
| jack_default_audio_sample_t fBuffer[BUFFER_SIZE_MAX + 4]; | |||||
| bool IsUsed() const | bool IsUsed() const | ||||
| { | { | ||||
| @@ -105,9 +105,9 @@ class SERVER_EXPORT JackPort | |||||
| } | } | ||||
| // Since we are in shared memory, the resulting pointer cannot be cached, so align it here... | // Since we are in shared memory, the resulting pointer cannot be cached, so align it here... | ||||
| float* GetBuffer() | |||||
| jack_default_audio_sample_t* GetBuffer() | |||||
| { | { | ||||
| return (float*)((long)fBuffer & ~15L) + 4; | |||||
| return (jack_default_audio_sample_t*)((long)fBuffer & ~15L) + 4; | |||||
| } | } | ||||
| int GetRefNum() const; | int GetRefNum() const; | ||||
| @@ -26,8 +26,8 @@ namespace Jack | |||||
| JackResampler::JackResampler() | JackResampler::JackResampler() | ||||
| :fRatio(1),fRingBufferSize(DEFAULT_RB_SIZE) | :fRatio(1),fRingBufferSize(DEFAULT_RB_SIZE) | ||||
| { | { | ||||
| fRingBuffer = jack_ringbuffer_create(sizeof(float) * fRingBufferSize); | |||||
| jack_ringbuffer_read_advance(fRingBuffer, (sizeof(float) * fRingBufferSize) / 2); | |||||
| fRingBuffer = jack_ringbuffer_create(sizeof(jack_default_audio_sample_t) * fRingBufferSize); | |||||
| jack_ringbuffer_read_advance(fRingBuffer, (sizeof(jack_default_audio_sample_t) * fRingBufferSize) / 2); | |||||
| } | } | ||||
| JackResampler::~JackResampler() | JackResampler::~JackResampler() | ||||
| @@ -39,54 +39,54 @@ JackResampler::~JackResampler() | |||||
| void JackResampler::Reset(unsigned int new_size) | void JackResampler::Reset(unsigned int new_size) | ||||
| { | { | ||||
| fRingBufferSize = new_size; | fRingBufferSize = new_size; | ||||
| jack_ringbuffer_reset_size(fRingBuffer, sizeof(float) * fRingBufferSize); | |||||
| jack_ringbuffer_read_advance(fRingBuffer, (sizeof(float) * fRingBufferSize / 2)); | |||||
| jack_ringbuffer_reset_size(fRingBuffer, sizeof(jack_default_audio_sample_t) * fRingBufferSize); | |||||
| jack_ringbuffer_read_advance(fRingBuffer, (sizeof(jack_default_audio_sample_t) * fRingBufferSize / 2)); | |||||
| } | } | ||||
| unsigned int JackResampler::ReadSpace() | unsigned int JackResampler::ReadSpace() | ||||
| { | { | ||||
| return (jack_ringbuffer_read_space(fRingBuffer) / sizeof(float)); | |||||
| return (jack_ringbuffer_read_space(fRingBuffer) / sizeof(jack_default_audio_sample_t)); | |||||
| } | } | ||||
| unsigned int JackResampler::WriteSpace() | unsigned int JackResampler::WriteSpace() | ||||
| { | { | ||||
| return (jack_ringbuffer_write_space(fRingBuffer) / sizeof(float)); | |||||
| return (jack_ringbuffer_write_space(fRingBuffer) / sizeof(jack_default_audio_sample_t)); | |||||
| } | } | ||||
| unsigned int JackResampler::Read(float* buffer, unsigned int frames) | |||||
| unsigned int JackResampler::Read(jack_default_audio_sample_t* buffer, unsigned int frames) | |||||
| { | { | ||||
| size_t len = jack_ringbuffer_read_space(fRingBuffer); | size_t len = jack_ringbuffer_read_space(fRingBuffer); | ||||
| jack_log("JackResampler::Read input available = %ld", len / sizeof(float)); | |||||
| if (len < frames * sizeof(float)) { | |||||
| jack_log("JackResampler::Read input available = %ld", len / sizeof(jack_default_audio_sample_t)); | |||||
| if (len < frames * sizeof(jack_default_audio_sample_t)) { | |||||
| jack_error("JackResampler::Read : producer too slow, missing frames = %d", frames); | jack_error("JackResampler::Read : producer too slow, missing frames = %d", frames); | ||||
| return 0; | return 0; | ||||
| } else { | } else { | ||||
| jack_ringbuffer_read(fRingBuffer, (char*)buffer, frames * sizeof(float)); | |||||
| jack_ringbuffer_read(fRingBuffer, (char*)buffer, frames * sizeof(jack_default_audio_sample_t)); | |||||
| return frames; | return frames; | ||||
| } | } | ||||
| } | } | ||||
| unsigned int JackResampler::Write(float* buffer, unsigned int frames) | |||||
| unsigned int JackResampler::Write(jack_default_audio_sample_t* buffer, unsigned int frames) | |||||
| { | { | ||||
| size_t len = jack_ringbuffer_write_space(fRingBuffer); | size_t len = jack_ringbuffer_write_space(fRingBuffer); | ||||
| jack_log("JackResampler::Write output available = %ld", len / sizeof(float)); | |||||
| if (len < frames * sizeof(float)) { | |||||
| jack_log("JackResampler::Write output available = %ld", len / sizeof(jack_default_audio_sample_t)); | |||||
| if (len < frames * sizeof(jack_default_audio_sample_t)) { | |||||
| jack_error("JackResampler::Write : consumer too slow, skip frames = %d", frames); | jack_error("JackResampler::Write : consumer too slow, skip frames = %d", frames); | ||||
| return 0; | return 0; | ||||
| } else { | } else { | ||||
| jack_ringbuffer_write(fRingBuffer, (char*)buffer, frames * sizeof(float)); | |||||
| jack_ringbuffer_write(fRingBuffer, (char*)buffer, frames * sizeof(jack_default_audio_sample_t)); | |||||
| return frames; | return frames; | ||||
| } | } | ||||
| } | } | ||||
| unsigned int JackResampler::ReadResample(float* buffer, unsigned int frames) | |||||
| unsigned int JackResampler::ReadResample(jack_default_audio_sample_t* buffer, unsigned int frames) | |||||
| { | { | ||||
| return Read(buffer, frames); | return Read(buffer, frames); | ||||
| } | } | ||||
| unsigned int JackResampler::WriteResample(float* buffer, unsigned int frames) | |||||
| unsigned int JackResampler::WriteResample(jack_default_audio_sample_t* buffer, unsigned int frames) | |||||
| { | { | ||||
| return Write(buffer, frames); | return Write(buffer, frames); | ||||
| } | } | ||||
| @@ -21,19 +21,20 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| #define __JackResampler__ | #define __JackResampler__ | ||||
| #include "ringbuffer.h" | #include "ringbuffer.h" | ||||
| #include "types.h" | |||||
| #include "JackError.h" | #include "JackError.h" | ||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| #define DEFAULT_RB_SIZE 32768 | #define DEFAULT_RB_SIZE 32768 | ||||
| #define DEFAULT_ADAPTATIVE_SIZE 2048 | |||||
| #define DEFAULT_ADAPTATIVE_SIZE 2048 | |||||
| inline float Range(float min, float max, float val) | inline float Range(float min, float max, float val) | ||||
| { | { | ||||
| return (val < min) ? min : ((val > max) ? max : val); | return (val < min) ? min : ((val > max) ? max : val); | ||||
| } | } | ||||
| /*! | /*! | ||||
| \brief Base class for Resampler. | \brief Base class for Resampler. | ||||
| */ | */ | ||||
| @@ -42,27 +43,27 @@ class JackResampler | |||||
| { | { | ||||
| protected: | protected: | ||||
| jack_ringbuffer_t* fRingBuffer; | jack_ringbuffer_t* fRingBuffer; | ||||
| double fRatio; | double fRatio; | ||||
| unsigned int fRingBufferSize; | unsigned int fRingBufferSize; | ||||
| public: | public: | ||||
| JackResampler(); | JackResampler(); | ||||
| virtual ~JackResampler(); | virtual ~JackResampler(); | ||||
| virtual void Reset(unsigned int new_size); | virtual void Reset(unsigned int new_size); | ||||
| virtual unsigned int ReadResample(float* buffer, unsigned int frames); | |||||
| virtual unsigned int WriteResample(float* buffer, unsigned int frames); | |||||
| virtual unsigned int Read(float* buffer, unsigned int frames); | |||||
| virtual unsigned int Write(float* buffer, unsigned int frames); | |||||
| virtual unsigned int ReadResample(jack_default_audio_sample_t* buffer, unsigned int frames); | |||||
| virtual unsigned int WriteResample(jack_default_audio_sample_t* buffer, unsigned int frames); | |||||
| virtual unsigned int Read(jack_default_audio_sample_t* buffer, unsigned int frames); | |||||
| virtual unsigned int Write(jack_default_audio_sample_t* buffer, unsigned int frames); | |||||
| virtual unsigned int ReadSpace(); | virtual unsigned int ReadSpace(); | ||||
| virtual unsigned int WriteSpace(); | virtual unsigned int WriteSpace(); | ||||
| unsigned int GetError() | unsigned int GetError() | ||||
| { | { | ||||
| return (jack_ringbuffer_read_space(fRingBuffer) / sizeof(float)) - (fRingBufferSize / 2); | return (jack_ringbuffer_read_space(fRingBuffer) / sizeof(float)) - (fRingBufferSize / 2); | ||||
| @@ -72,12 +73,12 @@ class JackResampler | |||||
| { | { | ||||
| fRatio = Range(0.25, 4.0, ratio); | fRatio = Range(0.25, 4.0, ratio); | ||||
| } | } | ||||
| double GetRatio() | double GetRatio() | ||||
| { | { | ||||
| return fRatio; | return fRatio; | ||||
| } | } | ||||
| }; | }; | ||||
| } | } | ||||
| @@ -545,18 +545,18 @@ void netjack_detach( netjack_driver_state_t *netj ) | |||||
| netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj, | netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj, | ||||
| jack_client_t * client, | jack_client_t * client, | ||||
| const char *name, | |||||
| unsigned int capture_ports, | |||||
| unsigned int playback_ports, | |||||
| unsigned int capture_ports_midi, | |||||
| unsigned int playback_ports_midi, | |||||
| jack_nframes_t sample_rate, | |||||
| jack_nframes_t period_size, | |||||
| unsigned int listen_port, | |||||
| unsigned int transport_sync, | |||||
| unsigned int resample_factor, | |||||
| unsigned int resample_factor_up, | |||||
| unsigned int bitdepth, | |||||
| const char *name, | |||||
| unsigned int capture_ports, | |||||
| unsigned int playback_ports, | |||||
| unsigned int capture_ports_midi, | |||||
| unsigned int playback_ports_midi, | |||||
| jack_nframes_t sample_rate, | |||||
| jack_nframes_t period_size, | |||||
| unsigned int listen_port, | |||||
| unsigned int transport_sync, | |||||
| unsigned int resample_factor, | |||||
| unsigned int resample_factor_up, | |||||
| unsigned int bitdepth, | |||||
| unsigned int use_autoconfig, | unsigned int use_autoconfig, | ||||
| unsigned int latency, | unsigned int latency, | ||||
| unsigned int redundancy, | unsigned int redundancy, | ||||
| @@ -663,74 +663,74 @@ netjack_startup( netjack_driver_state_t *netj ) | |||||
| netj->srcaddress_valid = 0; | netj->srcaddress_valid = 0; | ||||
| if (netj->use_autoconfig) | if (netj->use_autoconfig) | ||||
| { | { | ||||
| jacknet_packet_header *first_packet = alloca (sizeof (jacknet_packet_header)); | |||||
| #ifdef WIN32 | |||||
| int address_size = sizeof( struct sockaddr_in ); | |||||
| #else | |||||
| socklen_t address_size = sizeof (struct sockaddr_in); | |||||
| #endif | |||||
| //jack_info ("Waiting for an incoming packet !!!"); | |||||
| //jack_info ("*** IMPORTANT *** Dont connect a client to jackd until the driver is attached to a clock source !!!"); | |||||
| while(1) { | |||||
| if( ! netjack_poll( netj->sockfd, 1000 ) ) { | |||||
| jack_info ("Waiting aborted"); | |||||
| return -1; | |||||
| } | |||||
| first_pack_len = recvfrom (netj->sockfd, (char *)first_packet, sizeof (jacknet_packet_header), 0, (struct sockaddr*) & netj->syncsource_address, &address_size); | |||||
| #ifdef WIN32 | |||||
| if( first_pack_len == -1 ) { | |||||
| first_pack_len = sizeof(jacknet_packet_header); | |||||
| break; | |||||
| jacknet_packet_header *first_packet = alloca (sizeof (jacknet_packet_header)); | |||||
| #ifdef WIN32 | |||||
| int address_size = sizeof( struct sockaddr_in ); | |||||
| #else | |||||
| socklen_t address_size = sizeof (struct sockaddr_in); | |||||
| #endif | |||||
| //jack_info ("Waiting for an incoming packet !!!"); | |||||
| //jack_info ("*** IMPORTANT *** Dont connect a client to jackd until the driver is attached to a clock source !!!"); | |||||
| while(1) { | |||||
| if( ! netjack_poll( netj->sockfd, 1000 ) ) { | |||||
| jack_info ("Waiting aborted"); | |||||
| return -1; | |||||
| } | |||||
| first_pack_len = recvfrom (netj->sockfd, (char *)first_packet, sizeof (jacknet_packet_header), 0, (struct sockaddr*) & netj->syncsource_address, &address_size); | |||||
| #ifdef WIN32 | |||||
| if( first_pack_len == -1 ) { | |||||
| first_pack_len = sizeof(jacknet_packet_header); | |||||
| break; | |||||
| } | |||||
| #else | |||||
| if (first_pack_len == sizeof (jacknet_packet_header)) | |||||
| break; | |||||
| #endif | |||||
| } | } | ||||
| #else | |||||
| if (first_pack_len == sizeof (jacknet_packet_header)) | |||||
| break; | |||||
| #endif | |||||
| } | |||||
| netj->srcaddress_valid = 1; | |||||
| netj->srcaddress_valid = 1; | |||||
| if (first_pack_len == sizeof (jacknet_packet_header)) | |||||
| { | |||||
| packet_header_ntoh (first_packet); | |||||
| jack_info ("AutoConfig Override !!!"); | |||||
| if (netj->sample_rate != first_packet->sample_rate) | |||||
| { | |||||
| jack_info ("AutoConfig Override: Master JACK sample rate = %d", first_packet->sample_rate); | |||||
| netj->sample_rate = first_packet->sample_rate; | |||||
| } | |||||
| if (netj->period_size != first_packet->period_size) | |||||
| { | |||||
| jack_info ("AutoConfig Override: Master JACK period size is %d", first_packet->period_size); | |||||
| netj->period_size = first_packet->period_size; | |||||
| } | |||||
| if (netj->capture_channels_audio != first_packet->capture_channels_audio) | |||||
| { | |||||
| jack_info ("AutoConfig Override: capture_channels_audio = %d", first_packet->capture_channels_audio); | |||||
| netj->capture_channels_audio = first_packet->capture_channels_audio; | |||||
| } | |||||
| if (netj->capture_channels_midi != first_packet->capture_channels_midi) | |||||
| { | |||||
| jack_info ("AutoConfig Override: capture_channels_midi = %d", first_packet->capture_channels_midi); | |||||
| netj->capture_channels_midi = first_packet->capture_channels_midi; | |||||
| } | |||||
| if (netj->playback_channels_audio != first_packet->playback_channels_audio) | |||||
| { | |||||
| jack_info ("AutoConfig Override: playback_channels_audio = %d", first_packet->playback_channels_audio); | |||||
| netj->playback_channels_audio = first_packet->playback_channels_audio; | |||||
| } | |||||
| if (netj->playback_channels_midi != first_packet->playback_channels_midi) | |||||
| { | |||||
| jack_info ("AutoConfig Override: playback_channels_midi = %d", first_packet->playback_channels_midi); | |||||
| netj->playback_channels_midi = first_packet->playback_channels_midi; | |||||
| } | |||||
| netj->mtu = first_packet->mtu; | |||||
| jack_info ("MTU is set to %d bytes", first_packet->mtu); | |||||
| netj->latency = first_packet->latency; | |||||
| } | |||||
| if (first_pack_len == sizeof (jacknet_packet_header)) | |||||
| { | |||||
| packet_header_ntoh (first_packet); | |||||
| jack_info ("AutoConfig Override !!!"); | |||||
| if (netj->sample_rate != first_packet->sample_rate) | |||||
| { | |||||
| jack_info ("AutoConfig Override: Master JACK sample rate = %d", first_packet->sample_rate); | |||||
| netj->sample_rate = first_packet->sample_rate; | |||||
| } | |||||
| if (netj->period_size != first_packet->period_size) | |||||
| { | |||||
| jack_info ("AutoConfig Override: Master JACK period size is %d", first_packet->period_size); | |||||
| netj->period_size = first_packet->period_size; | |||||
| } | |||||
| if (netj->capture_channels_audio != first_packet->capture_channels_audio) | |||||
| { | |||||
| jack_info ("AutoConfig Override: capture_channels_audio = %d", first_packet->capture_channels_audio); | |||||
| netj->capture_channels_audio = first_packet->capture_channels_audio; | |||||
| } | |||||
| if (netj->capture_channels_midi != first_packet->capture_channels_midi) | |||||
| { | |||||
| jack_info ("AutoConfig Override: capture_channels_midi = %d", first_packet->capture_channels_midi); | |||||
| netj->capture_channels_midi = first_packet->capture_channels_midi; | |||||
| } | |||||
| if (netj->playback_channels_audio != first_packet->playback_channels_audio) | |||||
| { | |||||
| jack_info ("AutoConfig Override: playback_channels_audio = %d", first_packet->playback_channels_audio); | |||||
| netj->playback_channels_audio = first_packet->playback_channels_audio; | |||||
| } | |||||
| if (netj->playback_channels_midi != first_packet->playback_channels_midi) | |||||
| { | |||||
| jack_info ("AutoConfig Override: playback_channels_midi = %d", first_packet->playback_channels_midi); | |||||
| netj->playback_channels_midi = first_packet->playback_channels_midi; | |||||
| } | |||||
| netj->mtu = first_packet->mtu; | |||||
| jack_info ("MTU is set to %d bytes", first_packet->mtu); | |||||
| netj->latency = first_packet->latency; | |||||
| } | |||||
| } | } | ||||
| netj->capture_channels = netj->capture_channels_audio + netj->capture_channels_midi; | netj->capture_channels = netj->capture_channels_audio + netj->capture_channels_midi; | ||||
| netj->playback_channels = netj->playback_channels_audio + netj->playback_channels_midi; | netj->playback_channels = netj->playback_channels_audio + netj->playback_channels_midi; | ||||
| @@ -762,21 +762,21 @@ netjack_startup( netjack_driver_state_t *netj ) | |||||
| * 1000000.0f); | * 1000000.0f); | ||||
| if( netj->latency == 0 ) | if( netj->latency == 0 ) | ||||
| netj->deadline_offset = 50*netj->period_usecs; | |||||
| netj->deadline_offset = 50*netj->period_usecs; | |||||
| else | else | ||||
| netj->deadline_offset = netj->period_usecs + 10*netj->latency*netj->period_usecs/100; | |||||
| netj->deadline_offset = netj->period_usecs + 10*netj->latency*netj->period_usecs/100; | |||||
| if( netj->bitdepth == CELT_MODE ) { | if( netj->bitdepth == CELT_MODE ) { | ||||
| // celt mode. | |||||
| // TODO: this is a hack. But i dont want to change the packet header. | |||||
| netj->resample_factor = (netj->resample_factor * netj->period_size * 1024 / netj->sample_rate / 8)&(~1); | |||||
| netj->resample_factor_up = (netj->resample_factor_up * netj->period_size * 1024 / netj->sample_rate / 8)&(~1); | |||||
| // celt mode. | |||||
| // TODO: this is a hack. But i dont want to change the packet header. | |||||
| netj->resample_factor = (netj->resample_factor * netj->period_size * 1024 / netj->sample_rate / 8)&(~1); | |||||
| netj->resample_factor_up = (netj->resample_factor_up * netj->period_size * 1024 / netj->sample_rate / 8)&(~1); | |||||
| netj->net_period_down = netj->resample_factor; | |||||
| netj->net_period_up = netj->resample_factor_up; | |||||
| netj->net_period_down = netj->resample_factor; | |||||
| netj->net_period_up = netj->resample_factor_up; | |||||
| } else { | } else { | ||||
| netj->net_period_down = (float) netj->period_size / (float) netj->resample_factor; | |||||
| netj->net_period_up = (float) netj->period_size / (float) netj->resample_factor_up; | |||||
| netj->net_period_down = (float) netj->period_size / (float) netj->resample_factor; | |||||
| netj->net_period_up = (float) netj->period_size / (float) netj->resample_factor_up; | |||||
| } | } | ||||
| netj->rx_bufsize = sizeof (jacknet_packet_header) + netj->net_period_down * netj->capture_channels * get_sample_size (netj->bitdepth); | netj->rx_bufsize = sizeof (jacknet_packet_header) + netj->net_period_down * netj->capture_channels * get_sample_size (netj->bitdepth); | ||||
| @@ -790,9 +790,9 @@ netjack_startup( netjack_driver_state_t *netj ) | |||||
| // Special handling for latency=0 | // Special handling for latency=0 | ||||
| if( netj->latency == 0 ) | if( netj->latency == 0 ) | ||||
| netj->resync_threshold = 0; | |||||
| netj->resync_threshold = 0; | |||||
| else | else | ||||
| netj->resync_threshold = MIN( 15, netj->latency-1 ); | |||||
| netj->resync_threshold = MIN( 15, netj->latency-1 ); | |||||
| netj->running_free = 0; | netj->running_free = 0; | ||||
| @@ -127,19 +127,19 @@ void netjack_detach( netjack_driver_state_t *netj ); | |||||
| netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj, | netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj, | ||||
| jack_client_t * client, | jack_client_t * client, | ||||
| const char *name, | |||||
| unsigned int capture_ports, | |||||
| unsigned int playback_ports, | |||||
| unsigned int capture_ports_midi, | |||||
| unsigned int playback_ports_midi, | |||||
| jack_nframes_t sample_rate, | |||||
| jack_nframes_t period_size, | |||||
| unsigned int listen_port, | |||||
| unsigned int transport_sync, | |||||
| unsigned int resample_factor, | |||||
| unsigned int resample_factor_up, | |||||
| unsigned int bitdepth, | |||||
| unsigned int use_autoconfig, | |||||
| const char *name, | |||||
| unsigned int capture_ports, | |||||
| unsigned int playback_ports, | |||||
| unsigned int capture_ports_midi, | |||||
| unsigned int playback_ports_midi, | |||||
| jack_nframes_t sample_rate, | |||||
| jack_nframes_t period_size, | |||||
| unsigned int listen_port, | |||||
| unsigned int transport_sync, | |||||
| unsigned int resample_factor, | |||||
| unsigned int resample_factor_up, | |||||
| unsigned int bitdepth, | |||||
| unsigned int use_autoconfig, | |||||
| unsigned int latency, | unsigned int latency, | ||||
| unsigned int redundancy, | unsigned int redundancy, | ||||
| int dont_htonl_floats, | int dont_htonl_floats, | ||||
| @@ -145,8 +145,8 @@ namespace Jack | |||||
| void* fOutputCardChannels[256]; | void* fOutputCardChannels[256]; | ||||
| //non-interleaved mod, floating point software buffers | //non-interleaved mod, floating point software buffers | ||||
| float* fInputSoftChannels[256]; | |||||
| float* fOutputSoftChannels[256]; | |||||
| jack_default_audio_sample_t* fInputSoftChannels[256]; | |||||
| jack_default_audio_sample_t* fOutputSoftChannels[256]; | |||||
| //public methods --------------------------------------------------------- | //public methods --------------------------------------------------------- | ||||
| @@ -165,12 +165,12 @@ namespace Jack | |||||
| return fBuffering; | return fBuffering; | ||||
| } | } | ||||
| float** inputSoftChannels() | |||||
| jack_default_audio_sample_t** inputSoftChannels() | |||||
| { | { | ||||
| return fInputSoftChannels; | return fInputSoftChannels; | ||||
| } | } | ||||
| float** outputSoftChannels() | |||||
| jack_default_audio_sample_t** outputSoftChannels() | |||||
| { | { | ||||
| return fOutputSoftChannels; | return fOutputSoftChannels; | ||||
| } | } | ||||
| @@ -182,10 +182,10 @@ namespace Jack | |||||
| fInputParams = 0; | fInputParams = 0; | ||||
| fOutputParams = 0; | fOutputParams = 0; | ||||
| fPeriod = 2; | fPeriod = 2; | ||||
| fInputCardBuffer = 0; | fInputCardBuffer = 0; | ||||
| fOutputCardBuffer = 0; | fOutputCardBuffer = 0; | ||||
| for ( int i = 0; i < 256; i++ ) | for ( int i = 0; i < 256; i++ ) | ||||
| { | { | ||||
| fInputCardChannels[i] = 0; | fInputCardChannels[i] = 0; | ||||
| @@ -222,18 +222,18 @@ namespace Jack | |||||
| //get hardware input parameters | //get hardware input parameters | ||||
| check_error ( snd_pcm_hw_params_malloc ( &fInputParams ) ); | check_error ( snd_pcm_hw_params_malloc ( &fInputParams ) ); | ||||
| setAudioParams ( fInputDevice, fInputParams ); | setAudioParams ( fInputDevice, fInputParams ); | ||||
| //get hardware output parameters | //get hardware output parameters | ||||
| check_error ( snd_pcm_hw_params_malloc ( &fOutputParams ) ) | check_error ( snd_pcm_hw_params_malloc ( &fOutputParams ) ) | ||||
| setAudioParams ( fOutputDevice, fOutputParams ); | setAudioParams ( fOutputDevice, fOutputParams ); | ||||
| // set the number of physical input and output channels close to what we need | // set the number of physical input and output channels close to what we need | ||||
| fCardInputs = fSoftInputs; | fCardInputs = fSoftInputs; | ||||
| fCardOutputs = fSoftOutputs; | fCardOutputs = fSoftOutputs; | ||||
| snd_pcm_hw_params_set_channels_near(fInputDevice, fInputParams, &fCardInputs); | snd_pcm_hw_params_set_channels_near(fInputDevice, fInputParams, &fCardInputs); | ||||
| snd_pcm_hw_params_set_channels_near(fOutputDevice, fOutputParams, &fCardOutputs); | snd_pcm_hw_params_set_channels_near(fOutputDevice, fOutputParams, &fCardOutputs); | ||||
| //set input/output param | //set input/output param | ||||
| check_error ( snd_pcm_hw_params ( fInputDevice, fInputParams ) ); | check_error ( snd_pcm_hw_params ( fInputDevice, fInputParams ) ); | ||||
| check_error ( snd_pcm_hw_params ( fOutputDevice, fOutputParams ) ); | check_error ( snd_pcm_hw_params ( fOutputDevice, fOutputParams ) ); | ||||
| @@ -260,14 +260,14 @@ namespace Jack | |||||
| for ( unsigned int i = 0; i < fSoftInputs; i++ ) | for ( unsigned int i = 0; i < fSoftInputs; i++ ) | ||||
| { | { | ||||
| fInputSoftChannels[i] = ( float* ) aligned_calloc ( fBuffering, sizeof ( float ) ); | |||||
| fInputSoftChannels[i] = ( jack_default_audio_sample_t* ) aligned_calloc ( fBuffering, sizeof ( jack_default_audio_sample_t ) ); | |||||
| for ( int j = 0; j < fBuffering; j++ ) | for ( int j = 0; j < fBuffering; j++ ) | ||||
| fInputSoftChannels[i][j] = 0.0; | fInputSoftChannels[i][j] = 0.0; | ||||
| } | } | ||||
| for ( unsigned int i = 0; i < fSoftOutputs; i++ ) | for ( unsigned int i = 0; i < fSoftOutputs; i++ ) | ||||
| { | { | ||||
| fOutputSoftChannels[i] = ( float* ) aligned_calloc ( fBuffering, sizeof ( float ) ); | |||||
| fOutputSoftChannels[i] = ( jack_default_audio_sample_t* ) aligned_calloc ( fBuffering, sizeof ( jack_default_audio_sample_t ) ); | |||||
| for ( int j = 0; j < fBuffering; j++ ) | for ( int j = 0; j < fBuffering; j++ ) | ||||
| fOutputSoftChannels[i][j] = 0.0; | fOutputSoftChannels[i][j] = 0.0; | ||||
| } | } | ||||
| @@ -376,14 +376,14 @@ namespace Jack | |||||
| short* buffer16b = ( short* ) fInputCardBuffer; | short* buffer16b = ( short* ) fInputCardBuffer; | ||||
| for ( s = 0; s < fBuffering; s++ ) | for ( s = 0; s < fBuffering; s++ ) | ||||
| for ( c = 0; c < fCardInputs; c++ ) | for ( c = 0; c < fCardInputs; c++ ) | ||||
| fInputSoftChannels[c][s] = float ( buffer16b[c + s*fCardInputs] ) * ( 1.0/float ( SHRT_MAX ) ); | |||||
| fInputSoftChannels[c][s] = jack_default_audio_sample_t ( buffer16b[c + s*fCardInputs] ) * ( (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(SHRT_MAX)); | |||||
| } | } | ||||
| else // SND_PCM_FORMAT_S32 | else // SND_PCM_FORMAT_S32 | ||||
| { | { | ||||
| int32_t* buffer32b = ( int32_t* ) fInputCardBuffer; | int32_t* buffer32b = ( int32_t* ) fInputCardBuffer; | ||||
| for ( s = 0; s < fBuffering; s++ ) | for ( s = 0; s < fBuffering; s++ ) | ||||
| for ( c = 0; c < fCardInputs; c++ ) | for ( c = 0; c < fCardInputs; c++ ) | ||||
| fInputSoftChannels[c][s] = float ( buffer32b[c + s*fCardInputs] ) * ( 1.0/float ( INT_MAX ) ); | |||||
| fInputSoftChannels[c][s] = jack_default_audio_sample_t ( buffer32b[c + s*fCardInputs] ) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(INT_MAX)); | |||||
| } | } | ||||
| break; | break; | ||||
| case SND_PCM_ACCESS_RW_NONINTERLEAVED : | case SND_PCM_ACCESS_RW_NONINTERLEAVED : | ||||
| @@ -400,7 +400,7 @@ namespace Jack | |||||
| { | { | ||||
| chan16b = ( short* ) fInputCardChannels[c]; | chan16b = ( short* ) fInputCardChannels[c]; | ||||
| for ( s = 0; s < fBuffering; s++ ) | for ( s = 0; s < fBuffering; s++ ) | ||||
| fInputSoftChannels[c][s] = float ( chan16b[s] ) * ( 1.0/float ( SHRT_MAX ) ); | |||||
| fInputSoftChannels[c][s] = jack_default_audio_sample_t(chan16b[s]) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(SHRT_MAX)); | |||||
| } | } | ||||
| } | } | ||||
| else // SND_PCM_FORMAT_S32 | else // SND_PCM_FORMAT_S32 | ||||
| @@ -410,7 +410,7 @@ namespace Jack | |||||
| { | { | ||||
| chan32b = ( int32_t* ) fInputCardChannels[c]; | chan32b = ( int32_t* ) fInputCardChannels[c]; | ||||
| for ( s = 0; s < fBuffering; s++ ) | for ( s = 0; s < fBuffering; s++ ) | ||||
| fInputSoftChannels[c][s] = float ( chan32b[s] ) * ( 1.0/float ( INT_MAX ) ); | |||||
| fInputSoftChannels[c][s] = jack_default_audio_sample_t(chan32b[s]) * (jack_default_audio_sample_t(1.0)/jack_default_audio_sample_t(INT_MAX)); | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -440,8 +440,8 @@ namespace Jack | |||||
| { | { | ||||
| for ( unsigned int c = 0; c < fCardOutputs; c++ ) | for ( unsigned int c = 0; c < fCardOutputs; c++ ) | ||||
| { | { | ||||
| float x = fOutputSoftChannels[c][f]; | |||||
| buffer16b[c + f * fCardOutputs] = short ( max ( min ( x, 1.0 ), -1.0 ) * float ( SHRT_MAX ) ); | |||||
| jack_default_audio_sample_t x = fOutputSoftChannels[c][f]; | |||||
| buffer16b[c + f * fCardOutputs] = short(max(min (x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(SHRT_MAX)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -452,8 +452,8 @@ namespace Jack | |||||
| { | { | ||||
| for ( unsigned int c = 0; c < fCardOutputs; c++ ) | for ( unsigned int c = 0; c < fCardOutputs; c++ ) | ||||
| { | { | ||||
| float x = fOutputSoftChannels[c][f]; | |||||
| buffer32b[c + f * fCardOutputs] = int32_t ( max ( min ( x, 1.0 ), -1.0 ) * float ( INT_MAX ) ); | |||||
| jack_default_audio_sample_t x = fOutputSoftChannels[c][f]; | |||||
| buffer32b[c + f * fCardOutputs] = int32_t(max(min(x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(INT_MAX)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -474,8 +474,8 @@ namespace Jack | |||||
| short* chan16b = ( short* ) fOutputCardChannels[c]; | short* chan16b = ( short* ) fOutputCardChannels[c]; | ||||
| for ( f = 0; f < fBuffering; f++ ) | for ( f = 0; f < fBuffering; f++ ) | ||||
| { | { | ||||
| float x = fOutputSoftChannels[c][f]; | |||||
| chan16b[f] = short ( max ( min ( x,1.0 ), -1.0 ) * float ( SHRT_MAX ) ) ; | |||||
| jack_default_audio_sample_t x = fOutputSoftChannels[c][f]; | |||||
| chan16b[f] = short(max(min (x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(SHRT_MAX)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -486,8 +486,8 @@ namespace Jack | |||||
| int32_t* chan32b = ( int32_t* ) fOutputCardChannels[c]; | int32_t* chan32b = ( int32_t* ) fOutputCardChannels[c]; | ||||
| for ( f = 0; f < fBuffering; f++ ) | for ( f = 0; f < fBuffering; f++ ) | ||||
| { | { | ||||
| float x = fOutputSoftChannels[c][f]; | |||||
| chan32b[f] = int32_t ( max ( min ( x,1.0 ),-1.0 ) * float ( INT_MAX ) ) ; | |||||
| jack_default_audio_sample_t x = fOutputSoftChannels[c][f]; | |||||
| chan32b[f] = int32_t(max(min(x, jack_default_audio_sample_t(1.0)), jack_default_audio_sample_t(-1.0)) * jack_default_audio_sample_t(INT_MAX)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -276,17 +276,17 @@ OSStatus JackCoreAudioAdapter::Render(void *inRefCon, | |||||
| JackCoreAudioAdapter* adapter = static_cast<JackCoreAudioAdapter*>(inRefCon); | JackCoreAudioAdapter* adapter = static_cast<JackCoreAudioAdapter*>(inRefCon); | ||||
| AudioUnitRender(adapter->fAUHAL, ioActionFlags, inTimeStamp, 1, inNumberFrames, adapter->fInputData); | AudioUnitRender(adapter->fAUHAL, ioActionFlags, inTimeStamp, 1, inNumberFrames, adapter->fInputData); | ||||
| float* inputBuffer[adapter->fCaptureChannels]; | |||||
| float* outputBuffer[adapter->fPlaybackChannels]; | |||||
| jack_default_audio_sample_t* inputBuffer[adapter->fCaptureChannels]; | |||||
| jack_default_audio_sample_t* outputBuffer[adapter->fPlaybackChannels]; | |||||
| for (int i = 0; i < adapter->fCaptureChannels; i++) { | for (int i = 0; i < adapter->fCaptureChannels; i++) { | ||||
| inputBuffer[i] = (float*)adapter->fInputData->mBuffers[i].mData; | |||||
| inputBuffer[i] = (jack_default_audio_sample_t*)adapter->fInputData->mBuffers[i].mData; | |||||
| } | } | ||||
| for (int i = 0; i < adapter->fPlaybackChannels; i++) { | for (int i = 0; i < adapter->fPlaybackChannels; i++) { | ||||
| outputBuffer[i] = (float*)ioData->mBuffers[i].mData; | |||||
| outputBuffer[i] = (jack_default_audio_sample_t*)ioData->mBuffers[i].mData; | |||||
| } | } | ||||
| adapter->PushAndPull((float**)inputBuffer, (float**)outputBuffer, inNumberFrames); | |||||
| adapter->PushAndPull((jack_default_audio_sample_t**)inputBuffer, (jack_default_audio_sample_t**)outputBuffer, inNumberFrames); | |||||
| return noErr; | return noErr; | ||||
| } | } | ||||
| @@ -769,8 +769,8 @@ int JackCoreAudioAdapter::SetupBuffers(int inchannels) | |||||
| fInputData->mNumberBuffers = inchannels; | fInputData->mNumberBuffers = inchannels; | ||||
| for (int i = 0; i < fCaptureChannels; i++) { | for (int i = 0; i < fCaptureChannels; i++) { | ||||
| fInputData->mBuffers[i].mNumberChannels = 1; | fInputData->mBuffers[i].mNumberChannels = 1; | ||||
| fInputData->mBuffers[i].mDataByteSize = fAdaptedBufferSize * sizeof(float); | |||||
| fInputData->mBuffers[i].mData = malloc(fAdaptedBufferSize * sizeof(float)); | |||||
| fInputData->mBuffers[i].mDataByteSize = fAdaptedBufferSize * sizeof(jack_default_audio_sample_t); | |||||
| fInputData->mBuffers[i].mData = malloc(fAdaptedBufferSize * sizeof(jack_default_audio_sample_t)); | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -942,9 +942,9 @@ int JackCoreAudioAdapter::OpenAUHAL(bool capturing, | |||||
| srcFormat.mSampleRate = samplerate; | srcFormat.mSampleRate = samplerate; | ||||
| srcFormat.mFormatID = kAudioFormatLinearPCM; | srcFormat.mFormatID = kAudioFormatLinearPCM; | ||||
| srcFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | srcFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | ||||
| srcFormat.mBytesPerPacket = sizeof(float); | |||||
| srcFormat.mBytesPerPacket = sizeof(jack_default_audio_sample_t); | |||||
| srcFormat.mFramesPerPacket = 1; | srcFormat.mFramesPerPacket = 1; | ||||
| srcFormat.mBytesPerFrame = sizeof(float); | |||||
| srcFormat.mBytesPerFrame = sizeof(jack_default_audio_sample_t); | |||||
| srcFormat.mChannelsPerFrame = inchannels; | srcFormat.mChannelsPerFrame = inchannels; | ||||
| srcFormat.mBitsPerChannel = 32; | srcFormat.mBitsPerChannel = 32; | ||||
| PrintStreamDesc(&srcFormat); | PrintStreamDesc(&srcFormat); | ||||
| @@ -973,9 +973,9 @@ int JackCoreAudioAdapter::OpenAUHAL(bool capturing, | |||||
| dstFormat.mSampleRate = samplerate; | dstFormat.mSampleRate = samplerate; | ||||
| dstFormat.mFormatID = kAudioFormatLinearPCM; | dstFormat.mFormatID = kAudioFormatLinearPCM; | ||||
| dstFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | dstFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | ||||
| dstFormat.mBytesPerPacket = sizeof(float); | |||||
| dstFormat.mBytesPerPacket = sizeof(jack_default_audio_sample_t); | |||||
| dstFormat.mFramesPerPacket = 1; | dstFormat.mFramesPerPacket = 1; | ||||
| dstFormat.mBytesPerFrame = sizeof(float); | |||||
| dstFormat.mBytesPerFrame = sizeof(jack_default_audio_sample_t); | |||||
| dstFormat.mChannelsPerFrame = outchannels; | dstFormat.mChannelsPerFrame = outchannels; | ||||
| dstFormat.mBitsPerChannel = 32; | dstFormat.mBitsPerChannel = 32; | ||||
| PrintStreamDesc(&dstFormat); | PrintStreamDesc(&dstFormat); | ||||
| @@ -224,14 +224,14 @@ int JackCoreAudioDriver::Write() | |||||
| { | { | ||||
| for (int i = 0; i < fPlaybackChannels; i++) { | for (int i = 0; i < fPlaybackChannels; i++) { | ||||
| if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) { | if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) { | ||||
| float* buffer = GetOutputBuffer(i); | |||||
| int size = sizeof(float) * fEngineControl->fBufferSize; | |||||
| memcpy((float*)fDriverOutputData->mBuffers[i].mData, buffer, size); | |||||
| jack_default_audio_sample_t* buffer = GetOutputBuffer(i); | |||||
| int size = sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize; | |||||
| memcpy((jack_default_audio_sample_t*)fDriverOutputData->mBuffers[i].mData, buffer, size); | |||||
| // Monitor ports | // Monitor ports | ||||
| if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[i]) > 0) | if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[i]) > 0) | ||||
| memcpy(GetMonitorBuffer(i), buffer, size); | memcpy(GetMonitorBuffer(i), buffer, size); | ||||
| } else { | } else { | ||||
| memset((float*)fDriverOutputData->mBuffers[i].mData, 0, sizeof(float) * fEngineControl->fBufferSize); | |||||
| memset((jack_default_audio_sample_t*)fDriverOutputData->mBuffers[i].mData, 0, sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); | |||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| @@ -1294,9 +1294,9 @@ int JackCoreAudioDriver::OpenAUHAL(bool capturing, | |||||
| srcFormat.mSampleRate = samplerate; | srcFormat.mSampleRate = samplerate; | ||||
| srcFormat.mFormatID = kAudioFormatLinearPCM; | srcFormat.mFormatID = kAudioFormatLinearPCM; | ||||
| srcFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | srcFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | ||||
| srcFormat.mBytesPerPacket = sizeof(float); | |||||
| srcFormat.mBytesPerPacket = sizeof(jack_default_audio_sample_t); | |||||
| srcFormat.mFramesPerPacket = 1; | srcFormat.mFramesPerPacket = 1; | ||||
| srcFormat.mBytesPerFrame = sizeof(float); | |||||
| srcFormat.mBytesPerFrame = sizeof(jack_default_audio_sample_t); | |||||
| srcFormat.mChannelsPerFrame = inchannels; | srcFormat.mChannelsPerFrame = inchannels; | ||||
| srcFormat.mBitsPerChannel = 32; | srcFormat.mBitsPerChannel = 32; | ||||
| PrintStreamDesc(&srcFormat); | PrintStreamDesc(&srcFormat); | ||||
| @@ -1324,9 +1324,9 @@ int JackCoreAudioDriver::OpenAUHAL(bool capturing, | |||||
| dstFormat.mSampleRate = samplerate; | dstFormat.mSampleRate = samplerate; | ||||
| dstFormat.mFormatID = kAudioFormatLinearPCM; | dstFormat.mFormatID = kAudioFormatLinearPCM; | ||||
| dstFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | dstFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved; | ||||
| dstFormat.mBytesPerPacket = sizeof(float); | |||||
| dstFormat.mBytesPerPacket = sizeof(jack_default_audio_sample_t); | |||||
| dstFormat.mFramesPerPacket = 1; | dstFormat.mFramesPerPacket = 1; | ||||
| dstFormat.mBytesPerFrame = sizeof(float); | |||||
| dstFormat.mBytesPerFrame = sizeof(jack_default_audio_sample_t); | |||||
| dstFormat.mChannelsPerFrame = outchannels; | dstFormat.mChannelsPerFrame = outchannels; | ||||
| dstFormat.mBitsPerChannel = 32; | dstFormat.mBitsPerChannel = 32; | ||||
| PrintStreamDesc(&dstFormat); | PrintStreamDesc(&dstFormat); | ||||
| @@ -1376,7 +1376,7 @@ int JackCoreAudioDriver::SetupBuffers(int inchannels) | |||||
| fJackInputData->mNumberBuffers = inchannels; | fJackInputData->mNumberBuffers = inchannels; | ||||
| for (int i = 0; i < inchannels; i++) { | for (int i = 0; i < inchannels; i++) { | ||||
| fJackInputData->mBuffers[i].mNumberChannels = 1; | fJackInputData->mBuffers[i].mNumberChannels = 1; | ||||
| fJackInputData->mBuffers[i].mDataByteSize = fEngineControl->fBufferSize * sizeof(float); | |||||
| fJackInputData->mBuffers[i].mDataByteSize = fEngineControl->fBufferSize * sizeof(jack_default_audio_sample_t); | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -1723,7 +1723,7 @@ int JackCoreAudioDriver::SetBufferSize(jack_nframes_t buffer_size) | |||||
| // Input buffers do no change : prepare them only once | // Input buffers do no change : prepare them only once | ||||
| for (int i = 0; i < fCaptureChannels; i++) { | for (int i = 0; i < fCaptureChannels; i++) { | ||||
| fJackInputData->mBuffers[i].mNumberChannels = 1; | fJackInputData->mBuffers[i].mNumberChannels = 1; | ||||
| fJackInputData->mBuffers[i].mDataByteSize = fEngineControl->fBufferSize * sizeof(float); | |||||
| fJackInputData->mBuffers[i].mDataByteSize = fEngineControl->fBufferSize * sizeof(jack_default_audio_sample_t); | |||||
| fJackInputData->mBuffers[i].mData = GetInputBuffer(i); | fJackInputData->mBuffers[i].mData = GetInputBuffer(i); | ||||
| } | } | ||||
| @@ -41,17 +41,17 @@ class JackCoreMidiDriver : public JackMidiDriver | |||||
| MIDIPortRef fOutputPort; | MIDIPortRef fOutputPort; | ||||
| MIDIEndpointRef* fMidiDestination; | MIDIEndpointRef* fMidiDestination; | ||||
| MIDIEndpointRef* fMidiSource; | MIDIEndpointRef* fMidiSource; | ||||
| char fMIDIBuffer[BUFFER_SIZE_MAX * sizeof(float)]; | |||||
| char fMIDIBuffer[BUFFER_SIZE_MAX * sizeof(jack_default_audio_sample_t)]; | |||||
| int fRealCaptureChannels; | int fRealCaptureChannels; | ||||
| int fRealPlaybackChannels; | int fRealPlaybackChannels; | ||||
| static void ReadProcAux(const MIDIPacketList *pktlist, jack_ringbuffer_t* ringbuffer); | static void ReadProcAux(const MIDIPacketList *pktlist, jack_ringbuffer_t* ringbuffer); | ||||
| static void ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon); | static void ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon); | ||||
| static void ReadVirtualProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon); | static void ReadVirtualProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon); | ||||
| static void NotifyProc(const MIDINotification *message, void *refCon); | static void NotifyProc(const MIDINotification *message, void *refCon); | ||||
| public: | public: | ||||
| JackCoreMidiDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table); | JackCoreMidiDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table); | ||||
| @@ -67,7 +67,7 @@ class JackCoreMidiDriver : public JackMidiDriver | |||||
| jack_nframes_t capture_latency, | jack_nframes_t capture_latency, | ||||
| jack_nframes_t playback_latency); | jack_nframes_t playback_latency); | ||||
| int Close(); | int Close(); | ||||
| int Attach(); | int Attach(); | ||||
| int Read(); | int Read(); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| Copyright (C) 2006 Grame | |||||
| Copyright (C) 2006 Grame | |||||
| This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | ||||
| @@ -58,13 +58,13 @@ static const double twoRaisedTo32Reciprocal = 1. / twoRaisedTo32; | |||||
| using namespace std; | using namespace std; | ||||
| // class id. | |||||
| // class id. | |||||
| // {838FE50A-C1AB-4b77-B9B6-0A40788B53F3} | // {838FE50A-C1AB-4b77-B9B6-0A40788B53F3} | ||||
| CLSID IID_ASIO_DRIVER = { 0x838fe50a, 0xc1ab, 0x4b77, { 0xb9, 0xb6, 0xa, 0x40, 0x78, 0x8b, 0x53, 0xf3 } }; | CLSID IID_ASIO_DRIVER = { 0x838fe50a, 0xc1ab, 0x4b77, { 0xb9, 0xb6, 0xa, 0x40, 0x78, 0x8b, 0x53, 0xf3 } }; | ||||
| CFactoryTemplate g_Templates[1] = { | CFactoryTemplate g_Templates[1] = { | ||||
| {L"ASIOJACK", &IID_ASIO_DRIVER, JackRouter::CreateInstance} | |||||
| {L"ASIOJACK", &IID_ASIO_DRIVER, JackRouter::CreateInstance} | |||||
| }; | }; | ||||
| int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); | int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); | ||||
| @@ -183,7 +183,7 @@ JackRouter::JackRouter() : AsioDriver() | |||||
| char dllName[512]; | char dllName[512]; | ||||
| string confPath; | string confPath; | ||||
| DWORD res = GetModuleFileName(handle, dllName, 512); | DWORD res = GetModuleFileName(handle, dllName, 512); | ||||
| // Compute .ini file path | // Compute .ini file path | ||||
| string fullPath = dllName; | string fullPath = dllName; | ||||
| int lastPos = fullPath.find_last_of(PATH_SEP); | int lastPos = fullPath.find_last_of(PATH_SEP); | ||||
| @@ -223,7 +223,7 @@ static bool GetEXEName(DWORD dwProcessID, char* name) | |||||
| { | { | ||||
| DWORD aProcesses [1024], cbNeeded, cProcesses; | DWORD aProcesses [1024], cbNeeded, cProcesses; | ||||
| unsigned int i; | unsigned int i; | ||||
| // Enumerate all processes | // Enumerate all processes | ||||
| if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) | if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) | ||||
| return false; | return false; | ||||
| @@ -240,33 +240,33 @@ static bool GetEXEName(DWORD dwProcessID, char* name) | |||||
| // Get a handle to the process | // Get a handle to the process | ||||
| HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | | HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | | ||||
| PROCESS_VM_READ, FALSE, dwProcessID); | PROCESS_VM_READ, FALSE, dwProcessID); | ||||
| // Get the process name | // Get the process name | ||||
| if (NULL != hProcess) { | if (NULL != hProcess) { | ||||
| HMODULE hMod; | HMODULE hMod; | ||||
| DWORD cbNeeded; | DWORD cbNeeded; | ||||
| if(EnumProcessModules(hProcess, &hMod, | |||||
| if(EnumProcessModules(hProcess, &hMod, | |||||
| sizeof(hMod), &cbNeeded)) { | sizeof(hMod), &cbNeeded)) { | ||||
| //Get the name of the exe file | //Get the name of the exe file | ||||
| GetModuleBaseName(hProcess, hMod, szEXEName, | |||||
| GetModuleBaseName(hProcess, hMod, szEXEName, | |||||
| sizeof(szEXEName)/sizeof(TCHAR)); | sizeof(szEXEName)/sizeof(TCHAR)); | ||||
| int len = strlen((char*)szEXEName) - 4; // remove ".exe" | int len = strlen((char*)szEXEName) - 4; // remove ".exe" | ||||
| strncpy(name, (char*)szEXEName, len); | |||||
| strncpy(name, (char*)szEXEName, len); | |||||
| name[len] = '\0'; | name[len] = '\0'; | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } | |||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| //------------------------------------------------------------------------------------------ | //------------------------------------------------------------------------------------------ | ||||
| static inline float ClipFloat(float sample) | |||||
| static inline jack_default_audio_sample_t ClipFloat(jack_default_audio_sample_t sample) | |||||
| { | { | ||||
| return (sample < -1.0f) ? -1.0f : (sample > 1.0f) ? 1.0f : sample; | |||||
| return (sample < jack_default_audio_sample_t(-1.0)) ? jack_default_audio_sample_t(-1.0) : (sample > jack_default_audio_sample_t(1.0)) ? jack_default_audio_sample_t(1.0) : sample; | |||||
| } | } | ||||
| //------------------------------------------------------------------------------------------ | //------------------------------------------------------------------------------------------ | ||||
| @@ -288,42 +288,42 @@ int JackRouter::process(jack_nframes_t nframes, void* arg) | |||||
| { | { | ||||
| JackRouter* driver = (JackRouter*)arg; | JackRouter* driver = (JackRouter*)arg; | ||||
| int i,j; | int i,j; | ||||
| int pos = (driver->fToggle) ? 0 : driver->fBufferSize ; | |||||
| for (i = 0; i < driver->fActiveInputs; i++) { | |||||
| #ifdef LONG_SAMPLE | |||||
| float* buffer = (float*)jack_port_get_buffer(driver->fInputPorts[i], nframes); | |||||
| int pos = (driver->fToggle) ? 0 : driver->fBufferSize ; | |||||
| for (i = 0; i < driver->fActiveInputs; i++) { | |||||
| #ifdef LONG_SAMPLE | |||||
| jack_default_audio_sample_t* buffer = (jack_default_audio_sample_t*)jack_port_get_buffer(driver->fInputPorts[i], nframes); | |||||
| long* in = driver->fInputBuffers[i] + pos; | long* in = driver->fInputBuffers[i] + pos; | ||||
| for (j = 0; j < nframes; j++) { | for (j = 0; j < nframes; j++) { | ||||
| in[j] = buffer[j] * float(0x7fffffff); | |||||
| in[j] = buffer[j] * jack_default_audio_sample_t(0x7fffffff); | |||||
| } | } | ||||
| #else | #else | ||||
| memcpy(driver->fInputBuffers[i] + pos, | memcpy(driver->fInputBuffers[i] + pos, | ||||
| jack_port_get_buffer(driver->fInputPorts[i], nframes), | jack_port_get_buffer(driver->fInputPorts[i], nframes), | ||||
| nframes * sizeof(float)); | |||||
| nframes * sizeof(jack_default_audio_sample_t)); | |||||
| #endif | #endif | ||||
| } | |||||
| } | |||||
| driver->bufferSwitch(); | driver->bufferSwitch(); | ||||
| for (i = 0; i < driver->fActiveOutputs; i++) { | for (i = 0; i < driver->fActiveOutputs; i++) { | ||||
| #ifdef LONG_SAMPLE | #ifdef LONG_SAMPLE | ||||
| float* buffer = (float*)jack_port_get_buffer(driver->fOutputPorts[i], nframes); | |||||
| jack_default_audio_sample_t* buffer = (jack_default_audio_sample_t*)jack_port_get_buffer(driver->fOutputPorts[i], nframes); | |||||
| long* out = driver->fOutputBuffers[i] + pos; | long* out = driver->fOutputBuffers[i] + pos; | ||||
| float gain = 1.f/float(0x7fffffff); | |||||
| jack_default_audio_sample_t gain = jack_default_audio_sample_t(1)/jack_default_audio_sample_t(0x7fffffff); | |||||
| for (j = 0; j < nframes; j++) { | for (j = 0; j < nframes; j++) { | ||||
| buffer[j] = out[j] * gain; | buffer[j] = out[j] * gain; | ||||
| } | } | ||||
| #else | #else | ||||
| memcpy(jack_port_get_buffer(driver->fOutputPorts[i], nframes), | memcpy(jack_port_get_buffer(driver->fOutputPorts[i], nframes), | ||||
| driver->fOutputBuffers[i] + pos, | driver->fOutputBuffers[i] + pos, | ||||
| nframes * sizeof(float)); | |||||
| nframes * sizeof(jack_default_audio_sample_t)); | |||||
| #endif | #endif | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -356,7 +356,7 @@ ASIOBool JackRouter::init(void* sysRef) | |||||
| HANDLE win = (HANDLE)sysRef; | HANDLE win = (HANDLE)sysRef; | ||||
| int my_pid = _getpid(); | int my_pid = _getpid(); | ||||
| if (!GetEXEName(my_pid, name)) { // If getting the .exe name fails, takes a generic one. | if (!GetEXEName(my_pid, name)) { // If getting the .exe name fails, takes a generic one. | ||||
| _snprintf(name, sizeof(name) - 1, "JackRouter_%d", my_pid); | _snprintf(name, sizeof(name) - 1, "JackRouter_%d", my_pid); | ||||
| } | } | ||||
| @@ -365,19 +365,19 @@ ASIOBool JackRouter::init(void* sysRef) | |||||
| printf("Error: jack client still present...\n"); | printf("Error: jack client still present...\n"); | ||||
| return true; | return true; | ||||
| } | } | ||||
| fClient = jack_client_open(name, JackNullOption, NULL); | fClient = jack_client_open(name, JackNullOption, NULL); | ||||
| if (fClient == NULL) { | if (fClient == NULL) { | ||||
| strcpy (fErrorMessage, "Open error: is jack server running?"); | strcpy (fErrorMessage, "Open error: is jack server running?"); | ||||
| printf("Open error: is jack server running?\n"); | printf("Open error: is jack server running?\n"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| fBufferSize = jack_get_buffer_size(fClient); | fBufferSize = jack_get_buffer_size(fClient); | ||||
| fSampleRate = jack_get_sample_rate(fClient); | fSampleRate = jack_get_sample_rate(fClient); | ||||
| jack_set_process_callback(fClient, process, this); | jack_set_process_callback(fClient, process, this); | ||||
| jack_on_shutdown(fClient, shutdown, this); | jack_on_shutdown(fClient, shutdown, this); | ||||
| fInputLatency = fBufferSize; // typically | fInputLatency = fBufferSize; // typically | ||||
| fOutputLatency = fBufferSize * 2; | fOutputLatency = fBufferSize * 2; | ||||
| fMilliSeconds = (long)((double)(fBufferSize * 1000) / fSampleRate); | fMilliSeconds = (long)((double)(fBufferSize * 1000) / fSampleRate); | ||||
| @@ -399,7 +399,7 @@ ASIOError JackRouter::start() | |||||
| fToggle = 0; | fToggle = 0; | ||||
| fStarted = true; | fStarted = true; | ||||
| printf("Start ASIO Jack\n"); | printf("Start ASIO Jack\n"); | ||||
| if (jack_activate(fClient) == 0) { | if (jack_activate(fClient) == 0) { | ||||
| if (fFirstActivate) { | if (fFirstActivate) { | ||||
| @@ -413,9 +413,9 @@ ASIOError JackRouter::start() | |||||
| } else { | } else { | ||||
| return ASE_NotPresent; | return ASE_NotPresent; | ||||
| } | |||||
| } | |||||
| } | } | ||||
| return ASE_NotPresent; | return ASE_NotPresent; | ||||
| } | } | ||||
| @@ -533,8 +533,8 @@ ASIOError JackRouter::getChannelInfo(ASIOChannelInfo *info) | |||||
| char buf[32]; | char buf[32]; | ||||
| if (info->isInput) { | if (info->isInput) { | ||||
| for (i = 0; i < fActiveInputs; i++) { | |||||
| if (fInMap[i] == info->channel) { | |||||
| for (i = 0; i < fActiveInputs; i++) { | |||||
| if (fInMap[i] == info->channel) { | |||||
| info->isActive = ASIOTrue; | info->isActive = ASIOTrue; | ||||
| //_snprintf(buf, sizeof(buf) - 1, "Jack::In%d ", info->channel); | //_snprintf(buf, sizeof(buf) - 1, "Jack::In%d ", info->channel); | ||||
| //strcpy(info->name, buf); | //strcpy(info->name, buf); | ||||
| @@ -545,7 +545,7 @@ ASIOError JackRouter::getChannelInfo(ASIOChannelInfo *info) | |||||
| _snprintf(buf, sizeof(buf) - 1, "In%d ", info->channel); | _snprintf(buf, sizeof(buf) - 1, "In%d ", info->channel); | ||||
| strcpy(info->name, buf); | strcpy(info->name, buf); | ||||
| } else { | } else { | ||||
| for (i = 0; i < fActiveOutputs; i++) { | |||||
| for (i = 0; i < fActiveOutputs; i++) { | |||||
| if (fOutMap[i] == info->channel) { //NOT USED !! | if (fOutMap[i] == info->channel) { //NOT USED !! | ||||
| info->isActive = ASIOTrue; | info->isActive = ASIOTrue; | ||||
| //_snprintf(buf, sizeof(buf) - 1, "Jack::Out%d ", info->channel); | //_snprintf(buf, sizeof(buf) - 1, "Jack::Out%d ", info->channel); | ||||
| @@ -579,7 +579,7 @@ ASIOError JackRouter::createBuffers(ASIOBufferInfo *bufferInfos, long numChannel | |||||
| #ifdef LONG_SAMPLE | #ifdef LONG_SAMPLE | ||||
| fInputBuffers[fActiveInputs] = new long[fBufferSize * 2]; // double buffer | fInputBuffers[fActiveInputs] = new long[fBufferSize * 2]; // double buffer | ||||
| #else | #else | ||||
| fInputBuffers[fActiveInputs] = new float[fBufferSize * 2]; // double buffer | |||||
| fInputBuffers[fActiveInputs] = new jack_default_audio_sample_t[fBufferSize * 2]; // double buffer | |||||
| #endif | #endif | ||||
| if (fInputBuffers[fActiveInputs]) { | if (fInputBuffers[fActiveInputs]) { | ||||
| info->buffers[0] = fInputBuffers[fActiveInputs]; | info->buffers[0] = fInputBuffers[fActiveInputs]; | ||||
| @@ -588,9 +588,9 @@ ASIOError JackRouter::createBuffers(ASIOBufferInfo *bufferInfos, long numChannel | |||||
| info->buffers[0] = info->buffers[1] = 0; | info->buffers[0] = info->buffers[1] = 0; | ||||
| notEnoughMem = true; | notEnoughMem = true; | ||||
| } | } | ||||
| _snprintf(buf, sizeof(buf) - 1, "in%d", fActiveInputs + 1); | _snprintf(buf, sizeof(buf) - 1, "in%d", fActiveInputs + 1); | ||||
| fInputPorts[fActiveInputs] | |||||
| fInputPorts[fActiveInputs] | |||||
| = jack_port_register(fClient, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput,0); | = jack_port_register(fClient, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput,0); | ||||
| if (fInputPorts[fActiveInputs] == NULL) | if (fInputPorts[fActiveInputs] == NULL) | ||||
| goto error; | goto error; | ||||
| @@ -601,17 +601,17 @@ error: | |||||
| disposeBuffers(); | disposeBuffers(); | ||||
| return ASE_InvalidParameter; | return ASE_InvalidParameter; | ||||
| } | } | ||||
| } else { // output | |||||
| } else { // output | |||||
| if (info->channelNum < 0 || info->channelNum >= kNumOutputs) | if (info->channelNum < 0 || info->channelNum >= kNumOutputs) | ||||
| goto error; | goto error; | ||||
| fOutMap[fActiveOutputs] = info->channelNum; | fOutMap[fActiveOutputs] = info->channelNum; | ||||
| #ifdef LONG_SAMPLE | #ifdef LONG_SAMPLE | ||||
| fOutputBuffers[fActiveOutputs] = new long[fBufferSize * 2]; // double buffer | fOutputBuffers[fActiveOutputs] = new long[fBufferSize * 2]; // double buffer | ||||
| #else | #else | ||||
| fOutputBuffers[fActiveOutputs] = new float[fBufferSize * 2]; // double buffer | |||||
| fOutputBuffers[fActiveOutputs] = new jack_default_audio_sample_t[fBufferSize * 2]; // double buffer | |||||
| #endif | #endif | ||||
| if (fOutputBuffers[fActiveOutputs]) { | if (fOutputBuffers[fActiveOutputs]) { | ||||
| info->buffers[0] = fOutputBuffers[fActiveOutputs]; | info->buffers[0] = fOutputBuffers[fActiveOutputs]; | ||||
| info->buffers[1] = fOutputBuffers[fActiveOutputs] + fBufferSize; | info->buffers[1] = fOutputBuffers[fActiveOutputs] + fBufferSize; | ||||
| @@ -619,9 +619,9 @@ error: | |||||
| info->buffers[0] = info->buffers[1] = 0; | info->buffers[0] = info->buffers[1] = 0; | ||||
| notEnoughMem = true; | notEnoughMem = true; | ||||
| } | } | ||||
| _snprintf(buf, sizeof(buf) - 1, "out%d", fActiveOutputs + 1); | _snprintf(buf, sizeof(buf) - 1, "out%d", fActiveOutputs + 1); | ||||
| fOutputPorts[fActiveOutputs] | |||||
| fOutputPorts[fActiveOutputs] | |||||
| = jack_port_register(fClient, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput,0); | = jack_port_register(fClient, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput,0); | ||||
| if (fOutputPorts[fActiveOutputs] == NULL) | if (fOutputPorts[fActiveOutputs] == NULL) | ||||
| goto error; | goto error; | ||||
| @@ -633,7 +633,7 @@ error: | |||||
| return ASE_InvalidParameter; | return ASE_InvalidParameter; | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } | |||||
| if (notEnoughMem) { | if (notEnoughMem) { | ||||
| disposeBuffers(); | disposeBuffers(); | ||||
| @@ -653,9 +653,9 @@ error: | |||||
| fAsioTime.timeCode.timeCodeSamples.lo = fAsioTime.timeCode.timeCodeSamples.hi = 0; | fAsioTime.timeCode.timeCodeSamples.lo = fAsioTime.timeCode.timeCodeSamples.hi = 0; | ||||
| fAsioTime.timeCode.flags = kTcValid | kTcRunning ; | fAsioTime.timeCode.flags = kTcValid | kTcRunning ; | ||||
| } else { | } else { | ||||
| fTimeInfoMode = false; | |||||
| fTimeInfoMode = false; | |||||
| } | } | ||||
| return ASE_OK; | return ASE_OK; | ||||
| } | } | ||||
| @@ -663,14 +663,14 @@ error: | |||||
| ASIOError JackRouter::disposeBuffers() | ASIOError JackRouter::disposeBuffers() | ||||
| { | { | ||||
| long i; | long i; | ||||
| fCallbacks = 0; | fCallbacks = 0; | ||||
| stop(); | stop(); | ||||
| for (i = 0; i < fActiveInputs; i++) { | for (i = 0; i < fActiveInputs; i++) { | ||||
| delete[] fInputBuffers[i]; | delete[] fInputBuffers[i]; | ||||
| jack_port_unregister(fClient, fInputPorts[i]); | jack_port_unregister(fClient, fInputPorts[i]); | ||||
| } | |||||
| } | |||||
| fActiveInputs = 0; | fActiveInputs = 0; | ||||
| for (i = 0; i < fActiveOutputs; i++) { | for (i = 0; i < fActiveOutputs; i++) { | ||||
| @@ -689,7 +689,7 @@ ASIOError JackRouter::controlPanel() | |||||
| } | } | ||||
| //--------------------------------------------------------------------------------------------- | //--------------------------------------------------------------------------------------------- | ||||
| ASIOError JackRouter::future(long selector, void* opt) // !!! check properties | |||||
| ASIOError JackRouter::future(long selector, void* opt) // !!! check properties | |||||
| { | { | ||||
| ASIOTransportParameters* tp = (ASIOTransportParameters*)opt; | ASIOTransportParameters* tp = (ASIOTransportParameters*)opt; | ||||
| switch (selector) | switch (selector) | ||||
| @@ -804,7 +804,7 @@ void JackRouter::RestoreConnections() | |||||
| void JackRouter::AutoConnect() | void JackRouter::AutoConnect() | ||||
| { | { | ||||
| const char** ports; | const char** ports; | ||||
| if ((ports = jack_get_ports(fClient, NULL, NULL, JackPortIsPhysical | JackPortIsOutput)) == NULL) { | if ((ports = jack_get_ports(fClient, NULL, NULL, JackPortIsPhysical | JackPortIsOutput)) == NULL) { | ||||
| printf("Cannot find any physical capture ports\n"); | printf("Cannot find any physical capture ports\n"); | ||||
| } else { | } else { | ||||
| @@ -818,9 +818,9 @@ void JackRouter::AutoConnect() | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| jack_free(ports); | |||||
| jack_free(ports); | |||||
| } | } | ||||
| if ((ports = jack_get_ports(fClient, NULL, NULL, JackPortIsPhysical | JackPortIsInput)) == NULL) { | if ((ports = jack_get_ports(fClient, NULL, NULL, JackPortIsPhysical | JackPortIsInput)) == NULL) { | ||||
| printf("Cannot find any physical playback ports"); | printf("Cannot find any physical playback ports"); | ||||
| } else { | } else { | ||||
| @@ -834,7 +834,7 @@ void JackRouter::AutoConnect() | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| jack_free(ports); | |||||
| jack_free(ports); | |||||
| } | } | ||||
| } | } | ||||
| @@ -35,7 +35,7 @@ namespace Jack | |||||
| void* userData) | void* userData) | ||||
| { | { | ||||
| JackPortAudioAdapter* adapter = static_cast<JackPortAudioAdapter*>(userData); | JackPortAudioAdapter* adapter = static_cast<JackPortAudioAdapter*>(userData); | ||||
| adapter->PushAndPull((float**)inputBuffer, (float**)outputBuffer, framesPerBuffer); | |||||
| adapter->PushAndPull((jack_default_audio_sample_t**)inputBuffer, (jack_default_audio_sample_t**)outputBuffer, framesPerBuffer); | |||||
| return paContinue; | return paContinue; | ||||
| } | } | ||||
| @@ -38,8 +38,8 @@ namespace Jack | |||||
| void* userData) | void* userData) | ||||
| { | { | ||||
| JackPortAudioDriver* driver = (JackPortAudioDriver*)userData; | JackPortAudioDriver* driver = (JackPortAudioDriver*)userData; | ||||
| driver->fInputBuffer = (float**)inputBuffer; | |||||
| driver->fOutputBuffer = (float**)outputBuffer; | |||||
| driver->fInputBuffer = (jack_default_audio_sample_t**)inputBuffer; | |||||
| driver->fOutputBuffer = (jack_default_audio_sample_t**)outputBuffer; | |||||
| // Setup threadded based log function | // Setup threadded based log function | ||||
| set_threaded_log_function(); | set_threaded_log_function(); | ||||
| driver->CycleTakeBeginTime(); | driver->CycleTakeBeginTime(); | ||||
| @@ -49,14 +49,14 @@ namespace Jack | |||||
| int JackPortAudioDriver::Read() | int JackPortAudioDriver::Read() | ||||
| { | { | ||||
| for (int i = 0; i < fCaptureChannels; i++) | for (int i = 0; i < fCaptureChannels; i++) | ||||
| memcpy(GetInputBuffer(i), fInputBuffer[i], sizeof(float) * fEngineControl->fBufferSize); | |||||
| memcpy(GetInputBuffer(i), fInputBuffer[i], sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int JackPortAudioDriver::Write() | int JackPortAudioDriver::Write() | ||||
| { | { | ||||
| for (int i = 0; i < fPlaybackChannels; i++) | for (int i = 0; i < fPlaybackChannels; i++) | ||||
| memcpy(fOutputBuffer[i], GetOutputBuffer(i), sizeof(float) * fEngineControl->fBufferSize); | |||||
| memcpy(fOutputBuffer[i], GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -37,8 +37,8 @@ class JackPortAudioDriver : public JackAudioDriver | |||||
| PortAudioDevices* fPaDevices; | PortAudioDevices* fPaDevices; | ||||
| PaStream* fStream; | PaStream* fStream; | ||||
| float** fInputBuffer; | |||||
| float** fOutputBuffer; | |||||
| jack_default_audio_sample_t** fInputBuffer; | |||||
| jack_default_audio_sample_t** fOutputBuffer; | |||||
| PaDeviceIndex fInputDevice; | PaDeviceIndex fInputDevice; | ||||
| PaDeviceIndex fOutputDevice; | PaDeviceIndex fOutputDevice; | ||||