zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit ea47ceac711f4ca5709694474859e9340992c5d8
parent 2bee5f578cd94052a4d54be651a51b8bfab7ca4d
Author: fundamental <[email protected]>
Date:   Sat, 12 Jun 2010 13:13:52 -0400

Nio: removing unwanted call to new

Diffstat:
Msrc/Nio/AlsaEngine.cpp | 8++++----
Msrc/Nio/AlsaEngine.h | 3+--
Msrc/Nio/AudioOut.cpp | 10+---------
Msrc/Nio/AudioOut.h | 3+--
Msrc/Nio/JackEngine.cpp | 2+-
Msrc/Nio/NulEngine.cpp | 5++---
Msrc/Nio/OssEngine.cpp | 2+-
Msrc/Nio/PaEngine.cpp | 18++++++++----------
8 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp @@ -230,14 +230,14 @@ void AlsaEngine::stopMidi() snd_seq_close(handle); } -const short *AlsaEngine::interleave(const Stereo<Sample> smps)const +const short *AlsaEngine::interleave(const Stereo<REALTYPE *> smps)const { /**\todo TODO fix repeated allocation*/ - short *shortInterleaved = new short[smps.l().size()*2]; - memset(shortInterleaved,0,smps.l().size()*2*sizeof(short)); + short *shortInterleaved = new short[bufferSize*2]; + memset(shortInterleaved,0,bufferSize*2*sizeof(short)); int idx = 0;//possible off by one error here double scaled; - for (int frame = 0; frame < smps.l().size(); ++frame) + for (int frame = 0; frame < bufferSize; ++frame) { // with a nod to libsamplerate ... scaled = smps.l()[frame] * (8.0 * 0x10000000); shortInterleaved[idx++] = (short int)(lrint(scaled) >> 16); diff --git a/src/Nio/AlsaEngine.h b/src/Nio/AlsaEngine.h @@ -29,7 +29,6 @@ #include "MidiIn.h" #include "OutMgr.h" #include "../Misc/Stereo.h" -#include "../Samples/Sample.h" class AlsaEngine : public AudioOut, MidiIn { @@ -57,7 +56,7 @@ class AlsaEngine : public AudioOut, MidiIn bool openAudio(); void stopAudio(); - const short *interleave(const Stereo<Sample> smps) const; + const short *interleave(const Stereo<REALTYPE *> smps) const; struct { std::string device; diff --git a/src/Nio/AudioOut.cpp b/src/Nio/AudioOut.cpp @@ -65,15 +65,7 @@ int AudioOut::bufferingSize() //return buffering; } -const Stereo<Sample> AudioOut::getNext(bool wait) -{ - Stereo<REALTYPE *> tmp = OutMgr::getInstance().tick(bufferSize); - - //stop the samples - return Stereo<Sample>(Sample(bufferSize, tmp.l()), Sample(bufferSize, tmp.r())); -} - -const Stereo<REALTYPE *> AudioOut::getNextBuf() +const Stereo<REALTYPE *> AudioOut::getNext() { return OutMgr::getInstance().tick(bufferSize); } diff --git a/src/Nio/AudioOut.h b/src/Nio/AudioOut.h @@ -52,8 +52,7 @@ class AudioOut : public virtual Engine protected: /**Get the next sample for output. * (has nsamples sampled at a rate of samplerate)*/ - const Stereo<Sample> getNext(bool wait = false); - const Stereo<REALTYPE *> getNextBuf(); + const Stereo<REALTYPE *> getNext(); int samplerate; int bufferSize; diff --git a/src/Nio/JackEngine.cpp b/src/Nio/JackEngine.cpp @@ -259,7 +259,7 @@ bool JackEngine::processAudio(jack_nframes_t nframes) } } - Stereo<REALTYPE *> smp = getNextBuf(); + Stereo<REALTYPE *> smp = getNext(); //Assumes smp.l().size() == nframes memcpy(audio.portBuffs[0], smp.l(), bufferSize*sizeof(REALTYPE)); diff --git a/src/Nio/NulEngine.cpp b/src/Nio/NulEngine.cpp @@ -42,9 +42,8 @@ void *NulEngine::_AudioThread(void *arg) void *NulEngine::AudioThread() { - while(pThread) - { - const Stereo<Sample> smps = getNext(); + while(pThread) { + getNext(); struct timeval now; int remaining = 0; diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -209,7 +209,7 @@ void *OssEngine::thread() { if(getAudioEn()) { - const Stereo<Sample> smps = getNext(); + const Stereo<REALTYPE *> smps = getNext(); REALTYPE l, r; for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { diff --git a/src/Nio/PaEngine.cpp b/src/Nio/PaEngine.cpp @@ -44,7 +44,7 @@ bool PaEngine::Start() return true; enabled = true; Pa_Initialize(); - + PaStreamParameters outputParameters; outputParameters.device = Pa_GetDefaultOutputDevice(); if (outputParameters.device == paNoDevice) { @@ -54,7 +54,7 @@ bool PaEngine::Start() } outputParameters.channelCount = 2; /* stereo output */ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */ - outputParameters.suggestedLatency = + outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; @@ -70,7 +70,7 @@ bool PaEngine::Start() Pa_StartStream(stream); return true; } - + int PaEngine::PAprocess(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *outTime, PaStreamCallbackFlags flags, @@ -83,15 +83,13 @@ int PaEngine::PAprocess(const void *inputBuffer, void *outputBuffer, int PaEngine::process(float *out, unsigned long framesPerBuffer) { - const Stereo<Sample> smp = getNext(); - - if(framesPerBuffer != smp.l().size()) - cerr << "Bug: PaEngine::process SOUND_BUFFER_SIZE!=framesPerBuffer" - << framesPerBuffer << ' ' << smp.l().size() << endl; + const Stereo<REALTYPE *> smp = getNext(); + + //if(framesPerBuffer != smp.l().size()) + // cerr << "Bug: PaEngine::process SOUND_BUFFER_SIZE!=framesPerBuffer" + // << framesPerBuffer << ' ' << smp.l().size() << endl; for(int i = 0; i < framesPerBuffer; i++) { - if(i >= smp.l().size()) - break;//this should never happens, except only when framesPerBuffer!>SOUND_BUFFER_SIZE *out++ = smp.l()[i]; *out++ = smp.r()[i]; }