Simplify sample frame operations (make it a class) (#7156)

* Remove the struct StereoSample

Remove the struct `StereoSample`. Let `AudioEngine::getPeakValues` return a `sampleFrame` instead.

Adjust the calls in `Mixer`  and `Oscilloscope`.

* Simplify AudioEngine::getPeakValues

* Remove surroundSampleFrame

Some code assumes that `surroundSampleFrame` is interchangeable with `sampleFrame`. Thus, if the line `#define LMMS_DISABLE_SURROUND` is commented out in `lmms_basics.h` then the code does not compile anymore because `surroundSampleFrame` now is defined to be an array with four values instead of two. There also does not seem to be any support for surround sound (four channels instead of two) in the application. The faders and mixers do not seem to support more that two channels and the instruments and effects all expect a `sampleFrame`, i.e. stereo channels. It therefore makes sense to remove the "feature" because it also hinders the improvement of `sampleFrame`, e.g. by making it a class with some convenience methods that act on `sampleFrame` instances.

All occurrences of `surroundSampleFrame` are replaced with `sampleFrame`.

The version of `BufferManager::clear` that takes a `surroundSampleFrame` is removed completely.

The define `SURROUND_CHANNELS` is removed. All its occurrences are replaced with `DEFAULT_CHANNELS`.

Most of the audio devices classes, i.e. classes that inherit from `AudioDevice`, now clamp the configuration parameter between two values of `DEFAULT_CHANNELS`. This can be improved/streamlined later.

`BYTES_PER_SURROUND_FRAME` has been removed as it was not used anywhere anyway.

* Make sampleFrame a class

Make `sampleFrame` a class with several convenience methods. As a first step and demonstration adjust the follow methods to make use of the new functionality:
* `AudioEngine::getPeakValues`: Much more concise now.
* `lmms::MixHelpers::sanitize`: Better structure, better readable, less dereferencing and juggling with indices.
* `AddOp`, `AddMultipliedOp`, `multiply`: Make use of operators. Might become superfluous in the future.

* More operators and methods for sampleFrame

Add some more operators and methods to `sampleFrame`:
* Constructor which initializes both channels from a single sample value
* Assignment operator from a single sample value
* Addition/multiplication operators
* Scalar product

Adjust some more plugins to the new functionality of `sampleFrame`.

* Adjust DelayEffect to methods in sampleFrame

* Use composition instead of inheritance

Using inheritance was the quickest way to enable adding methods to `sampleFrame` without having to reimpement much of `std::array`s interface.

This is changed with this commit. The array is now a member of `sampleFrame` and the interface is extended with the necessary methods `data` and the index operator.

An `average` method was added so that no iterators need to be implemented (see changes in `SampleWaveform.cpp`).

* Apply suggestions from code review

Apply Veratil's suggestions from the code review

Co-authored-by: Kevin Zander <veratil@gmail.com>

* Fix warnings: zeroing non-trivial type

Fix several warnings of the following form:

Warnung: »void* memset(void*, int, size_t)« Säubern eines Objekts von nichttrivialem Typ »class lmms::sampleFrame«; use assignment or value-initialization instead [-Wclass-memaccess]

* Remove unnecessary reinterpret_casts

Remove some unnecessary reinterpret_casts with regards to `sampleFrame` buffers.

`PlayHandle::m_playHandleBuffer` already is a `sampleFrame*` and does not need a reinterpret_cast anymore.

In `LadspaEffect::processAudioBuffer` the `QVarLengthArray` is now directly initialized as an array of `sampleFrame` instances.

I guess in both places the `sampleFrame` previously was a `surroundSampleFrame` which has been removed.

* Clean up zeroSampleFrames code

* Fix warnings in RemotePlugin

Fix some warnings related to calls to `memcpy` in conjunction with`sampleFrame` which is now a class.

Add the helper functions `copyToSampleFrames` and `copyFromSampleFrames` and use them. The first function copies data from a `float` buffer into a `sampleFrame` buffer and the second copies vice versa.

* Rename "sampleFrame" to "SampleFrame"

Uppercase the name of `sampleFrame` so that it uses UpperCamelCase convention.

* Move SampleFrame into its own file

Move the class `SampleFrame` into its own class and remove it from `lmms_basics.h`.

Add forward includes to all headers where possible or include the `SampleFrame` header if it's not just referenced but used.

Add include to all cpp files where necessary.

It's a bit surprising that the `SampleFrame` header does not need to be included much more often in the implementation/cpp files. This is an indicator that it seems to be included via an include chain that at one point includes one of the headers where an include instead of a forward declaration had to be added in this commit.

* Return reference for += and *=

Return a reference for the compound assignment operators `+=` and `-=`.

* Explicit float constructor

Make the  constructor that takes a `float` explicit.

Remove the assignment operator that takes a `float`. Clients must use the
explicit `float` constructor and assign the result.

Adjust the code in "BitInvader" accordingly.

* Use std::fill in zeroSampleFrames

* Use zeroSampleFrames in sanitize

* Replace max with absMax

Replace `SampleFrame::max` with `SampleFrame::absMax`.

Use `absMax` in `DelayEffect::processAudioBuffer`. This should also fix
a buggy implementation of the peak computation.

Add the function `getAbsPeakValues`. It  computes the absolute peak
values for a buffer.

Remove `AudioEngine::getPeakValues`. It's not really the business of the
audio engine. Let `Mixer` and `Oscilloscope` use `getAbsPeakValues`.

* Replace scalarProduct

Replace the rather mathematical method `scalarProduct` with
`sumOfSquaredAmplitudes`. It was always called on itself anyway.

* Remove comment/TODO

* Simplify sanitize

Simplify the `sanitize` function by getting rid of the `bool found` and
by zeroing the buffer as soon as a problem is found.

* Put pointer symbols next to type

* Code review adjustments

* Remove "#pragme once"
* Adjust name of include guard
* Remove superfluous includes (leftovers from previous code changes)

---------

Co-authored-by: Kevin Zander <veratil@gmail.com>
This commit is contained in:
Michael Gregorius
2024-06-30 20:21:19 +02:00
committed by GitHub
parent a0fbd7e7b4
commit 286e62adf5
199 changed files with 879 additions and 668 deletions

View File

@@ -95,7 +95,7 @@ AudioEngine::AudioEngine( bool renderOnly ) :
{
m_inputBufferFrames[i] = 0;
m_inputBufferSize[i] = DEFAULT_BUFFER_SIZE * 100;
m_inputBuffer[i] = new sampleFrame[ DEFAULT_BUFFER_SIZE * 100 ];
m_inputBuffer[i] = new SampleFrame[ DEFAULT_BUFFER_SIZE * 100 ];
BufferManager::clear( m_inputBuffer[i], m_inputBufferSize[i] );
}
@@ -136,8 +136,8 @@ AudioEngine::AudioEngine( bool renderOnly ) :
// now that framesPerPeriod is fixed initialize global BufferManager
BufferManager::init( m_framesPerPeriod );
m_outputBufferRead = std::make_unique<surroundSampleFrame[]>(m_framesPerPeriod);
m_outputBufferWrite = std::make_unique<surroundSampleFrame[]>(m_framesPerPeriod);
m_outputBufferRead = std::make_unique<SampleFrame[]>(m_framesPerPeriod);
m_outputBufferWrite = std::make_unique<SampleFrame[]>(m_framesPerPeriod);
for( int i = 0; i < m_numWorkers+1; ++i )
@@ -279,19 +279,19 @@ bool AudioEngine::criticalXRuns() const
void AudioEngine::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames )
void AudioEngine::pushInputFrames( SampleFrame* _ab, const f_cnt_t _frames )
{
requestChangeInModel();
f_cnt_t frames = m_inputBufferFrames[ m_inputBufferWrite ];
int size = m_inputBufferSize[ m_inputBufferWrite ];
sampleFrame * buf = m_inputBuffer[ m_inputBufferWrite ];
SampleFrame* buf = m_inputBuffer[ m_inputBufferWrite ];
if( frames + _frames > size )
{
size = std::max(size * 2, frames + _frames);
auto ab = new sampleFrame[size];
memcpy( ab, buf, frames * sizeof( sampleFrame ) );
auto ab = new SampleFrame[size];
memcpy( ab, buf, frames * sizeof( SampleFrame ) );
delete [] buf;
m_inputBufferSize[ m_inputBufferWrite ] = size;
@@ -300,7 +300,7 @@ void AudioEngine::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames )
buf = ab;
}
memcpy( &buf[ frames ], _ab, _frames * sizeof( sampleFrame ) );
memcpy( &buf[ frames ], _ab, _frames * sizeof( SampleFrame ) );
m_inputBufferFrames[ m_inputBufferWrite ] += _frames;
doneChangeInModel();
@@ -429,7 +429,7 @@ void AudioEngine::renderStageMix()
const surroundSampleFrame* AudioEngine::renderNextBuffer()
const SampleFrame* AudioEngine::renderNextBuffer()
{
const auto lock = std::lock_guard{m_changeMutex};
@@ -457,7 +457,7 @@ void AudioEngine::swapBuffers()
m_inputBufferFrames[m_inputBufferWrite] = 0;
std::swap(m_outputBufferRead, m_outputBufferWrite);
std::fill_n(m_outputBufferWrite.get(), m_framesPerPeriod, surroundSampleFrame{});
zeroSampleFrames(m_outputBufferWrite.get(), m_framesPerPeriod);
}
@@ -548,32 +548,6 @@ void AudioEngine::clearInternal()
AudioEngine::StereoSample AudioEngine::getPeakValues(sampleFrame * ab, const f_cnt_t frames) const
{
sample_t peakLeft = 0.0f;
sample_t peakRight = 0.0f;
for (f_cnt_t f = 0; f < frames; ++f)
{
float const absLeft = std::abs(ab[f][0]);
float const absRight = std::abs(ab[f][1]);
if (absLeft > peakLeft)
{
peakLeft = absLeft;
}
if (absRight > peakRight)
{
peakRight = absRight;
}
}
return StereoSample(peakLeft, peakRight);
}
void AudioEngine::changeQuality(const struct qualitySettings & qs)
{
// don't delete the audio-device
@@ -1226,9 +1200,9 @@ void AudioEngine::fifoWriter::run()
const fpp_t frames = m_audioEngine->framesPerPeriod();
while( m_writing )
{
auto buffer = new surroundSampleFrame[frames];
const surroundSampleFrame * b = m_audioEngine->renderNextBuffer();
memcpy( buffer, b, frames * sizeof( surroundSampleFrame ) );
auto buffer = new SampleFrame[frames];
const SampleFrame* b = m_audioEngine->renderNextBuffer();
memcpy(buffer, b, frames * sizeof(SampleFrame));
m_fifo->write(buffer);
}

View File

@@ -26,6 +26,8 @@
#include "BufferManager.h"
#include "SampleFrame.h"
#include <cstring>
@@ -40,26 +42,18 @@ void BufferManager::init( fpp_t fpp )
}
sampleFrame * BufferManager::acquire()
SampleFrame* BufferManager::acquire()
{
return new sampleFrame[s_framesPerPeriod];
return new SampleFrame[s_framesPerPeriod];
}
void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset )
void BufferManager::clear( SampleFrame* ab, const f_cnt_t frames, const f_cnt_t offset )
{
memset( ab + offset, 0, sizeof( *ab ) * frames );
zeroSampleFrames(ab + offset, frames);
}
#ifndef LMMS_DISABLE_SURROUND
void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames,
const f_cnt_t offset )
{
memset( ab + offset, 0, sizeof( *ab ) * frames );
}
#endif
void BufferManager::release( sampleFrame * buf )
void BufferManager::release( SampleFrame* buf )
{
delete[] buf;
}

View File

@@ -31,6 +31,7 @@
#include "EffectView.h"
#include "ConfigManager.h"
#include "SampleFrame.h"
namespace lmms
{
@@ -199,9 +200,9 @@ void Effect::reinitSRC()
void Effect::resample( int _i, const sampleFrame * _src_buf,
void Effect::resample( int _i, const SampleFrame* _src_buf,
sample_rate_t _src_sr,
sampleFrame * _dst_buf, sample_rate_t _dst_sr,
SampleFrame* _dst_buf, sample_rate_t _dst_sr,
f_cnt_t _frames )
{
if( m_srcState[_i] == nullptr )

View File

@@ -184,7 +184,7 @@ void EffectChain::moveUp( Effect * _effect )
bool EffectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, bool hasInputNoise )
bool EffectChain::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames, bool hasInputNoise )
{
if( m_enabledModel.value() == false )
{

View File

@@ -45,7 +45,7 @@ Instrument::Instrument(InstrumentTrack * _instrument_track,
{
}
void Instrument::play( sampleFrame * )
void Instrument::play( SampleFrame* )
{
}
@@ -89,7 +89,7 @@ bool Instrument::isFromTrack( const Track * _track ) const
}
// helper function for Instrument::applyFadeIn
static int countZeroCrossings(sampleFrame *buf, fpp_t start, fpp_t frames)
static int countZeroCrossings(SampleFrame* buf, fpp_t start, fpp_t frames)
{
// zero point crossing counts of all channels
auto zeroCrossings = std::array<int, DEFAULT_CHANNELS>{};
@@ -128,7 +128,7 @@ fpp_t getFadeInLength(float maxLength, fpp_t frames, int zeroCrossings)
}
void Instrument::applyFadeIn(sampleFrame * buf, NotePlayHandle * n)
void Instrument::applyFadeIn(SampleFrame* buf, NotePlayHandle * n)
{
const static float MAX_FADE_IN_LENGTH = 85.0;
f_cnt_t total = n->totalFramesPlayed();
@@ -179,7 +179,7 @@ void Instrument::applyFadeIn(sampleFrame * buf, NotePlayHandle * n)
}
}
void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n )
void Instrument::applyRelease( SampleFrame* buf, const NotePlayHandle * _n )
{
const auto fpp = Engine::audioEngine()->framesPerPeriod();
const auto releaseFrames = desiredReleaseFrames();

View File

@@ -40,7 +40,7 @@ InstrumentPlayHandle::InstrumentPlayHandle(Instrument * instrument, InstrumentTr
setAudioPort(instrumentTrack->audioPort());
}
void InstrumentPlayHandle::play(sampleFrame * working_buffer)
void InstrumentPlayHandle::play(SampleFrame* working_buffer)
{
InstrumentTrack * instrumentTrack = m_instrument->instrumentTrack();

View File

@@ -127,7 +127,7 @@ float InstrumentSoundShaping::volumeLevel( NotePlayHandle* n, const f_cnt_t fram
void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer,
void InstrumentSoundShaping::processAudioBuffer( SampleFrame* buffer,
const fpp_t frames,
NotePlayHandle* n )
{

View File

@@ -32,6 +32,7 @@
#include <QtGlobal>
#include "ValueBuffer.h"
#include "SampleFrame.h"
@@ -43,7 +44,7 @@ namespace lmms::MixHelpers
/*! \brief Function for applying MIXOP on all sample frames */
template<typename MIXOP>
static inline void run( sampleFrame* dst, const sampleFrame* src, int frames, const MIXOP& OP )
static inline void run( SampleFrame* dst, const SampleFrame* src, int frames, const MIXOP& OP )
{
for( int i = 0; i < frames; ++i )
{
@@ -53,18 +54,18 @@ static inline void run( sampleFrame* dst, const sampleFrame* src, int frames, co
/*! \brief Function for applying MIXOP on all sample frames - split source */
template<typename MIXOP>
static inline void run( sampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, int frames, const MIXOP& OP )
static inline void run( SampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, int frames, const MIXOP& OP )
{
for( int i = 0; i < frames; ++i )
{
const sampleFrame src = { srcLeft[i], srcRight[i] };
const SampleFrame src = { srcLeft[i], srcRight[i] };
OP( dst[i], src );
}
}
bool isSilent( const sampleFrame* src, int frames )
bool isSilent( const SampleFrame* src, int frames )
{
const float silenceThreshold = 0.0000001f;
@@ -90,55 +91,49 @@ void setNaNHandler( bool use )
}
/*! \brief Function for sanitizing a buffer of infs/nans - returns true if those are found */
bool sanitize( sampleFrame * src, int frames )
bool sanitize( SampleFrame* src, int frames )
{
if( !useNaNHandler() )
{
return false;
}
bool found = false;
for( int f = 0; f < frames; ++f )
for (int f = 0; f < frames; ++f)
{
for( int c = 0; c < 2; ++c )
auto& currentFrame = src[f];
if (currentFrame.containsInf() || currentFrame.containsNaN())
{
if( std::isinf( src[f][c] ) || std::isnan( src[f][c] ) )
{
#ifdef LMMS_DEBUG
#ifdef LMMS_DEBUG
// TODO don't use printf here
printf("Bad data, clearing buffer. frame: ");
printf("%d: value %f\n", f, src[f][c]);
#endif
for( int f = 0; f < frames; ++f )
{
for( int c = 0; c < 2; ++c )
{
src[f][c] = 0.0f;
}
}
found = true;
return found;
}
else
{
src[f][c] = std::clamp(src[f][c], -1000.0f, 1000.0f);
}
printf("%d: value %f, %f\n", f, currentFrame.left(), currentFrame.right());
#endif
// Clear the whole buffer if a problem is found
zeroSampleFrames(src, frames);
return true;
}
}
return found;
else
{
currentFrame.clamp(sample_t(-1000.0), sample_t(1000.0));
}
};
return false;
}
struct AddOp
{
void operator()( sampleFrame& dst, const sampleFrame& src ) const
void operator()( SampleFrame& dst, const SampleFrame& src ) const
{
dst[0] += src[0];
dst[1] += src[1];
dst += src;
}
} ;
void add( sampleFrame* dst, const sampleFrame* src, int frames )
void add( SampleFrame* dst, const SampleFrame* src, int frames )
{
run<>( dst, src, frames, AddOp() );
}
@@ -149,17 +144,16 @@ struct AddMultipliedOp
{
AddMultipliedOp( float coeff ) : m_coeff( coeff ) { }
void operator()( sampleFrame& dst, const sampleFrame& src ) const
void operator()( SampleFrame& dst, const SampleFrame& src ) const
{
dst[0] += src[0] * m_coeff;
dst[1] += src[1] * m_coeff;
dst += src * m_coeff;
}
const float m_coeff;
} ;
void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames )
void addMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames )
{
run<>( dst, src, frames, AddMultipliedOp(coeffSrc) );
}
@@ -169,7 +163,7 @@ struct AddSwappedMultipliedOp
{
AddSwappedMultipliedOp( float coeff ) : m_coeff( coeff ) { }
void operator()( sampleFrame& dst, const sampleFrame& src ) const
void operator()( SampleFrame& dst, const SampleFrame& src ) const
{
dst[0] += src[1] * m_coeff;
dst[1] += src[0] * m_coeff;
@@ -178,22 +172,21 @@ struct AddSwappedMultipliedOp
const float m_coeff;
};
void multiply(sampleFrame* dst, float coeff, int frames)
void multiply(SampleFrame* dst, float coeff, int frames)
{
for (int i = 0; i < frames; ++i)
{
dst[i][0] *= coeff;
dst[i][1] *= coeff;
dst[i] *= coeff;
}
}
void addSwappedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames )
void addSwappedMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames )
{
run<>( dst, src, frames, AddSwappedMultipliedOp(coeffSrc) );
}
void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
void addMultipliedByBuffer( SampleFrame* dst, const SampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
{
for( int f = 0; f < frames; ++f )
{
@@ -202,7 +195,7 @@ void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coef
}
}
void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
void addMultipliedByBuffers( SampleFrame* dst, const SampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
{
for( int f = 0; f < frames; ++f )
{
@@ -212,7 +205,7 @@ void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuff
}
void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
void addSanitizedMultipliedByBuffer( SampleFrame* dst, const SampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
{
if ( !useNaNHandler() )
{
@@ -228,7 +221,7 @@ void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, f
}
}
void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
void addSanitizedMultipliedByBuffers( SampleFrame* dst, const SampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
{
if ( !useNaNHandler() )
{
@@ -254,7 +247,7 @@ struct AddSanitizedMultipliedOp
{
AddSanitizedMultipliedOp( float coeff ) : m_coeff( coeff ) { }
void operator()( sampleFrame& dst, const sampleFrame& src ) const
void operator()( SampleFrame& dst, const SampleFrame& src ) const
{
dst[0] += ( std::isinf( src[0] ) || std::isnan( src[0] ) ) ? 0.0f : src[0] * m_coeff;
dst[1] += ( std::isinf( src[1] ) || std::isnan( src[1] ) ) ? 0.0f : src[1] * m_coeff;
@@ -263,7 +256,7 @@ struct AddSanitizedMultipliedOp
const float m_coeff;
};
void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames )
void addSanitizedMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames )
{
if ( !useNaNHandler() )
{
@@ -284,7 +277,7 @@ struct AddMultipliedStereoOp
m_coeffs[1] = coeffRight;
}
void operator()( sampleFrame& dst, const sampleFrame& src ) const
void operator()( SampleFrame& dst, const SampleFrame& src ) const
{
dst[0] += src[0] * m_coeffs[0];
dst[1] += src[1] * m_coeffs[1];
@@ -294,7 +287,7 @@ struct AddMultipliedStereoOp
} ;
void addMultipliedStereo( sampleFrame* dst, const sampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames )
void addMultipliedStereo( SampleFrame* dst, const SampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames )
{
run<>( dst, src, frames, AddMultipliedStereoOp(coeffSrcLeft, coeffSrcRight) );
@@ -312,7 +305,7 @@ struct MultiplyAndAddMultipliedOp
m_coeffs[1] = coeffSrc;
}
void operator()( sampleFrame& dst, const sampleFrame& src ) const
void operator()( SampleFrame& dst, const SampleFrame& src ) const
{
dst[0] = dst[0]*m_coeffs[0] + src[0]*m_coeffs[1];
dst[1] = dst[1]*m_coeffs[0] + src[1]*m_coeffs[1];
@@ -322,14 +315,14 @@ struct MultiplyAndAddMultipliedOp
} ;
void multiplyAndAddMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffDst, float coeffSrc, int frames )
void multiplyAndAddMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffDst, float coeffSrc, int frames )
{
run<>( dst, src, frames, MultiplyAndAddMultipliedOp(coeffDst, coeffSrc) );
}
void multiplyAndAddMultipliedJoined( sampleFrame* dst,
void multiplyAndAddMultipliedJoined( SampleFrame* dst,
const sample_t* srcLeft,
const sample_t* srcRight,
float coeffDst, float coeffSrc, int frames )

View File

@@ -64,7 +64,7 @@ MixerChannel::MixerChannel( int idx, Model * _parent ) :
m_stillRunning( false ),
m_peakLeft( 0.0f ),
m_peakRight( 0.0f ),
m_buffer( new sampleFrame[Engine::audioEngine()->framesPerPeriod()] ),
m_buffer( new SampleFrame[Engine::audioEngine()->framesPerPeriod()] ),
m_muteModel( false, _parent ),
m_soloModel( false, _parent ),
m_volumeModel(1.f, 0.f, 2.f, 0.001f, _parent),
@@ -134,7 +134,7 @@ void MixerChannel::doProcessing()
ValueBuffer * volBuf = sender->m_volumeModel.valueBuffer();
// mix it's output with this one's output
sampleFrame * ch_buf = sender->m_buffer;
SampleFrame* ch_buf = sender->m_buffer;
// use sample-exact mixing if sample-exact values are available
if( ! volBuf && ! sendBuf ) // neither volume nor send has sample-exact data...
@@ -171,9 +171,9 @@ void MixerChannel::doProcessing()
m_stillRunning = m_fxChain.processAudioBuffer( m_buffer, fpp, m_hasInput );
AudioEngine::StereoSample peakSamples = Engine::audioEngine()->getPeakValues(m_buffer, fpp);
m_peakLeft = std::max(m_peakLeft, peakSamples.left * v);
m_peakRight = std::max(m_peakRight, peakSamples.right * v);
SampleFrame peakSamples = getAbsPeakValues(m_buffer, fpp);
m_peakLeft = std::max(m_peakLeft, peakSamples[0] * v);
m_peakRight = std::max(m_peakRight, peakSamples[1] * v);
}
else
{
@@ -596,7 +596,7 @@ FloatModel * Mixer::channelSendModel( mix_ch_t fromChannel, mix_ch_t toChannel )
void Mixer::mixToChannel( const sampleFrame * _buf, mix_ch_t _ch )
void Mixer::mixToChannel( const SampleFrame* _buf, mix_ch_t _ch )
{
if( m_mixerChannels[_ch]->m_muteModel.value() == false )
{
@@ -618,7 +618,7 @@ void Mixer::prepareMasterMix()
void Mixer::masterMix( sampleFrame * _buf )
void Mixer::masterMix( SampleFrame* _buf )
{
const int fpp = Engine::audioEngine()->framesPerPeriod();

View File

@@ -183,7 +183,7 @@ int NotePlayHandle::midiKey() const
void NotePlayHandle::play( sampleFrame * _working_buffer )
void NotePlayHandle::play( SampleFrame* _working_buffer )
{
if (m_muted)
{

View File

@@ -77,7 +77,7 @@ Oscillator::Oscillator(const IntModel *wave_shape_model,
void Oscillator::update(sampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator)
void Oscillator::update(SampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator)
{
if (m_freq >= Engine::audioEngine()->outputSampleRate() / 2)
{
@@ -316,7 +316,7 @@ void Oscillator::generateWaveTables()
void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateNoSub( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
switch( static_cast<WaveShape>(m_waveShapeModel->value()) )
@@ -352,7 +352,7 @@ void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updatePM( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
switch( static_cast<WaveShape>(m_waveShapeModel->value()) )
@@ -388,7 +388,7 @@ void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateAM( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
switch( static_cast<WaveShape>(m_waveShapeModel->value()) )
@@ -424,7 +424,7 @@ void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateMix( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
switch( static_cast<WaveShape>(m_waveShapeModel->value()) )
@@ -460,7 +460,7 @@ void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateSync( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
switch( static_cast<WaveShape>(m_waveShapeModel->value()) )
@@ -496,7 +496,7 @@ void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateFM( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
switch( static_cast<WaveShape>(m_waveShapeModel->value()) )
@@ -558,7 +558,7 @@ inline bool Oscillator::syncOk( float _osc_coeff )
float Oscillator::syncInit( sampleFrame * _ab, const fpp_t _frames,
float Oscillator::syncInit( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
if( m_subOsc != nullptr )
@@ -574,7 +574,7 @@ float Oscillator::syncInit( sampleFrame * _ab, const fpp_t _frames,
// if we have no sub-osc, we can't do any modulation... just get our samples
template<Oscillator::WaveShape W>
void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateNoSub( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
recalcPhase();
@@ -592,7 +592,7 @@ void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames,
// do pm by using sub-osc as modulator
template<Oscillator::WaveShape W>
void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updatePM( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
m_subOsc->update( _ab, _frames, _chnl, true );
@@ -613,7 +613,7 @@ void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames,
// do am by using sub-osc as modulator
template<Oscillator::WaveShape W>
void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateAM( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
m_subOsc->update( _ab, _frames, _chnl, false );
@@ -632,7 +632,7 @@ void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames,
// do mix by using sub-osc as mix-sample
template<Oscillator::WaveShape W>
void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateMix( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
m_subOsc->update( _ab, _frames, _chnl, false );
@@ -652,7 +652,7 @@ void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames,
// sync with sub-osc (every time sub-osc starts new period, we also start new
// period)
template<Oscillator::WaveShape W>
void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateSync( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
const float sub_osc_coeff = m_subOsc->syncInit( _ab, _frames, _chnl );
@@ -675,7 +675,7 @@ void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames,
// do fm by using sub-osc as modulator
template<Oscillator::WaveShape W>
void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames,
void Oscillator::updateFM( SampleFrame* _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
m_subOsc->update( _ab, _frames, _chnl, true );

View File

@@ -70,9 +70,9 @@ void PlayHandle::releaseBuffer()
m_bufferReleased = true;
}
sampleFrame* PlayHandle::buffer()
SampleFrame* PlayHandle::buffer()
{
return m_bufferReleased ? nullptr : reinterpret_cast<sampleFrame*>(m_playHandleBuffer);
return m_bufferReleased ? nullptr : m_playHandleBuffer;
};
} // namespace lmms

View File

@@ -206,7 +206,7 @@ PresetPreviewPlayHandle::~PresetPreviewPlayHandle()
void PresetPreviewPlayHandle::play( sampleFrame * _working_buffer )
void PresetPreviewPlayHandle::play( SampleFrame* _working_buffer )
{
// Do nothing; the preview instrument is played by m_previewNote, which
// has been added to the audio engine

View File

@@ -325,7 +325,7 @@ bool RemotePlugin::init(const QString &pluginExecutable,
bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf )
bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf )
{
const fpp_t frames = Engine::audioEngine()->framesPerPeriod();
@@ -376,11 +376,12 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf
}
else if( inputs == DEFAULT_CHANNELS )
{
memcpy( m_audioBuffer.get(), _in_buf, frames * BYTES_PER_FRAME );
auto target = m_audioBuffer.get();
copyFromSampleFrames(target, _in_buf, frames);
}
else
{
auto o = (sampleFrame*)m_audioBuffer.get();
auto o = (SampleFrame*)m_audioBuffer.get();
for( ch_cnt_t ch = 0; ch < inputs; ++ch )
{
for( fpp_t frame = 0; frame < frames; ++frame )
@@ -418,12 +419,12 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf
}
else if( outputs == DEFAULT_CHANNELS )
{
memcpy( _out_buf, m_audioBuffer.get() + m_inputCount * frames,
frames * BYTES_PER_FRAME );
auto source = m_audioBuffer.get() + m_inputCount * frames;
copyToSampleFrames(_out_buf, source, frames);
}
else
{
auto o = (sampleFrame*)(m_audioBuffer.get() + m_inputCount * frames);
auto o = (SampleFrame*)(m_audioBuffer.get() + m_inputCount * frames);
// clear buffer, if plugin didn't fill up both channels
BufferManager::clear( _out_buf, frames );

View File

@@ -37,8 +37,8 @@ RingBuffer::RingBuffer( f_cnt_t size ) :
m_samplerate( Engine::audioEngine()->outputSampleRate() ),
m_size( size + m_fpp )
{
m_buffer = new sampleFrame[ m_size ];
memset( m_buffer, 0, m_size * sizeof( sampleFrame ) );
m_buffer = new SampleFrame[ m_size ];
zeroSampleFrames(m_buffer, m_size);
m_position = 0;
}
@@ -48,8 +48,8 @@ RingBuffer::RingBuffer( float size ) :
m_samplerate( Engine::audioEngine()->outputSampleRate() )
{
m_size = msToFrames( size ) + m_fpp;
m_buffer = new sampleFrame[ m_size ];
memset( m_buffer, 0, m_size * sizeof( sampleFrame ) );
m_buffer = new SampleFrame[ m_size ];
zeroSampleFrames(m_buffer, m_size);
m_position = 0;
setSamplerateAware( true );
//qDebug( "m_size %d, m_position %d", m_size, m_position );
@@ -64,7 +64,7 @@ RingBuffer::~RingBuffer()
void RingBuffer::reset()
{
memset( m_buffer, 0, m_size * sizeof( sampleFrame ) );
zeroSampleFrames(m_buffer, m_size);
m_position = 0;
}
@@ -72,10 +72,10 @@ void RingBuffer::reset()
void RingBuffer::changeSize( f_cnt_t size )
{
size += m_fpp;
sampleFrame * tmp = m_buffer;
SampleFrame* tmp = m_buffer;
m_size = size;
m_buffer = new sampleFrame[ m_size ];
memset( m_buffer, 0, m_size * sizeof( sampleFrame ) );
m_buffer = new SampleFrame[ m_size ];
zeroSampleFrames(m_buffer, m_size);
m_position = 0;
delete[] tmp;
}
@@ -118,111 +118,111 @@ void RingBuffer::movePosition( float amount )
}
void RingBuffer::pop( sampleFrame * dst )
void RingBuffer::pop( SampleFrame* dst )
{
if( m_position + m_fpp <= m_size ) // we won't go over the edge so we can just memcpy here
{
memcpy( dst, & m_buffer [ m_position ], m_fpp * sizeof( sampleFrame ) );
memset( & m_buffer[m_position], 0, m_fpp * sizeof( sampleFrame ) );
memcpy( dst, & m_buffer [ m_position ], m_fpp * sizeof( SampleFrame ) );
zeroSampleFrames(&m_buffer[m_position], m_fpp);
}
else
{
f_cnt_t first = m_size - m_position;
f_cnt_t second = m_fpp - first;
memcpy( dst, & m_buffer [ m_position ], first * sizeof( sampleFrame ) );
memset( & m_buffer [m_position], 0, first * sizeof( sampleFrame ) );
memcpy( dst, & m_buffer [ m_position ], first * sizeof( SampleFrame ) );
zeroSampleFrames(&m_buffer[m_position], first);
memcpy( & dst [first], m_buffer, second * sizeof( sampleFrame ) );
memset( m_buffer, 0, second * sizeof( sampleFrame ) );
memcpy( & dst [first], m_buffer, second * sizeof( SampleFrame ) );
zeroSampleFrames(m_buffer, second);
}
m_position = ( m_position + m_fpp ) % m_size;
}
void RingBuffer::read( sampleFrame * dst, f_cnt_t offset )
void RingBuffer::read( SampleFrame* dst, f_cnt_t offset )
{
f_cnt_t pos = ( m_position + offset ) % m_size;
if( pos < 0 ) { pos += m_size; }
if( pos + m_fpp <= m_size ) // we won't go over the edge so we can just memcpy here
{
memcpy( dst, & m_buffer [pos], m_fpp * sizeof( sampleFrame ) );
memcpy( dst, & m_buffer [pos], m_fpp * sizeof( SampleFrame ) );
}
else
{
f_cnt_t first = m_size - pos;
f_cnt_t second = m_fpp - first;
memcpy( dst, & m_buffer [pos], first * sizeof( sampleFrame ) );
memcpy( dst, & m_buffer [pos], first * sizeof( SampleFrame ) );
memcpy( & dst [first], m_buffer, second * sizeof( sampleFrame ) );
memcpy( & dst [first], m_buffer, second * sizeof( SampleFrame ) );
}
}
void RingBuffer::read( sampleFrame * dst, float offset )
void RingBuffer::read( SampleFrame* dst, float offset )
{
read( dst, msToFrames( offset ) );
}
void RingBuffer::read( sampleFrame * dst, f_cnt_t offset, f_cnt_t length )
void RingBuffer::read( SampleFrame* dst, f_cnt_t offset, f_cnt_t length )
{
f_cnt_t pos = ( m_position + offset ) % m_size;
if( pos < 0 ) { pos += m_size; }
if( pos + length <= m_size ) // we won't go over the edge so we can just memcpy here
{
memcpy( dst, & m_buffer [pos], length * sizeof( sampleFrame ) );
memcpy( dst, & m_buffer [pos], length * sizeof( SampleFrame ) );
}
else
{
f_cnt_t first = m_size - pos;
f_cnt_t second = length - first;
memcpy( dst, & m_buffer [pos], first * sizeof( sampleFrame ) );
memcpy( dst, & m_buffer [pos], first * sizeof( SampleFrame ) );
memcpy( & dst [first], m_buffer, second * sizeof( sampleFrame ) );
memcpy( & dst [first], m_buffer, second * sizeof( SampleFrame ) );
}
}
void RingBuffer::read( sampleFrame * dst, float offset, f_cnt_t length )
void RingBuffer::read( SampleFrame* dst, float offset, f_cnt_t length )
{
read( dst, msToFrames( offset ), length );
}
void RingBuffer::write( sampleFrame * src, f_cnt_t offset, f_cnt_t length )
void RingBuffer::write( SampleFrame* src, f_cnt_t offset, f_cnt_t length )
{
const f_cnt_t pos = ( m_position + offset ) % m_size;
if( length == 0 ) { length = m_fpp; }
if( pos + length <= m_size ) // we won't go over the edge so we can just memcpy here
{
memcpy( & m_buffer [pos], src, length * sizeof( sampleFrame ) );
memcpy( & m_buffer [pos], src, length * sizeof( SampleFrame ) );
}
else
{
f_cnt_t first = m_size - pos;
f_cnt_t second = length - first;
memcpy( & m_buffer [pos], src, first * sizeof( sampleFrame ) );
memcpy( & m_buffer [pos], src, first * sizeof( SampleFrame ) );
memcpy( m_buffer, & src [first], second * sizeof( sampleFrame ) );
memcpy( m_buffer, & src [first], second * sizeof( SampleFrame ) );
}
}
void RingBuffer::write( sampleFrame * src, float offset, f_cnt_t length )
void RingBuffer::write( SampleFrame* src, float offset, f_cnt_t length )
{
write( src, msToFrames( offset ), length );
}
void RingBuffer::writeAdding( sampleFrame * src, f_cnt_t offset, f_cnt_t length )
void RingBuffer::writeAdding( SampleFrame* src, f_cnt_t offset, f_cnt_t length )
{
const f_cnt_t pos = ( m_position + offset ) % m_size;
if( length == 0 ) { length = m_fpp; }
@@ -243,13 +243,13 @@ void RingBuffer::writeAdding( sampleFrame * src, f_cnt_t offset, f_cnt_t length
}
void RingBuffer::writeAdding( sampleFrame * src, float offset, f_cnt_t length )
void RingBuffer::writeAdding( SampleFrame* src, float offset, f_cnt_t length )
{
writeAdding( src, msToFrames( offset ), length );
}
void RingBuffer::writeAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt_t length, float level )
void RingBuffer::writeAddingMultiplied( SampleFrame* src, f_cnt_t offset, f_cnt_t length, float level )
{
const f_cnt_t pos = ( m_position + offset ) % m_size;
//qDebug( "pos %d m_pos %d ofs %d siz %d", pos, m_position, offset, m_size );
@@ -271,14 +271,14 @@ void RingBuffer::writeAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt
}
void RingBuffer::writeAddingMultiplied( sampleFrame * src, float offset, f_cnt_t length, float level )
void RingBuffer::writeAddingMultiplied( SampleFrame* src, float offset, f_cnt_t length, float level )
{
f_cnt_t ofs = msToFrames( offset );
writeAddingMultiplied( src, ofs, length, level );
}
void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt_t length, float level )
void RingBuffer::writeSwappedAddingMultiplied( SampleFrame* src, f_cnt_t offset, f_cnt_t length, float level )
{
const f_cnt_t pos = ( m_position + offset ) % m_size;
if( length == 0 ) { length = m_fpp; }
@@ -299,7 +299,7 @@ void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, f_cnt_t offset
}
void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, float offset, f_cnt_t length, float level )
void RingBuffer::writeSwappedAddingMultiplied( SampleFrame* src, float offset, f_cnt_t length, float level )
{
writeSwappedAddingMultiplied( src, msToFrames( offset ), length, level );
}
@@ -311,8 +311,8 @@ void RingBuffer::updateSamplerate()
m_size = static_cast<f_cnt_t>( ceilf( newsize ) ) + m_fpp;
m_samplerate = Engine::audioEngine()->outputSampleRate();
delete[] m_buffer;
m_buffer = new sampleFrame[ m_size ];
memset( m_buffer, 0, m_size * sizeof( sampleFrame ) );
m_buffer = new SampleFrame[ m_size ];
zeroSampleFrames(m_buffer, m_size);
m_position = 0;
}

View File

@@ -46,7 +46,7 @@ Sample::Sample(const QByteArray& base64, int sampleRate)
{
}
Sample::Sample(const sampleFrame* data, size_t numFrames, int sampleRate)
Sample::Sample(const SampleFrame* data, size_t numFrames, int sampleRate)
: m_buffer(std::make_shared<SampleBuffer>(data, numFrames, sampleRate))
, m_startFrame(0)
, m_endFrame(m_buffer->size())
@@ -116,7 +116,7 @@ auto Sample::operator=(Sample&& other) -> Sample&
return *this;
}
bool Sample::play(sampleFrame* dst, PlaybackState* state, size_t numFrames, float desiredFrequency, Loop loopMode) const
bool Sample::play(SampleFrame* dst, PlaybackState* state, size_t numFrames, float desiredFrequency, Loop loopMode) const
{
assert(numFrames > 0);
assert(desiredFrequency > 0);
@@ -131,7 +131,7 @@ bool Sample::play(sampleFrame* dst, PlaybackState* state, size_t numFrames, floa
state->m_frameIndex = std::max<int>(m_startFrame, state->m_frameIndex);
auto playBuffer = std::vector<sampleFrame>(numFrames / resampleRatio + marginSize);
auto playBuffer = std::vector<SampleFrame>(numFrames / resampleRatio + marginSize);
playRaw(playBuffer.data(), playBuffer.size(), state, loopMode);
state->resampler().setRatio(resampleRatio);
@@ -141,7 +141,7 @@ bool Sample::play(sampleFrame* dst, PlaybackState* state, size_t numFrames, floa
advance(state, resampleResult.inputFramesUsed, loopMode);
const auto outputFrames = resampleResult.outputFramesGenerated;
if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, sampleFrame{}); }
if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, SampleFrame{}); }
if (!typeInfo<float>::isEqual(m_amplification, 1.0f))
{
@@ -170,7 +170,7 @@ void Sample::setAllPointFrames(int startFrame, int endFrame, int loopStartFrame,
setLoopEndFrame(loopEndFrame);
}
void Sample::playRaw(sampleFrame* dst, size_t numFrames, const PlaybackState* state, Loop loopMode) const
void Sample::playRaw(SampleFrame* dst, size_t numFrames, const PlaybackState* state, Loop loopMode) const
{
if (m_buffer->size() < 1) { return; }

View File

@@ -31,7 +31,7 @@
namespace lmms {
SampleBuffer::SampleBuffer(const sampleFrame* data, size_t numFrames, int sampleRate)
SampleBuffer::SampleBuffer(const SampleFrame* data, size_t numFrames, int sampleRate)
: m_data(data, data + numFrames)
, m_sampleRate(sampleRate)
{
@@ -60,11 +60,11 @@ SampleBuffer::SampleBuffer(const QString& base64, int sampleRate)
{
// TODO: Replace with non-Qt equivalent
const auto bytes = QByteArray::fromBase64(base64.toUtf8());
m_data.resize(bytes.size() / sizeof(sampleFrame));
std::memcpy(reinterpret_cast<char*>(m_data.data()), bytes, m_data.size() * sizeof(sampleFrame));
m_data.resize(bytes.size() / sizeof(SampleFrame));
std::memcpy(reinterpret_cast<char*>(m_data.data()), bytes, m_data.size() * sizeof(SampleFrame));
}
SampleBuffer::SampleBuffer(std::vector<sampleFrame> data, int sampleRate)
SampleBuffer::SampleBuffer(std::vector<SampleFrame> data, int sampleRate)
: m_data(std::move(data))
, m_sampleRate(sampleRate)
{
@@ -82,7 +82,7 @@ QString SampleBuffer::toBase64() const
{
// TODO: Replace with non-Qt equivalent
const auto data = reinterpret_cast<const char*>(m_data.data());
const auto size = static_cast<int>(m_data.size() * sizeof(sampleFrame));
const auto size = static_cast<int>(m_data.size() * sizeof(SampleFrame));
const auto byteArray = QByteArray{data, size};
return byteArray.toBase64();
}

View File

@@ -75,7 +75,7 @@ auto decodeSampleSF(const QString& audioFile) -> std::optional<SampleDecoder::Re
sf_close(sndFile);
file.close();
auto result = std::vector<sampleFrame>(sfInfo.frames);
auto result = std::vector<SampleFrame>(sfInfo.frames);
for (int i = 0; i < static_cast<int>(result.size()); ++i)
{
if (sfInfo.channels == 1)
@@ -107,7 +107,7 @@ auto decodeSampleDS(const QString& audioFile) -> std::optional<SampleDecoder::Re
if (frames <= 0 || !data) { return std::nullopt; }
auto result = std::vector<sampleFrame>(frames);
auto result = std::vector<SampleFrame>(frames);
src_short_to_float_array(data.get(), &result[0][0], frames * DEFAULT_CHANNELS);
return SampleDecoder::Result{std::move(result), static_cast<int>(engineRate)};
@@ -173,7 +173,7 @@ auto decodeSampleOggVorbis(const QString& audioFile) -> std::optional<SampleDeco
totalSamplesRead += samplesRead;
}
auto result = std::vector<sampleFrame>(totalSamplesRead / numChannels);
auto result = std::vector<SampleFrame>(totalSamplesRead / numChannels);
for (int i = 0; i < result.size(); ++i)
{
if (numChannels == 1) { result[i] = {buffer[i], buffer[i]}; }

View File

@@ -85,23 +85,23 @@ SamplePlayHandle::~SamplePlayHandle()
void SamplePlayHandle::play( sampleFrame * buffer )
void SamplePlayHandle::play( SampleFrame* buffer )
{
const fpp_t fpp = Engine::audioEngine()->framesPerPeriod();
//play( 0, _try_parallelizing );
if( framesDone() >= totalFrames() )
{
memset( buffer, 0, sizeof( sampleFrame ) * fpp );
zeroSampleFrames(buffer, fpp);
return;
}
sampleFrame * workingBuffer = buffer;
SampleFrame* workingBuffer = buffer;
f_cnt_t frames = fpp;
// apply offset for the first period
if( framesDone() == 0 )
{
memset( buffer, 0, sizeof( sampleFrame ) * offset() );
zeroSampleFrames(buffer, offset());
workingBuffer += offset();
frames -= offset();
}
@@ -116,7 +116,7 @@ void SamplePlayHandle::play( sampleFrame * buffer )
// it is used only for previews, SampleTracks and the metronome.
if (!m_sample->play(workingBuffer, &m_state, frames, DefaultBaseFreq))
{
memset(workingBuffer, 0, frames * sizeof(sampleFrame));
zeroSampleFrames(workingBuffer, frames);
}
}

View File

@@ -64,9 +64,9 @@ SampleRecordHandle::~SampleRecordHandle()
void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ )
void SampleRecordHandle::play( SampleFrame* /*_working_buffer*/ )
{
const sampleFrame * recbuf = Engine::audioEngine()->inputBuffer();
const SampleFrame* recbuf = Engine::audioEngine()->inputBuffer();
const f_cnt_t frames = Engine::audioEngine()->inputBufferFrames();
writeBuffer( recbuf, frames );
m_framesRecorded += frames;
@@ -110,7 +110,7 @@ std::shared_ptr<const SampleBuffer> SampleRecordHandle::createSampleBuffer()
{
const f_cnt_t frames = framesRecorded();
// create buffer to store all recorded buffers in
auto bigBuffer = std::vector<sampleFrame>(frames);
auto bigBuffer = std::vector<SampleFrame>(frames);
// now copy all buffers into big buffer
auto framesCopied = 0;
@@ -127,9 +127,9 @@ std::shared_ptr<const SampleBuffer> SampleRecordHandle::createSampleBuffer()
void SampleRecordHandle::writeBuffer( const sampleFrame * _ab, const f_cnt_t _frames )
void SampleRecordHandle::writeBuffer( const SampleFrame* _ab, const f_cnt_t _frames )
{
auto buf = new sampleFrame[_frames];
auto buf = new SampleFrame[_frames];
for( f_cnt_t frame = 0; frame < _frames; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )

View File

@@ -39,7 +39,7 @@ AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) :
AudioDevice(std::clamp<ch_cnt_t>(
ConfigManager::inst()->value("audioalsa", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS), _audioEngine),
DEFAULT_CHANNELS), _audioEngine),
m_handle( nullptr ),
m_hwParams( nullptr ),
m_swParams( nullptr ),
@@ -242,7 +242,7 @@ void AudioAlsa::stopProcessing()
void AudioAlsa::run()
{
auto temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()];
auto temp = new SampleFrame[audioEngine()->framesPerPeriod()];
auto outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()];
auto pcmbuf = new int_sample_t[m_periodSize * channels()];

View File

@@ -37,7 +37,7 @@ AudioDevice::AudioDevice( const ch_cnt_t _channels, AudioEngine* _audioEngine )
m_sampleRate( _audioEngine->outputSampleRate() ),
m_channels( _channels ),
m_audioEngine( _audioEngine ),
m_buffer( new surroundSampleFrame[audioEngine()->framesPerPeriod()] )
m_buffer(new SampleFrame[audioEngine()->framesPerPeriod()])
{
}
@@ -64,14 +64,14 @@ void AudioDevice::processNextBuffer()
}
}
fpp_t AudioDevice::getNextBuffer(surroundSampleFrame* _ab)
fpp_t AudioDevice::getNextBuffer(SampleFrame* _ab)
{
fpp_t frames = audioEngine()->framesPerPeriod();
const SampleFrame* b = audioEngine()->nextBuffer();
const surroundSampleFrame* b = audioEngine()->nextBuffer();
if (!b) { return 0; }
memcpy(_ab, b, frames * sizeof(surroundSampleFrame));
memcpy(_ab, b, frames * sizeof(SampleFrame));
if (audioEngine()->hasFifoWriter()) { delete[] b; }
return frames;
@@ -127,7 +127,7 @@ void AudioDevice::renamePort( AudioPort * )
{
}
int AudioDevice::convertToS16( const surroundSampleFrame * _ab,
int AudioDevice::convertToS16(const SampleFrame* _ab,
const fpp_t _frames,
int_sample_t * _output_buffer,
const bool _convert_endian )

View File

@@ -89,7 +89,7 @@ bool AudioFileFlac::startEncoding()
return true;
}
void AudioFileFlac::writeBuffer(surroundSampleFrame const* _ab, fpp_t const frames)
void AudioFileFlac::writeBuffer(const SampleFrame* _ab, fpp_t const frames)
{
OutputSettings::BitDepth depth = getOutputSettings().getBitDepth();
float clipvalue = std::nextafterf( -1.0f, 0.0f );

View File

@@ -25,6 +25,8 @@
#include "AudioFileMP3.h"
#include "SampleFrame.h"
#ifdef LMMS_HAVE_MP3LAME
@@ -53,7 +55,7 @@ AudioFileMP3::~AudioFileMP3()
tearDownEncoder();
}
void AudioFileMP3::writeBuffer(const surroundSampleFrame* _buf, const fpp_t _frames)
void AudioFileMP3::writeBuffer(const SampleFrame* _buf, const fpp_t _frames)
{
if (_frames < 1)
{

View File

@@ -179,7 +179,7 @@ bool AudioFileOgg::startEncoding()
return true;
}
void AudioFileOgg::writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames)
void AudioFileOgg::writeBuffer(const SampleFrame* _ab, const fpp_t _frames)
{
int eos = 0;

View File

@@ -93,7 +93,7 @@ bool AudioFileWave::startEncoding()
return true;
}
void AudioFileWave::writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames)
void AudioFileWave::writeBuffer(const SampleFrame* _ab, const fpp_t _frames)
{
OutputSettings::BitDepth bitDepth = getOutputSettings().getBitDepth();

View File

@@ -48,7 +48,7 @@ AudioJack::AudioJack(bool& successful, AudioEngine* audioEngineParam)
std::clamp<int>(
ConfigManager::inst()->value("audiojack", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS
DEFAULT_CHANNELS
),
// clang-format on
audioEngineParam)
@@ -56,7 +56,7 @@ AudioJack::AudioJack(bool& successful, AudioEngine* audioEngineParam)
, m_active(false)
, m_midiClient(nullptr)
, m_tempOutBufs(new jack_default_audio_sample_t*[channels()])
, m_outBuf(new surroundSampleFrame[audioEngine()->framesPerPeriod()])
, m_outBuf(new SampleFrame[audioEngine()->framesPerPeriod()])
, m_framesDoneInCurBuf(0)
, m_framesToDoInCurBuf(0)
{
@@ -392,7 +392,7 @@ AudioJack::setupWidget::setupWidget(QWidget* parent)
form->addRow(tr("Client name"), m_clientName);
auto m = new gui::LcdSpinBoxModel(/* this */);
m->setRange(DEFAULT_CHANNELS, SURROUND_CHANNELS);
m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS);
m->setStep(2);
m->setValue(ConfigManager::inst()->value("audiojack", "channels").toInt());

View File

@@ -72,7 +72,7 @@ AudioOss::AudioOss( bool & _success_ful, AudioEngine* _audioEngine ) :
AudioDevice(std::clamp<ch_cnt_t>(
ConfigManager::inst()->value("audiooss", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS), _audioEngine),
DEFAULT_CHANNELS), _audioEngine),
m_convertEndian( false )
{
_success_ful = false;
@@ -256,7 +256,7 @@ void AudioOss::stopProcessing()
void AudioOss::run()
{
auto temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()];
auto temp = new SampleFrame[audioEngine()->framesPerPeriod()];
auto outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()];
while( true )
@@ -291,7 +291,7 @@ AudioOss::setupWidget::setupWidget( QWidget * _parent ) :
form->addRow(tr("Device"), m_device);
auto m = new gui::LcdSpinBoxModel(/* this */);
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS);
m->setStep( 2 );
m->setValue( ConfigManager::inst()->value( "audiooss",
"channels" ).toInt() );

View File

@@ -64,10 +64,10 @@ AudioPortAudio::AudioPortAudio( bool & _success_ful, AudioEngine * _audioEngine
AudioDevice(std::clamp<ch_cnt_t>(
ConfigManager::inst()->value("audioportaudio", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS), _audioEngine),
DEFAULT_CHANNELS), _audioEngine),
m_paStream( nullptr ),
m_wasPAInitError( false ),
m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ),
m_outBuf(new SampleFrame[audioEngine()->framesPerPeriod()]),
m_outBufPos( 0 )
{
_success_ful = false;
@@ -236,7 +236,7 @@ int AudioPortAudio::process_callback(
{
if( supportsCapture() )
{
audioEngine()->pushInputFrames( (sampleFrame*)_inputBuffer, _framesPerBuffer );
audioEngine()->pushInputFrames( (SampleFrame*)_inputBuffer, _framesPerBuffer );
}
if( m_stopped )
@@ -387,7 +387,7 @@ AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) :
form->addRow(tr("Device"), m_device);
/* LcdSpinBoxModel * m = new LcdSpinBoxModel( );
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
m->setRange( DEFAULT_CHANNELS, DEFAULT_CHANNELS );
m->setStep( 2 );
m->setValue( ConfigManager::inst()->value( "audioportaudio",
"channels" ).toInt() );

View File

@@ -49,7 +49,7 @@ AudioPulseAudio::AudioPulseAudio( bool & _success_ful, AudioEngine* _audioEngin
AudioDevice(std::clamp<ch_cnt_t>(
ConfigManager::inst()->value("audiopa", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS), _audioEngine),
DEFAULT_CHANNELS), _audioEngine),
m_s( nullptr ),
m_quit( false ),
m_convertEndian( false )
@@ -230,7 +230,7 @@ void AudioPulseAudio::run()
else
{
const fpp_t fpp = audioEngine()->framesPerPeriod();
auto temp = new surroundSampleFrame[fpp];
auto temp = new SampleFrame[fpp];
while( getNextBuffer( temp ) )
{
}
@@ -249,7 +249,7 @@ void AudioPulseAudio::run()
void AudioPulseAudio::streamWriteCallback( pa_stream *s, size_t length )
{
const fpp_t fpp = audioEngine()->framesPerPeriod();
auto temp = new surroundSampleFrame[fpp];
auto temp = new SampleFrame[fpp];
auto pcmbuf = (int_sample_t*)pa_xmalloc(fpp * channels() * sizeof(int_sample_t));
size_t fd = 0;
@@ -298,7 +298,7 @@ AudioPulseAudio::setupWidget::setupWidget( QWidget * _parent ) :
form->addRow(tr("Device"), m_device);
auto m = new gui::LcdSpinBoxModel();
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS);
m->setStep( 2 );
m->setValue( ConfigManager::inst()->value( "audiopa",
"channels" ).toInt() );

View File

@@ -71,7 +71,7 @@ std::shared_ptr<const SampleBuffer> AudioSampleRecorder::createSampleBuffer()
{
const f_cnt_t frames = framesRecorded();
// create buffer to store all recorded buffers in
auto bigBuffer = std::vector<sampleFrame>(frames);
auto bigBuffer = std::vector<SampleFrame>(frames);
// now copy all buffers into big buffer
auto framesCopied = 0;
@@ -85,9 +85,9 @@ std::shared_ptr<const SampleBuffer> AudioSampleRecorder::createSampleBuffer()
return std::make_shared<const SampleBuffer>(std::move(bigBuffer), sampleRate());
}
void AudioSampleRecorder::writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames)
void AudioSampleRecorder::writeBuffer(const SampleFrame* _ab, const fpp_t _frames)
{
auto buf = new sampleFrame[_frames];
auto buf = new SampleFrame[_frames];
for( fpp_t frame = 0; frame < _frames; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )

View File

@@ -38,7 +38,7 @@ namespace lmms
AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
AudioDevice( DEFAULT_CHANNELS, _audioEngine ),
m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] )
m_outBuf(new SampleFrame[audioEngine()->framesPerPeriod()])
{
_success_ful = false;
@@ -225,13 +225,13 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len )
m_currentBufferFramesCount = frames;
}
const uint min_frames_count = std::min(_len/sizeof(sampleFrame),
const uint min_frames_count = std::min(_len/sizeof(SampleFrame),
m_currentBufferFramesCount
- m_currentBufferFramePos);
memcpy( _buf, m_outBuf + m_currentBufferFramePos, min_frames_count*sizeof(sampleFrame) );
_buf += min_frames_count*sizeof(sampleFrame);
_len -= min_frames_count*sizeof(sampleFrame);
memcpy( _buf, m_outBuf + m_currentBufferFramePos, min_frames_count*sizeof(SampleFrame) );
_buf += min_frames_count*sizeof(SampleFrame);
_len -= min_frames_count*sizeof(SampleFrame);
m_currentBufferFramePos += min_frames_count;
m_currentBufferFramePos %= m_currentBufferFramesCount;
@@ -274,8 +274,8 @@ void AudioSdl::sdlInputAudioCallback(void *_udata, Uint8 *_buf, int _len) {
}
void AudioSdl::sdlInputAudioCallback(Uint8 *_buf, int _len) {
auto samples_buffer = (sampleFrame*)_buf;
fpp_t frames = _len / sizeof ( sampleFrame );
auto samples_buffer = (SampleFrame*)_buf;
fpp_t frames = _len / sizeof ( SampleFrame );
audioEngine()->pushInputFrames (samples_buffer, frames);
}

View File

@@ -46,7 +46,7 @@ AudioSndio::AudioSndio(bool & _success_ful, AudioEngine * _audioEngine) :
AudioDevice(std::clamp<ch_cnt_t>(
ConfigManager::inst()->value("audiosndio", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS), _audioEngine),
DEFAULT_CHANNELS), _audioEngine),
m_convertEndian ( false )
{
_success_ful = false;
@@ -141,7 +141,7 @@ void AudioSndio::stopProcessing()
void AudioSndio::run()
{
surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()];
SampleFrame* temp = new SampleFrame[audioEngine()->framesPerPeriod()];
int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()];
while( true )
@@ -173,7 +173,7 @@ AudioSndio::setupWidget::setupWidget( QWidget * _parent ) :
form->addRow(tr("Device"), m_device);
gui::LcdSpinBoxModel * m = new gui::LcdSpinBoxModel( /* this */ );
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS);
m->setStep( 2 );
m->setValue( ConfigManager::inst()->value( "audiosndio",
"channels" ).toInt() );

View File

@@ -42,7 +42,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) :
AudioDevice(std::clamp<ch_cnt_t>(
ConfigManager::inst()->value("audiosoundio", "channels").toInt(),
DEFAULT_CHANNELS,
SURROUND_CHANNELS), _audioEngine)
DEFAULT_CHANNELS), _audioEngine)
{
outSuccessful = false;
m_soundio = nullptr;
@@ -213,7 +213,7 @@ void AudioSoundIo::startProcessing()
m_outBufFramesTotal = 0;
m_outBufSize = audioEngine()->framesPerPeriod();
m_outBuf = new surroundSampleFrame[m_outBufSize];
m_outBuf = new SampleFrame[m_outBufSize];
if (! m_outstreamStarted)
{

View File

@@ -137,7 +137,7 @@ void Lv2ControlBase::copyModelsToLmms() const
void Lv2ControlBase::copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames) {
void Lv2ControlBase::copyBuffersFromLmms(const SampleFrame* buf, fpp_t frames) {
unsigned firstChan = 0; // tell the procs which channels they shall read from
for (const auto& c : m_procs)
{
@@ -149,7 +149,7 @@ void Lv2ControlBase::copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames) {
void Lv2ControlBase::copyBuffersToLmms(sampleFrame *buf, fpp_t frames) const {
void Lv2ControlBase::copyBuffersToLmms(SampleFrame* buf, fpp_t frames) const {
unsigned firstChan = 0; // tell the procs which channels they shall write to
for (const auto& c : m_procs) {
c->copyBuffersToCore(buf, firstChan, m_channelsPerProc, frames);

View File

@@ -34,6 +34,7 @@
#include "Lv2Basics.h"
#include "Lv2Manager.h"
#include "Lv2Evbuf.h"
#include "SampleFrame.h"
namespace lmms::Lv2Ports
@@ -311,7 +312,7 @@ Audio::Audio(std::size_t bufferSize, bool isSidechain)
void Audio::copyBuffersFromCore(const sampleFrame *lmmsBuf,
void Audio::copyBuffersFromCore(const SampleFrame* lmmsBuf,
unsigned channel, fpp_t frames)
{
for (std::size_t f = 0; f < static_cast<unsigned>(frames); ++f)
@@ -323,7 +324,7 @@ void Audio::copyBuffersFromCore(const sampleFrame *lmmsBuf,
void Audio::averageWithBuffersFromCore(const sampleFrame *lmmsBuf,
void Audio::averageWithBuffersFromCore(const SampleFrame* lmmsBuf,
unsigned channel, fpp_t frames)
{
for (std::size_t f = 0; f < static_cast<unsigned>(frames); ++f)
@@ -335,7 +336,7 @@ void Audio::averageWithBuffersFromCore(const sampleFrame *lmmsBuf,
void Audio::copyBuffersToCore(sampleFrame *lmmsBuf,
void Audio::copyBuffersToCore(SampleFrame* lmmsBuf,
unsigned channel, fpp_t frames) const
{
for (std::size_t f = 0; f < static_cast<unsigned>(frames); ++f)

View File

@@ -324,7 +324,7 @@ void Lv2Proc::copyModelsToCore()
void Lv2Proc::copyBuffersFromCore(const sampleFrame *buf,
void Lv2Proc::copyBuffersFromCore(const SampleFrame* buf,
unsigned firstChan, unsigned num,
fpp_t frames)
{
@@ -349,7 +349,7 @@ void Lv2Proc::copyBuffersFromCore(const sampleFrame *buf,
void Lv2Proc::copyBuffersToCore(sampleFrame* buf,
void Lv2Proc::copyBuffersToCore(SampleFrame* buf,
unsigned firstChan, unsigned num,
fpp_t frames) const
{

View File

@@ -70,7 +70,7 @@ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) :
form->addRow(tr("Device"), m_deviceComboBox);
auto m = new LcdSpinBoxModel(/* this */);
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS);
m->setStep( 2 );
m->setValue( ConfigManager::inst()->value( "audioalsa",
"channels" ).toInt() );

View File

@@ -59,7 +59,7 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q
const int frameIndex = !parameters.reversed ? i : maxFrames - i;
const auto& frame = parameters.buffer[frameIndex];
const float value = std::accumulate(frame.begin(), frame.end(), 0.0f) / frame.size();
const auto value = frame.average();
if (value > max[pixelIndex]) { max[pixelIndex] = value; }
if (value < min[pixelIndex]) { min[pixelIndex] = value; }

View File

@@ -55,7 +55,7 @@ Oscilloscope::Oscilloscope( QWidget * _p ) :
setActive( ConfigManager::inst()->value( "ui", "displaywaveform").toInt() );
const fpp_t frames = Engine::audioEngine()->framesPerPeriod();
m_buffer = new sampleFrame[frames];
m_buffer = new SampleFrame[frames];
BufferManager::clear( m_buffer, frames );
@@ -75,12 +75,12 @@ Oscilloscope::~Oscilloscope()
void Oscilloscope::updateAudioBuffer( const surroundSampleFrame * buffer )
void Oscilloscope::updateAudioBuffer(const SampleFrame* buffer)
{
if( !Engine::getSong()->isExporting() )
{
const fpp_t fpp = Engine::audioEngine()->framesPerPeriod();
memcpy( m_buffer, buffer, sizeof( surroundSampleFrame ) * fpp );
memcpy(m_buffer, buffer, sizeof(SampleFrame) * fpp);
}
}
@@ -96,8 +96,8 @@ void Oscilloscope::setActive( bool _active )
SIGNAL(periodicUpdate()),
this, SLOT(update()));
connect( Engine::audioEngine(),
SIGNAL(nextAudioBuffer(const lmms::surroundSampleFrame*)),
this, SLOT(updateAudioBuffer(const lmms::surroundSampleFrame*)) );
SIGNAL(nextAudioBuffer(const lmms::SampleFrame*)),
this, SLOT(updateAudioBuffer(const lmms::SampleFrame*)));
}
else
{
@@ -105,8 +105,8 @@ void Oscilloscope::setActive( bool _active )
SIGNAL(periodicUpdate()),
this, SLOT(update()));
disconnect( Engine::audioEngine(),
SIGNAL( nextAudioBuffer( const lmms::surroundSampleFrame* ) ),
this, SLOT( updateAudioBuffer( const lmms::surroundSampleFrame* ) ) );
SIGNAL(nextAudioBuffer(const lmms::SampleFrame*)),
this, SLOT(updateAudioBuffer(const lmms::SampleFrame*)));
// we have to update (remove last waves),
// because timer doesn't do that anymore
update();
@@ -168,10 +168,10 @@ void Oscilloscope::paintEvent( QPaintEvent * )
float masterOutput = audioEngine->masterGain();
const fpp_t frames = audioEngine->framesPerPeriod();
AudioEngine::StereoSample peakValues = audioEngine->getPeakValues(m_buffer, frames);
SampleFrame peakValues = getAbsPeakValues(m_buffer, frames);
auto const leftChannelClips = clips(peakValues.left * masterOutput);
auto const rightChannelClips = clips(peakValues.right * masterOutput);
auto const leftChannelClips = clips(peakValues.left() * masterOutput);
auto const rightChannelClips = clips(peakValues.right() * masterOutput);
p.setRenderHint( QPainter::Antialiasing );

View File

@@ -220,7 +220,7 @@ InstrumentTrack::~InstrumentTrack()
void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, NotePlayHandle* n )
void InstrumentTrack::processAudioBuffer( SampleFrame* buf, const fpp_t frames, NotePlayHandle* n )
{
// we must not play the sound if this InstrumentTrack is muted...
if( isMuted() || ( Engine::getSong()->playMode() != Song::PlayMode::MidiClip &&
@@ -567,7 +567,7 @@ f_cnt_t InstrumentTrack::beatLen( NotePlayHandle * _n ) const
void InstrumentTrack::playNote( NotePlayHandle* n, sampleFrame* workingBuffer )
void InstrumentTrack::playNote( NotePlayHandle* n, SampleFrame* workingBuffer )
{
// Note: under certain circumstances the working buffer is a nullptr.
// These cases are triggered in PlayHandle::doProcessing when the play method is called with a nullptr.