Mercurial > hg > svapp
changeset 434:dee4aceb131c cxx11
Fixes to go with latest svcore
author | Chris Cannam |
---|---|
date | Wed, 04 Mar 2015 13:53:13 +0000 |
parents | 720f732e8082 |
children | 618d5816b04d |
files | audioio/AudioCallbackPlaySource.cpp audioio/AudioCallbackPlaySource.h audioio/PlaySpeedRangeMapper.cpp audioio/PlaySpeedRangeMapper.h framework/MainWindowBase.cpp |
diffstat | 5 files changed, 76 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/AudioCallbackPlaySource.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/audioio/AudioCallbackPlaySource.cpp Wed Mar 04 13:53:13 2015 +0000 @@ -397,7 +397,7 @@ } void -AudioCallbackPlaySource::play(int startFrame) +AudioCallbackPlaySource::play(sv_frame_t startFrame) { if (!m_sourceSampleRate) { cerr << "AudioCallbackPlaySource::play: No source sample rate available, not playing" << endl; @@ -597,18 +597,18 @@ } void -AudioCallbackPlaySource::setTargetPlayLatency(int latency) +AudioCallbackPlaySource::setTargetPlayLatency(sv_frame_t latency) { m_playLatency = latency; } -int +sv_frame_t AudioCallbackPlaySource::getTargetPlayLatency() const { return m_playLatency; } -int +sv_frame_t AudioCallbackPlaySource::getCurrentPlayingFrame() { // This method attempts to estimate which audio sample frame is @@ -625,13 +625,13 @@ return getCurrentFrame(latency_t); } -int +sv_frame_t AudioCallbackPlaySource::getCurrentBufferedFrame() { return getCurrentFrame(RealTime::zeroTime); } -int +sv_frame_t AudioCallbackPlaySource::getCurrentFrame(RealTime latency_t) { // We resample when filling the ring buffer, and time-stretch when @@ -640,8 +640,8 @@ // Because of the multiple rates involved, we do the actual // calculation using RealTime instead. - int sourceRate = getSourceSampleRate(); - int targetRate = getTargetSampleRate(); + sv_samplerate_t sourceRate = getSourceSampleRate(); + sv_samplerate_t targetRate = getTargetSampleRate(); if (sourceRate == 0 || targetRate == 0) return 0; @@ -739,7 +739,7 @@ - latency_t - stretchlat_t - lastretrieved_t - inbuffer_t + sincerequest_t; if (playing_t < RealTime::zeroTime) playing_t = RealTime::zeroTime; - int frame = RealTime::realTime2Frame(playing_t, sourceRate); + sv_frame_t frame = RealTime::realTime2Frame(playing_t, sourceRate); return m_viewManager->alignPlaybackFrameToReference(frame); } @@ -833,7 +833,7 @@ if (playing_t < RealTime::zeroTime) playing_t = RealTime::zeroTime; - int frame = RealTime::realTime2Frame(playing_t, sourceRate); + sv_frame_t frame = RealTime::realTime2Frame(playing_t, sourceRate); if (m_lastCurrentFrame > 0 && !looping) { if (frame < m_lastCurrentFrame) { @@ -916,7 +916,7 @@ } void -AudioCallbackPlaySource::setTargetSampleRate(int sr) +AudioCallbackPlaySource::setTargetSampleRate(sv_samplerate_t sr) { bool first = (m_targetSampleRate == 0); @@ -1033,7 +1033,7 @@ clearRingBuffers(); } -int +sv_samplerate_t AudioCallbackPlaySource::getTargetSampleRate() const { if (m_targetSampleRate) return m_targetSampleRate; @@ -1053,7 +1053,7 @@ return m_sourceChannelCount; } -int +sv_samplerate_t AudioCallbackPlaySource::getSourceSampleRate() const { return m_sourceSampleRate; @@ -1093,11 +1093,9 @@ emit activity(tr("Change time-stretch factor to %1").arg(factor)); } -int -AudioCallbackPlaySource::getSourceSamples(int ucount, float **buffer) +sv_frame_t +AudioCallbackPlaySource::getSourceSamples(sv_frame_t count, float **buffer) { - int count = ucount; - if (!m_playing) { #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING SVDEBUG << "AudioCallbackPlaySource::getSourceSamples: Not playing" << endl; @@ -1309,7 +1307,7 @@ } void -AudioCallbackPlaySource::applyAuditioningEffect(int count, float **buffers) +AudioCallbackPlaySource::applyAuditioningEffect(sv_frame_t count, float **buffers) { if (m_auditioningPluginBypassed) return; RealTimePluginInstance *plugin = m_auditioningPlugin; @@ -1359,11 +1357,11 @@ static float *tmp = 0; static int tmpSize = 0; - int space = 0; + sv_frame_t space = 0; for (int c = 0; c < getTargetChannelCount(); ++c) { RingBuffer<float> *wb = getWriteRingBuffer(c); if (wb) { - int spaceHere = wb->getWriteSpace(); + sv_frame_t spaceHere = wb->getWriteSpace(); if (c == 0 || spaceHere < space) space = spaceHere; } } @@ -1375,7 +1373,7 @@ return false; } - int f = m_writeBufferFill; + sv_frame_t f = m_writeBufferFill; bool readWriteEqual = (m_readBuffers == m_writeBuffers); @@ -1398,8 +1396,8 @@ int channels = getTargetChannelCount(); - int orig = space; - int got = 0; + sv_frame_t orig = space; + sv_frame_t got = 0; static float **bufferPtrs = 0; static int bufferPtrCount = 0; @@ -1580,14 +1578,14 @@ return true; } -int -AudioCallbackPlaySource::mixModels(int &frame, int count, float **buffers) +sv_frame_t +AudioCallbackPlaySource::mixModels(sv_frame_t &frame, sv_frame_t count, float **buffers) { - int processed = 0; - int chunkStart = frame; - int chunkSize = count; - int selectionSize = 0; - int nextChunkStart = chunkStart + chunkSize; + sv_frame_t processed = 0; + sv_frame_t chunkStart = frame; + sv_frame_t chunkSize = count; + sv_frame_t selectionSize = 0; + sv_frame_t nextChunkStart = chunkStart + chunkSize; bool looping = m_viewManager->getPlayLoopMode(); bool constrained = (m_viewManager->getPlaySelectionMode() && @@ -1617,11 +1615,11 @@ nextChunkStart = chunkStart + chunkSize; selectionSize = 0; - int fadeIn = 0, fadeOut = 0; + sv_frame_t fadeIn = 0, fadeOut = 0; if (constrained) { - int rChunkStart = + sv_frame_t rChunkStart = m_viewManager->alignPlaybackFrameToReference(chunkStart); Selection selection = @@ -1643,9 +1641,9 @@ } else { - int sf = m_viewManager->alignReferenceToPlaybackFrame + sv_frame_t sf = m_viewManager->alignReferenceToPlaybackFrame (selection.getStartFrame()); - int ef = m_viewManager->alignReferenceToPlaybackFrame + sv_frame_t ef = m_viewManager->alignReferenceToPlaybackFrame (selection.getEndFrame()); selectionSize = ef - sf;
--- a/audioio/AudioCallbackPlaySource.h Tue Mar 03 09:33:59 2015 +0000 +++ b/audioio/AudioCallbackPlaySource.h Wed Mar 04 13:53:13 2015 +0000 @@ -83,7 +83,7 @@ * from the given frame. If playback is already under way, reseek * to the given frame and continue. */ - virtual void play(int startFrame); + virtual void play(sv_frame_t startFrame); /** * Stop playback and ensure that no more data is returned. @@ -99,18 +99,18 @@ * Return the frame number that is currently expected to be coming * out of the speakers. (i.e. compensating for playback latency.) */ - virtual int getCurrentPlayingFrame(); + virtual sv_frame_t getCurrentPlayingFrame(); /** * Return the last frame that would come out of the speakers if we * stopped playback right now. */ - virtual int getCurrentBufferedFrame(); + virtual sv_frame_t getCurrentBufferedFrame(); /** * Return the frame at which playback is expected to end (if not looping). */ - virtual int getPlayEndFrame() { return m_lastModelEndFrame; } + virtual sv_frame_t getPlayEndFrame() { return m_lastModelEndFrame; } /** * Set the target and the block size of the target audio device. @@ -133,12 +133,12 @@ * highest last frame across all channels) requested via * getSamples(). The default is zero. */ - void setTargetPlayLatency(int); + void setTargetPlayLatency(sv_frame_t); /** * Get the playback latency of the target audio device. */ - int getTargetPlayLatency() const; + sv_frame_t getTargetPlayLatency() const; /** * Specify that the target audio device has a fixed sample rate @@ -147,13 +147,13 @@ * source sample rate, this class will resample automatically to * fit. */ - void setTargetSampleRate(int); + void setTargetSampleRate(sv_samplerate_t); /** * Return the sample rate set by the target audio device (or the * source sample rate if the target hasn't set one). */ - virtual int getTargetSampleRate() const; + virtual sv_samplerate_t getTargetSampleRate() const; /** * Set the current output levels for metering (for call from the @@ -189,14 +189,14 @@ * safely be called from a realtime thread. Returns 0 if there is * no source yet available. */ - virtual int getSourceSampleRate() const; + virtual sv_samplerate_t getSourceSampleRate() const; /** * Get "count" samples (at the target sample rate) of the mixed * audio data, in all channels. This may safely be called from a * realtime thread. */ - int getSourceSamples(int count, float **buffer); + sv_frame_t getSourceSamples(sv_frame_t count, float **buffer); /** * Set the time stretcher factor (i.e. playback speed). @@ -285,24 +285,24 @@ Scavenger<RingBufferVector> m_bufferScavenger; int m_sourceChannelCount; int m_blockSize; - int m_sourceSampleRate; - int m_targetSampleRate; + sv_samplerate_t m_sourceSampleRate; + sv_samplerate_t m_targetSampleRate; int m_playLatency; AudioCallbackPlayTarget *m_target; double m_lastRetrievalTimestamp; int m_lastRetrievedBlockSize; bool m_trustworthyTimestamps; - int m_lastCurrentFrame; + sv_frame_t m_lastCurrentFrame; bool m_playing; bool m_exiting; - int m_lastModelEndFrame; + sv_frame_t m_lastModelEndFrame; int m_ringBufferSize; float m_outputLeft; float m_outputRight; RealTimePluginInstance *m_auditioningPlugin; bool m_auditioningPluginBypassed; Scavenger<RealTimePluginInstance> m_pluginScavenger; - int m_playStartFrame; + sv_frame_t m_playStartFrame; bool m_playStartFramePassed; RealTime m_playStartedAt; @@ -343,17 +343,17 @@ // which will be count or fewer. Return in the frame argument the // new buffered frame position (which may be earlier than the // frame argument passed in, in the case of looping). - int mixModels(int &frame, int count, float **buffers); + sv_frame_t mixModels(sv_frame_t &frame, sv_frame_t count, float **buffers); // Called from getSourceSamples. - void applyAuditioningEffect(int count, float **buffers); + void applyAuditioningEffect(sv_frame_t count, float **buffers); // Ranges of current selections, if play selection is active std::vector<RealTime> m_rangeStarts; std::vector<RealTime> m_rangeDurations; void rebuildRangeLists(); - int getCurrentFrame(RealTime outputLatency); + sv_frame_t getCurrentFrame(RealTime outputLatency); class FillThread : public Thread {
--- a/audioio/PlaySpeedRangeMapper.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/audioio/PlaySpeedRangeMapper.cpp Wed Mar 04 13:53:13 2015 +0000 @@ -25,23 +25,23 @@ } int -PlaySpeedRangeMapper::getPositionForValue(float value) const +PlaySpeedRangeMapper::getPositionForValue(double value) const { // value is percent - float factor = getFactorForValue(value); + double factor = getFactorForValue(value); int position = getPositionForFactor(factor); return position; } int -PlaySpeedRangeMapper::getPositionForValueUnclamped(float value) const +PlaySpeedRangeMapper::getPositionForValueUnclamped(double value) const { // We don't really provide this return getPositionForValue(value); } int -PlaySpeedRangeMapper::getPositionForFactor(float factor) const +PlaySpeedRangeMapper::getPositionForFactor(double factor) const { bool slow = (factor > 1.0); @@ -63,37 +63,37 @@ return position; } -float +double PlaySpeedRangeMapper::getValueForPosition(int position) const { - float factor = getFactorForPosition(position); - float pc = getValueForFactor(factor); + double factor = getFactorForPosition(position); + double pc = getValueForFactor(factor); return pc; } -float +double PlaySpeedRangeMapper::getValueForPositionUnclamped(int position) const { // We don't really provide this return getValueForPosition(position); } -float -PlaySpeedRangeMapper::getValueForFactor(float factor) const +double +PlaySpeedRangeMapper::getValueForFactor(double factor) const { - float pc; + double pc; if (factor < 1.0) pc = ((1.0 / factor) - 1.0) * 100.0; else pc = (1.0 - factor) * 100.0; // cerr << "position = " << position << " percent = " << pc << endl; return pc; } -float -PlaySpeedRangeMapper::getFactorForValue(float value) const +double +PlaySpeedRangeMapper::getFactorForValue(double value) const { // value is percent - float factor; + double factor; if (value <= 0) { factor = 1.0 - (value / 100.0); @@ -105,7 +105,7 @@ return factor; } -float +double PlaySpeedRangeMapper::getFactorForPosition(int position) const { bool slow = false; @@ -124,7 +124,7 @@ // position is between min and half (inclusive) - float factor; + double factor; if (position == m_minpos) { factor = 1.0;
--- a/audioio/PlaySpeedRangeMapper.h Tue Mar 03 09:33:59 2015 +0000 +++ b/audioio/PlaySpeedRangeMapper.h Wed Mar 04 13:53:13 2015 +0000 @@ -23,17 +23,17 @@ public: PlaySpeedRangeMapper(int minpos, int maxpos); - virtual int getPositionForValue(float value) const; - virtual int getPositionForValueUnclamped(float value) const; + virtual int getPositionForValue(double value) const; + virtual int getPositionForValueUnclamped(double value) const; - virtual float getValueForPosition(int position) const; - virtual float getValueForPositionUnclamped(int position) const; + virtual double getValueForPosition(int position) const; + virtual double getValueForPositionUnclamped(int position) const; - int getPositionForFactor(float factor) const; - float getValueForFactor(float factor) const; + int getPositionForFactor(double factor) const; + double getValueForFactor(double factor) const; - float getFactorForPosition(int position) const; - float getFactorForValue(float value) const; + double getFactorForPosition(int position) const; + double getFactorForValue(double value) const; virtual QString getUnit() const;
--- a/framework/MainWindowBase.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/framework/MainWindowBase.cpp Wed Mar 04 13:53:13 2015 +0000 @@ -2370,8 +2370,8 @@ Model *model = getMainModel(); if (!model) return; - int start = model->getStartFrame(); - int end = model->getEndFrame(); + sv_frame_t start = model->getStartFrame(); + sv_frame_t end = model->getEndFrame(); if (m_playSource) end = std::max(end, m_playSource->getPlayEndFrame()); int pixels = currentPane->width();