Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitinvader - Fix saving with automation and division by 0 #5805

Merged
merged 8 commits into from
Nov 27, 2020
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions plugins/bit_invader/bit_invader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

#include "plugin_export.h"

#define WAVETABLE_SIZE 200
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved

extern "C"
{

Expand Down Expand Up @@ -72,8 +74,8 @@ bSynth::bSynth( float * _shape, NotePlayHandle * _nph, bool _interpolation,
sample_rate( _sample_rate ),
interpolation( _interpolation)
{
sample_shape = new float[200];
for (int i=0; i < 200; ++i)
sample_shape = new float[WAVETABLE_SIZE];
for (int i=0; i < WAVETABLE_SIZE; ++i)
{
sample_shape[i] = _shape[i] * _factor;
}
Expand Down Expand Up @@ -138,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, 200, 1, this, tr( "Sample length" ) ),
m_graph( -1.0f, 1.0f, 200, 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 @@ -177,8 +179,8 @@ void bitInvader::saveSettings( QDomDocument & _doc, QDomElement & _this )

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


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

void bitInvader::loadSettings( const QDomElement & _this )
{
// Clear wavetable before loading a new
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
m_graph.clear();

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

Expand Down Expand Up @@ -240,7 +245,7 @@ void bitInvader::samplesChanged( int _begin, int _end )
void bitInvader::normalize()
{
// analyze
float max = 0;
float max = 0.0001f;
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
const float* samples = m_graph.samples();
for(int i=0; i < m_graph.length(); i++)
{
Expand Down