Fix Bitinvader waveform cutoff behavior

This commit is contained in:
Douglas
2019-02-13 11:46:47 -07:00
committed by Hyunjin Song
parent fcacf44375
commit 8d707df171
3 changed files with 19 additions and 28 deletions

View File

@@ -165,6 +165,7 @@ public slots:
void normalize();
void invert();
void shiftPhase( int _deg );
void clearInvisible();
signals:
void lengthChanged();

View File

@@ -472,6 +472,7 @@ void bitInvaderView::modelChanged()
void bitInvaderView::sinWaveClicked()
{
m_graph->model()->clearInvisible();
m_graph->model()->setWaveToSine();
Engine::getSong()->setModified();
}
@@ -481,6 +482,7 @@ void bitInvaderView::sinWaveClicked()
void bitInvaderView::triangleWaveClicked()
{
m_graph->model()->clearInvisible();
m_graph->model()->setWaveToTriangle();
Engine::getSong()->setModified();
}
@@ -490,6 +492,7 @@ void bitInvaderView::triangleWaveClicked()
void bitInvaderView::sawWaveClicked()
{
m_graph->model()->clearInvisible();
m_graph->model()->setWaveToSaw();
Engine::getSong()->setModified();
}
@@ -499,6 +502,7 @@ void bitInvaderView::sawWaveClicked()
void bitInvaderView::sqrWaveClicked()
{
m_graph->model()->clearInvisible();
m_graph->model()->setWaveToSquare();
Engine::getSong()->setModified();
}
@@ -508,6 +512,7 @@ void bitInvaderView::sqrWaveClicked()
void bitInvaderView::noiseWaveClicked()
{
m_graph->model()->clearInvisible();
m_graph->model()->setWaveToNoise();
Engine::getSong()->setModified();
}
@@ -518,35 +523,12 @@ void bitInvaderView::noiseWaveClicked()
void bitInvaderView::usrWaveClicked()
{
QString fileName = m_graph->model()->setWaveToUser();
ToolTip::add( m_usrWaveBtn, fileName );
Engine::getSong()->setModified();
/*
m_graph->model()->setWaveToNoise();
Engine::getSong()->setModified();
// zero sample_shape
for (int i = 0; i < sample_length; i++)
if (!fileName.isEmpty())
{
sample_shape[i] = 0;
ToolTip::add(m_usrWaveBtn, fileName);
m_graph->model()->clearInvisible();
Engine::getSong()->setModified();
}
// load user shape
sampleBuffer buffer;
QString af = buffer.openAudioFile();
if ( af != "" )
{
buffer.setAudioFile( af );
// copy buffer data
sample_length = min( sample_length, static_cast<int>(
buffer.frames() ) );
for ( int i = 0; i < sample_length; i++ )
{
sample_shape[i] = (float)*buffer.data()[i];
}
}
sampleChanged();
*/
}

View File

@@ -692,7 +692,15 @@ void graphModel::shiftPhase( int _deg )
emit samplesChanged( 0, length()-1 );
}
// Clear any part of the graph that isn't displayed
void graphModel::clearInvisible()
{
const int graph_length = length();
const int full_graph_length = m_samples.size();
for( int i = graph_length; i < full_graph_length; i++ )
m_samples[i] = 0;
emit samplesChanged( graph_length, full_graph_length - 1 );
}
void graphModel::drawSampleAt( int x, float val )
{