tweaks
This commit is contained in:
@@ -28,7 +28,7 @@ bool Instrument::isActive() {
|
||||
float Instrument::process(bool& scopeTrigger) {
|
||||
|
||||
if(active_ && envelope_ < 1.0f) envelope_ += 0.01f;
|
||||
if(!active_ && envelope_ > 0.0f) envelope_ -= 0.01f;
|
||||
if(!active_ && envelope_ > 0.0f) envelope_ -= 0.0004f;
|
||||
|
||||
phase_ += phaseIncrement_;
|
||||
if(phase_ > 2.0f * pi) {
|
||||
@@ -37,6 +37,10 @@ float Instrument::process(bool& scopeTrigger) {
|
||||
}
|
||||
|
||||
if(!isActive()) return 0.0f;
|
||||
return sin(phase_) * envelope_;
|
||||
|
||||
// float sample = sin(phase_);
|
||||
float sample = phase_ / pi - 1.0f; // saw
|
||||
|
||||
return sample * envelope_;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,12 +10,19 @@ Synth::Synth(ConfigService* config, LoggerService* logger, ScopeBuffer* scope, N
|
||||
|
||||
void Synth::handleNoteEvent(const NoteEvent& event) {
|
||||
|
||||
Voice* v = findVoiceByNote(event.note);
|
||||
if(v != nullptr) v->noteOff();
|
||||
// Voice* v = findVoiceByNote(event.note);
|
||||
// if(v != nullptr) v->noteOff();
|
||||
|
||||
// stop all voices that are currently playing this note
|
||||
for(Voice& v : voices_) {
|
||||
if(v.isActive() && v.note() == event.note) {
|
||||
v.noteOff();
|
||||
}
|
||||
}
|
||||
|
||||
if(event.type == NoteEventType::NoteOn) {
|
||||
|
||||
v = findFreeVoice();
|
||||
Voice* v = findFreeVoice();
|
||||
if(v != nullptr) v->noteOn(event.note, event.velocity);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user