replaced wave-generation methods by static methods of oscillator.h

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@60 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Andreas Brandmaier
2006-01-23 20:15:56 +00:00
parent 86b37628d5
commit 458304016e
2 changed files with 99 additions and 12 deletions

View File

@@ -64,6 +64,8 @@ using namespace std;
#include "knob.h"
#include "pixmap_button.h"
#include "tooltip.h"
#include "song_editor.h"
#include "oscillator.h"
#include "embed.cpp"
@@ -348,6 +350,72 @@ void bitInvader::paintEvent( QPaintEvent * )
}
void bitInvader::sinWaveClicked( void )
{
// generate a Sinus wave using static oscillator-method
for (int i=0; i < sample_length; i++)
{
sample_shape[i] = oscillator::sinSample( i/static_cast<float>(sample_length) );
}
sampleChanged();
}
void bitInvader::triangleWaveClicked( void )
{
// generate a Triangle wave using static oscillator-method
for (int i=0; i < sample_length; i++)
{
sample_shape[i] = oscillator::triangleSample( i/static_cast<float>(sample_length) );
}
sampleChanged();
}
void bitInvader::sawWaveClicked( void )
{
// generate a Saw wave using static oscillator-method
for (int i=0; i < sample_length; i++)
{
sample_shape[i] = oscillator::sawSample( i/static_cast<float>(sample_length) );
}
sampleChanged();
}
void bitInvader::sqrWaveClicked( void )
{
// generate a Sqr wave using static oscillator-method
for (int i=0; i < sample_length; i++)
{
sample_shape[i] = oscillator::squareSample( i/static_cast<float>(sample_length) );
}
sampleChanged();
}
void bitInvader::noiseWaveClicked( void )
{
// generate a Noise wave using static oscillator-method
for (int i=0; i < sample_length; i++)
{
sample_shape[i] = oscillator::noiseSample( i/static_cast<float>(sample_length) );
}
sampleChanged();
}
/*
deprecated code
was replaced by static oscillator methods
void bitInvader::sinWaveClicked( void )
{
// generate sample data
@@ -360,7 +428,6 @@ void bitInvader::sinWaveClicked( void )
sampleChanged();
}
void bitInvader::triangleWaveClicked( void )
{
int half_sample_length = sample_length / 2;
@@ -440,6 +507,10 @@ void bitInvader::noiseWaveClicked( void)
}
*/
bitInvader::~bitInvader()
{
}
@@ -516,17 +587,25 @@ void bitInvader::loadSettings( const QDomElement & _this )
}
update();
// m_graph->update();
songEditor::inst()->setModified();
}
void bitInvader::interpolationToggle( bool value )
{
interpolation = value;
songEditor::inst()->setModified();
}
void bitInvader::normalizeToggle( bool value )
{
normalize = value;
songEditor::inst()->setModified();
}
@@ -560,6 +639,10 @@ void bitInvader::smoothClicked( void )
// paint
update();
m_graph->update();
songEditor::inst()->setModified();
}
@@ -653,14 +736,14 @@ void bitInvader::sampleSizeChanged( float _new_sample_length )
}
// sample_length = static_cast<int>(value);
// delete[] sample_shape;
// sample_shape = new float[sample_length];
// ** repaint
m_graph->setSamplePointer( sample_shape, sample_length );
m_graph->repaint();
// update sample graph
m_graph->setSamplePointer( sample_shape, sample_length );
m_graph->update();
// set Song modified
songEditor::inst()->setModified();
}
void bitInvader::sampleChanged()
@@ -674,12 +757,13 @@ void bitInvader::sampleChanged()
}
normalizeFactor = 1.0 / max;
// cout << "MAX:" << max << "\tnormalizeFactor : " << normalizeFactor << endl;
// update
if (m_graph != NULL) {
m_graph->update();
}
songEditor::inst()->setModified();
}

View File

@@ -44,7 +44,7 @@
#include "spc_bg_hndl_widget.h"
#include "graph.h"
#include "led_checkbox.h"
#include "oscillator.h"
class knob;
class notePlayHandle;
@@ -67,7 +67,8 @@ private:
float* sample_shape;
float sample_step;
bool interpolation;
bool interpolation;
} ;
class bitInvader : public instrument, public specialBgHandlingWidget
@@ -128,6 +129,8 @@ private:
bool interpolation;
bool normalize;
float normalizeFactor;
oscillator * m_osc;
} ;