Skip to content

Commit

Permalink
Write whole wave table on load
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Nov 24, 2020
1 parent 14f8086 commit 23a18f7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions plugins/bit_invader/bit_invader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ sample_t bSynth::nextStringSample( float sample_length )

bitInvader::bitInvader( InstrumentTrack * _instrument_track ) :
Instrument( _instrument_track, &bitinvader_plugin_descriptor ),
m_sampleLength( 128, 4, WAVETABLE_SIZE, 1, this, tr( "Sample length" ) ),
m_graph( -1.0f, 1.0f, WAVETABLE_SIZE, this ),
m_sampleLength(128, 4, WAVETABLE_SIZE, 1, this, tr("Sample length")),
m_graph(-1.0f, 1.0f, WAVETABLE_SIZE, this),
m_interpolation( false, this ),
m_normalize( false, this )
{

lengthChanged();

m_graph.setWaveToSine();
Expand Down Expand Up @@ -179,8 +179,8 @@ void bitInvader::saveSettings( QDomDocument & _doc, QDomElement & _this )

// Save sample shape base64-encoded
QString sampleString;
base64::encode( (const char *)m_graph.samples(),
WAVETABLE_SIZE * sizeof(float), sampleString );
base64::encode((const char *)m_graph.samples(),
WAVETABLE_SIZE * sizeof(float), sampleString);
_this.setAttribute( "sampleShape", sampleString );


Expand All @@ -196,6 +196,12 @@ void bitInvader::saveSettings( QDomDocument & _doc, QDomElement & _this )

void bitInvader::loadSettings( const QDomElement & _this )
{
// Clear wavetable before loading a new
for (int i = 0; i < WAVETABLE_SIZE; i++)
{
m_graph.setSampleAt(i, 0.f);
}

// Load sample length
m_sampleLength.loadSettings( _this, "sampleLength" );

Expand All @@ -206,8 +212,8 @@ void bitInvader::loadSettings( const QDomElement & _this )
char * dst = 0;
base64::decode( _this.attribute( "sampleShape"), &dst, &size );

m_graph.setLength( sampleLength );
m_graph.setSamples( (float*) dst );
m_graph.setLength(sampleLength);
m_graph.setSamples((float*) dst);
delete[] dst;

// Load LED normalize
Expand Down

0 comments on commit 23a18f7

Please sign in to comment.