-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoicechannel.cpp
More file actions
39 lines (30 loc) · 1.33 KB
/
voicechannel.cpp
File metadata and controls
39 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//voicechannel.cpp
#include "voicechannel.h"
VoiceChannel::VoiceChannel(int p, int mchan):MidiChannel(p,mchan) {
octave=4;
volume=100;
gate=100;
transpose=0;
}
void VoiceChannel::sendNote(Event *event,snd_seq_event_t *ev){
int next=event->note->duration*TICKS_PER_QUARTER*numerator/division;
int duration=next*gate/100;
//printf("send channel %d note %d velocity %d duration %d tick %u\n",midiChannel, event->note->note + transpose, volume, duration,tick);
snd_seq_ev_set_note(ev, midiChannel, event->note->note + transpose, volume, duration);
tick += next;
}
void VoiceChannel::sendChord(Event *event,snd_seq_event_t *ev){
int next=event->chord->duration*TICKS_PER_QUARTER*numerator/division;
int duration=next*gate/100;
//printf("send channel %d note %d velocity %d duration %d tick %u\n",midiChannel-1, event->chord->note + transpose, volume, duration,tick);
snd_seq_ev_set_note(ev, midiChannel, event->chord->note + transpose, volume, duration);
}
void VoiceChannel::processEvent(Event *event,snd_seq_event_t *ev){
switch(event->type) {
case Event::VOLUME: volume=event->value;break;
case Event::GATE: gate=event->value;break;
case Event::NOTE: sendNote(event,ev);break;
case Event::CHORD: sendChord(event,ev);break;
default: MidiChannel::processEvent(event,ev);break;
}
}