mute implementat
This commit is contained in:
@@ -11,6 +11,7 @@ toneGen::toneGen() {
|
||||
this->instrument = CHIPTUNE_INSTRUMENT_NOISE;
|
||||
this->volume = 0;
|
||||
this->effect = CHIPTUNE_EFFECT_FADEOUT;
|
||||
this->muted = false;
|
||||
|
||||
this->current_volume = this->nominal_volume = 1.0f;
|
||||
|
||||
@@ -37,6 +38,7 @@ void toneGen::setup(const uint8_t note, const uint8_t instrument, const uint8_t
|
||||
this->instrument = instrument;
|
||||
this->volume = volume;
|
||||
this->effect = effect;
|
||||
this->muted = false;
|
||||
|
||||
this->nominal_volume = float(volume) / 15.0f;
|
||||
this->current_volume = this->effect == CHIPTUNE_EFFECT_FADEIN ? 0.0f : this->nominal_volume;
|
||||
@@ -92,9 +94,13 @@ const int toneGen::getSamples(const int numSamples, Sint16 *buffer) {
|
||||
buffer[i] = (rand()*2)-AUDIO_FORMAT_MAX_VALUE;
|
||||
break;
|
||||
}
|
||||
buffer[i] *= this->current_volume;
|
||||
buffer[i] *= (muted ? 0 : this->current_volume);
|
||||
}
|
||||
|
||||
this->current_pos += actual_samples_generated;
|
||||
return actual_samples_generated;
|
||||
}
|
||||
|
||||
void toneGen::setMute(const bool value) {
|
||||
muted = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user