From 424dc3b0e823aa685a9fb9981ccea6b70ed2b326 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Sun, 21 Sep 2008 17:06:31 +0000 Subject: [PATCH] Add pitch-bend support to BitInvader, Move smooth button, and some minor coding style corrections git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1669 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 9 +++++++- plugins/bit_invader/bit_invader.cpp | 36 +++++++++++------------------ plugins/bit_invader/bit_invader.h | 10 ++++---- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b6156fff..7e5fa243a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,7 +48,8 @@ - Replace r&b,r_b with r_n_b * src/core/main.cpp: - Make "could not set realtime priority" sound less like an error + - Make "could not set realtime priority" sound less like an error + - Actually commit the file * plugins/lb302/lb302.cpp: * plugins/lb302/lb302.h: @@ -59,6 +60,12 @@ - Add Sine, Noise, and Exponential waveforms - Use buttons instead of a knob + * plugins/bit_invader/bit_invader.cpp: + * plugins/bit_invader/bit_invader.h: + - Add support for pitch bend + - Move smoothing button to a more noticable location + - Some coding style changes + 2008-09-20 Paul Giblock * plugins/sf2_player/sf2_player.cpp: diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index 9522012b1..b503700c3 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -68,30 +68,20 @@ plugin::descriptor PLUGIN_EXPORT bitinvader_plugin_descriptor = } -bSynth::bSynth( float * shape, int length, float _pitch, bool _interpolation, - float factor, const sample_rate_t _sample_rate ) +bSynth::bSynth( float * _shape, int _length, notePlayHandle * _nph, bool _interpolation, + float _factor, const sample_rate_t _sample_rate ) : + sample_length( _length ), + nph( _nph ), + interpolation( _interpolation), + sample_rate( _sample_rate ), + sample_index( 0 ), + sample_realindex( 0 ) { - - interpolation = _interpolation; - - // init variables - - sample_length = length; sample_shape = new float[sample_length]; - for (int i=0; i < length; i++) + for (int i=0; i < _length; i++) { - sample_shape[i] = shape[i] * factor; + sample_shape[i] = _shape[i] * _factor; } - - - sample_index = 0; - sample_realindex = 0; - - - sample_step = static_cast( sample_length / ( _sample_rate / - _pitch ) ); - - } @@ -102,6 +92,8 @@ bSynth::~bSynth() sample_t bSynth::nextStringSample( void ) { + float sample_step = + static_cast( sample_length / ( sample_rate / nph->frequency() ) ); // check overflow @@ -281,7 +273,7 @@ void bitInvader::playNote( notePlayHandle * _n, bool, _n->m_pluginData = new bSynth( const_cast( m_graph.samples() ), m_graph.length(), - _n->frequency(), + _n, m_interpolation.value(), factor, engine::getMixer()->processingSampleRate() ); } @@ -402,7 +394,7 @@ bitInvaderView::bitInvaderView( instrument * _instrument, tr( "Click here for a user-defined shape." ) ); smoothBtn = new pixmapButton( this, tr( "Smooth" ) ); - smoothBtn->move( 55, 225 ); + smoothBtn->move( 35, 200 ); smoothBtn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth" ) ); smoothBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( diff --git a/plugins/bit_invader/bit_invader.h b/plugins/bit_invader/bit_invader.h index 191c8fe81..72b63d42c 100644 --- a/plugins/bit_invader/bit_invader.h +++ b/plugins/bit_invader/bit_invader.h @@ -42,8 +42,9 @@ class bitInvaderView; class bSynth { public: - bSynth( float * sample, int length, float _pitch, bool _interpolation, - float factor, const sample_rate_t _sample_rate ); + bSynth( float * sample, int length, notePlayHandle * _nph, + bool _interpolation, float factor, + const sample_rate_t _sample_rate ); virtual ~bSynth(); sample_t nextStringSample(); @@ -52,9 +53,10 @@ public: private: int sample_index; float sample_realindex; - int sample_length; float* sample_shape; - float sample_step; + notePlayHandle* nph; + const int sample_length; + const sample_rate_t sample_rate; bool interpolation;