本文整理汇总了C++中EventBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ EventBuffer类的具体用法?C++ EventBuffer怎么用?C++ EventBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
void Caen785Module::setChannels()
{
// Setup channels
EventBuffer *evbuf = RunManager::ref ().getEventBuffer ();
for (int i= 0; i < 32; ++i)
evslots << evbuf->registerSlot (this, QString ("out %1").arg (i), PluginConnector::VectorUint32);
// Output for raw data -> to event builder
evslots << evbuf->registerSlot(this, "raw out", PluginConnector::VectorUint32);
}
示例2: TumbleNoteFunction
static void TumbleNoteFunction(FunctionEvent& p, EventBuffer& midiOutput) {
static NoteEvent note; // temporary note for placing in buffer
TumbleParameters& param = tparam[p.charValue(0)];
int newnote = limit(param.current + param.dir * param.n[param.pos], 0, 127);
// turn off algorithm if someone turned the algorithm off externally
// or if the current note is too large or too small.
if (param.active == 0 || newnote < A0 || newnote > C7) {
param.active = 0;
p.off(midiOutput);
return;
}
// set the parameters of the output note:
note.setOnDur(t_time, param.d[param.pos]); // off time holds dur
note.setVel(param.v[param.pos]);
note.setChan(p.getChan());
note.setKey(newnote);
note.activate();
note.action(midiOutput); // start right now, avoiding any buffer delay
midiOutput.insert(note); // store the note for turning off later
// update the parameters for the tumble algorithm
p.setOnTime(p.getOnTime() + param.i[param.pos]);
param.current = newnote;
param.pos++;
if (param.pos > param.n.getSize()) {
param.pos = 0;
}
}
示例3: EnhanceFunction
static void EnhanceFunction(FunctionEvent& p, EventBuffer& midiOutput) {
static NoteEvent note; // temporary note before placing in buffer
// set the parameters for the output note:
note.setOnDur(t_time, p.getOffTime()); // off time holds dur
note.setVel(p.getVel());
note.setChan(p.getChan());
note.setKey(p.getKey());
// if note is too quiet
if (p.getVel() <= 5) {
p.off(midiOutput);
}
// update the parameters for the function:
p.setKey(p.getKey()+p.shortValue(14));
p.setVel(p.getVel()-5);
p.setOnTime(p.getOnTime() + p.getDur()); // OffTime stores duration
note.activate();
note.action(midiOutput); // start right now, avoiding any buffer delay
midiOutput.insert(note); // the note off message is being buffered
// check wether to kill the algorithm or not:
// if note is off the range of the keyboard
if (p.getKey() > C8 || p.getKey() < A0) {
p.off(midiOutput);
}
}
示例4: EchoAlgorithm
static void EchoAlgorithm(FunctionEvent& p, EventBuffer& midiOutput) {
static NoteEvent note; // temporary note before placing in buffer
// check if pausing
if (decaystates[p.getKey()] < 0.0) {
p.setOnTime(p.getOnTime() + p.getDur() + p.shortValue(14));
return;
}
// set the parameters for the output note:
note.setOnDur(t_time, p.getOffTime()); // off time holds dur
note.setVel(p.getVel());
note.setChan(p.getChan());
note.setKey(p.getKey());
// update the parameters for the function:
decaystates[p.getKey()] *= decayrate;
p.setVel((int)decaystates[p.getKey()]);
// if note is too quiet, end the note
if (p.getVel() <= 2) {
p.off(midiOutput);
decaystates[p.getKey()] = 0.0;
}
// next time includes a gap so that key can raise on keyboard
p.setOnTime(p.getOnTime() + p.getDur() + p.shortValue(14));
note.activate();
note.action(midiOutput); // start right now, avoiding any buffer delay
midiOutput.insert(note); // the note off message is being buffered
}
示例5: playNextPattern
void playNextPattern(EventBuffer& eventbuffer, NoteScore& score,
int pattern, int subpattern, double tempo) {
if (pattern == 0 && subpattern == 3) {
subpattern = 2;
}
if (pattern == 6 && subpattern == 3) {
subpattern = 2;
}
int p = pattern;
int sp = subpattern;
cout << "playing pattern " << pattern << (char)('a' + subpattern) << endl;
NoteEvent note; // temporary note for placing in buffer
int i;
for (i=0; i<score[pattern][subpattern].getSize(); i++) {
if (!activevoice[score[pattern][subpattern][i].voice]) {
continue;
}
note.setOnDur((int)(t_time + score[p][sp][i].start * 1000 * 60 / tempo +
0.5), (int)(score[p][sp][i].dur * 1000 * 60 / tempo + 0.5));
note.setChan(CH_10);
note.setKey(voicetokey[score[p][sp][i].voice]);
note.setVel(score[p][sp][i].vel);
note.activate();
if (score[p][sp][i].start == 0.0) {
note.action(eventbuffer); // play starting notes now, avoiding delay
}
eventbuffer.insert(note);
}
}
示例6: add_noteon_event_to_buffer
void Track_Pattern::add_noteon_event_to_buffer(char p_note,char p_velocity,int p_column,EventBuffer &p_buffer,int p_frame_offset) {
EventBuffer &event_buffer=get_event_buffer();
//printf("note %i\n",p_note);
if (data.last_note[p_column].is_note() && data.last_note[p_column].note==p_note) {
/* IF the note is the same, we must mute it before */
Event e;
SET_EVENT_MIDI(e,EventMidi::MIDI_NOTE_OFF,0,data.last_note[p_column].note,0);
e.frame_offset=p_frame_offset; //off te
p_buffer.push_event(e);
data.last_note[p_column]=Note(Note::NOTE_OFF); //avoid the next check
}
/* send new note */
{
int velocity=(int)p_velocity*127/99;
Event e;
SET_EVENT_MIDI(e,EventMidi::MIDI_NOTE_ON,0,p_note,velocity);
e.frame_offset=p_frame_offset;
p_buffer.push_event(e);
}
if (data.last_note[p_column].is_note() && data.last_note[p_column].note!=p_note) {
/* If the note is different, mute it later */
Event e;
SET_EVENT_MIDI(e,EventMidi::MIDI_NOTE_OFF,0,data.last_note[p_column].note,0);
e.frame_offset=p_frame_offset; //off te
p_buffer.push_event(e);
}
data.last_note[p_column]=Note(p_note);
}
示例7: createTrill
void createTrill(int key1, int key2, int velocity, int channel, int duration) {
static FunctionEvent tn; // a Temporary Note for copying into eventBuffer
// key1 should always be smaller than key2
int temp;
if (key1 > key2) {
temp = key1;
key1 = key2;
key2 = temp;
}
// setting the fields of the function note
tn.setFunction(TrillAlgorithm);
tn.setChannel(channel);
tn.setKeyno(key1);
tn.setVelocity(velocity);
// set extra parameters
tn.charValue(15) = 0; // 0 = play key1 next, 1 = play key2 next
tn.charValue(14) = key2; // secondary pitch
tn.intValue(10) = t_time; // initialization time
tn.setStatus(EVENT_STATUS_ACTIVE);
// start time of function and the duration between calling it
tn.setOnDur(t_time + duration, duration);
eventBuffer.insert(tn);
cout << "Trill = " << key1 << " to " << key2
<< "\tRate = " << duration
<< endl;
}
示例8: mainloopalgorithms
void mainloopalgorithms(void) {
eventBuffer.checkPoll(); // see if any notes need playing
while (synth.getNoteCount() > 0) {
processNote(synth.extractNote());
}
}
示例9: playgliss
void playgliss(int basenote, int loudness, int channel, int duration,
int distancee) {
static FunctionEvent tn; // a Temporary Note for copying into eventBuffer
// setting the fields of the function note
tn.shortValue(14) = distancee;
tn.setFunction(EnhanceFunction);
tn.setChannel(channel);
tn.setKeyno(basenote + distancee);
tn.setVelocity(loudness - 5);
tn.setStatus(EVENT_STATUS_ACTIVE);
// start time of function and the duration between calling it
tn.setOnDur(t_time, duration);
eventBuffer.insert(tn);
cout << "StartKey = " << basenote
<< "\tLoudness = " << loudness
<< "\tRate = " << duration
<< "\tDirection = " << distancee
<< endl;
}
示例10: startAlgorithm
int startAlgorithm(TumbleParameters& p) {
static FunctionEvent tn; // a Temporary Note for copying into eventBuffer
int ploc = storeParameters(tparam, p);
if (ploc < 0) {
cout << "Warning: Parameter space is full. Not adding new algorithm"
<< endl;
return -1;
}
// setting the fields of the function note
tn.setFunction(TumbleNoteFunction);
tn.setChannel(channel);
tn.setKeyno(0);
tn.setVelocity(0);
tn.charValue(0) = (char)ploc; // store location of the parameters
tn.setStatus(EVENT_STATUS_ACTIVE);
tn.setOnTime(t_time + p.i[0] - anticipation);
// display the basic algorithm info
cout << "Tumble: Time: " << t_time << "\tStart = " << (int)p.current
<< "\tPattern = . ";
for (int i=1; i<p.n.getSize(); i++) {
cout << (int)p.n[i] << " ";
}
cout << "(" << (int)p.n[0] << ")";
cout << " ioi: " << p.i[0];
cout << endl;
return eventBuffer.insert(tn);
}
示例11: initialization
void initialization(void) {
eventBuffer.setPollPeriod(10);
for (int i=0; i<notestates.getSize(); i++) {
notestates[i] = 0;
onvels[i] = 0;
decaystates[i] = 0.0;
}
}
示例12: mainloopalgorithms
void mainloopalgorithms(void) {
eventBuffer.checkPoll(); // see if any notes to play
while (synth.getNoteCount() > 0) {
message = synth.extractNote();
processNote(message);
}
}
示例13: initialization
void initialization(void) {
eventBuffer.setPollPeriod(10);
notetimes.reset();
notetimes.insert(0);
notetimes.insert(0);
notes.reset();
notes.insert(0);
notes.insert(0);
noteontimes.zero();
}
示例14: mainloopalgorithms
void mainloopalgorithms(void) {
eventBuffer.checkPoll(); // see if any notes need playing
while (synth.getNoteCount() > 0) {
noteMessage = synth.extractNote();
if (noteMessage.getP2() != 0) {
playchord(noteMessage, chordType, onset, duration);
}
}
}
示例15: mainloopalgorithms
void mainloopalgorithms(void) {
eventbuffer.checkPoll();
if (nextpatterntime <= t_time) {
patternbeats = nextpattern + 2;
if (nextpattern == 0) {
patternbeats = 3;
}
nextpatterntime = t_time + (int)(60.0/tempo*1000*patternbeats + 0.5);
playNextPattern(eventbuffer, rpscore, nextpattern, nextsubpattern, tempo);
}
}