basic song play, better vibrato, copy/paste note
This commit is contained in:
@@ -9,7 +9,7 @@ toneGen::toneGen() {
|
||||
|
||||
this->note = 34;
|
||||
this->instrument = CHIPTUNE_INSTRUMENT_NOISE;
|
||||
this->volume = 15;
|
||||
this->volume = 0;
|
||||
this->effect = CHIPTUNE_EFFECT_FADEOUT;
|
||||
|
||||
this->current_volume = this->nominal_volume = 1.0f;
|
||||
@@ -21,6 +21,7 @@ toneGen::toneGen() {
|
||||
|
||||
this->old_df = this->df = notes[this->note];
|
||||
this->f = -AUDIO_FORMAT_MAX_VALUE;
|
||||
this->vibrato_counter = 0;
|
||||
}
|
||||
|
||||
void toneGen::setNoteLength(const int note_length) {
|
||||
@@ -30,6 +31,8 @@ void toneGen::setNoteLength(const int note_length) {
|
||||
void toneGen::setup(const uint8_t note, const uint8_t instrument, const uint8_t volume, const uint8_t effect) {
|
||||
this->current_pos = 0;
|
||||
|
||||
if (note == 0) return;
|
||||
|
||||
this->note = note;
|
||||
this->instrument = instrument;
|
||||
this->volume = volume;
|
||||
@@ -52,12 +55,13 @@ const int toneGen::getSamples(const int numSamples, Sint16 *buffer) {
|
||||
|
||||
for (int i=0; i<actual_samples_generated;++i) {
|
||||
f += df;
|
||||
vibrato_counter += 0.001f;
|
||||
|
||||
switch (this->effect) {
|
||||
case CHIPTUNE_EFFECT_NONE:
|
||||
break;
|
||||
case CHIPTUNE_EFFECT_VIBRATO:
|
||||
f += SDL_sinf((i+this->current_pos)/1000)*15;
|
||||
f += SDL_sinf(vibrato_counter)*8;
|
||||
break;
|
||||
case CHIPTUNE_EFFECT_DROP:
|
||||
if (((i+this->current_pos)%15)==0 && df != 0) { df--; if (df < 100) this->current_volume = this->nominal_volume*df*0.01f; }
|
||||
|
||||
Reference in New Issue
Block a user