From b0d91d48e9ac4cfffbdecd0c85312008e4d3678f Mon Sep 17 00:00:00 2001 From: Andreas Brandmaier Date: Tue, 24 Jan 2006 00:26:07 +0000 Subject: [PATCH] added user-loadable waveform code cleanup git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@62 0778d3d1-df1d-0410-868b-ea421aaaa00d --- plugins/bit_invader/bit_invader.cpp | 48 +++++++++++++++++++++++++++-- plugins/bit_invader/bit_invader.h | 6 ++-- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index d68287040..2b5ccc0ef 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -66,7 +66,7 @@ using namespace std; #include "tooltip.h" #include "song_editor.h" #include "oscillator.h" - +#include "sample_buffer.h" #include "embed.cpp" @@ -285,6 +285,16 @@ bitInvader::bitInvader( channelTrack * _channel_track ) : tr( "Click here if you want a white-noise for " "current oscillator." ) ); + usrWaveBtn = new pixmapButton( this ); + usrWaveBtn->move( 188, 200 ); + usrWaveBtn->setActiveGraphic( embed::getIconPixmap( + "usr_wave_active" ) ); + usrWaveBtn->setInactiveGraphic( embed::getIconPixmap( + "usr_wave_inactive" ) ); + toolTip::add( usrWaveBtn, + tr( "Click here if you want a user-defined " + "wave-shape for current oscillator." ) ); + connect( sinWaveBtn, SIGNAL (clicked ( void ) ), this, SLOT ( sinWaveClicked( void ) ) ); @@ -296,6 +306,9 @@ bitInvader::bitInvader( channelTrack * _channel_track ) : this, SLOT ( sqrWaveClicked( void ) ) ); connect( whiteNoiseWaveBtn, SIGNAL ( clicked ( void ) ), this, SLOT ( noiseWaveClicked( void ) ) ); + connect( usrWaveBtn, SIGNAL ( clicked ( void ) ), + this, SLOT ( usrWaveClicked( void ) ) ); + smoothBtn = new pixmapButton( this ); @@ -324,7 +337,7 @@ bitInvader::bitInvader( channelTrack * _channel_track ) : } - +/* void bitInvader::paintEvent( QPaintEvent * ) { #ifdef QT4 @@ -348,7 +361,7 @@ void bitInvader::paintEvent( QPaintEvent * ) } - +*/ void bitInvader::sinWaveClicked( void ) { @@ -409,6 +422,35 @@ void bitInvader::noiseWaveClicked( void ) } +void bitInvader::usrWaveClicked( void ) +{ + // zero sample_shape + for (int i = 0; i < sample_length; i++) + { + sample_shape[i] = 0; + } + + // load user shape + sampleBuffer buffer; + QString af = buffer.openAudioFile(); + if ( af != "" ) + { + buffer.setAudioFile( af ); + + // copy buffer data + sample_length = min( sample_length, static_cast(buffer.frames()) ); + for ( int i = 0; i < sample_length; i++ ) + { +// sample_shape = (float*)buffer.data(); + sample_shape[i] = (float)*buffer.data()[i]; + } + } + + sampleChanged(); + +} + + /* diff --git a/plugins/bit_invader/bit_invader.h b/plugins/bit_invader/bit_invader.h index e723b6802..244d94165 100644 --- a/plugins/bit_invader/bit_invader.h +++ b/plugins/bit_invader/bit_invader.h @@ -101,10 +101,11 @@ public slots: void sqrWaveClicked( void ); void sawWaveClicked( void ); void noiseWaveClicked( void ); - + void usrWaveClicked( void ); +/* protected: virtual void paintEvent( QPaintEvent * ); - +*/ private: knob * m_pickKnob; @@ -116,6 +117,7 @@ private: pixmapButton * sawWaveBtn; pixmapButton * whiteNoiseWaveBtn; pixmapButton * smoothBtn; + pixmapButton * usrWaveBtn; static QPixmap * s_artwork;