Exemplo n.º 1
0
void NotePool::killNote(uint8_t note)
{
    for(auto &d:activeDesc()) {
        if(d.note == note)
            kill(d);
    }
}
Exemplo n.º 2
0
void NotePool::upgradeToLegato(void)
{
    for(auto &d:activeDesc())
        if(d.playing())
            for(auto &s:activeNotes(d))
                insertLegatoNote(d.note, d.sendto, s);
}
Exemplo n.º 3
0
void NotePool::enforceKeyLimit(int limit)
{
    int notes_to_kill = getRunningNotes() - limit;
    if(notes_to_kill <= 0)
        return;

    NoteDescriptor *to_kill = NULL;
    unsigned oldest = 0;
    for(auto &nd : activeDesc()) {
        if(to_kill == NULL) {
            //There must be something to kill
            oldest  = nd.age;
            to_kill = &nd;
        } else if(to_kill->released() && nd.playing()) {
            //Prefer to kill off a running note
            oldest = nd.age;
            to_kill = &nd;
        } else if(nd.age > oldest && !(to_kill->playing() && nd.released())) {
            //Get an older note when it doesn't move from running to released
            oldest = nd.age;
            to_kill = &nd;
        }
    }

    if(to_kill) {
        auto &tk = *to_kill;
        if(tk.released() || tk.sustained())
            kill(*to_kill);
        else
            entomb(*to_kill);
    }
}
Exemplo n.º 4
0
void NotePool::upgradeToLegato(void)
{
    for(auto &d:activeDesc())
        if(d.status == Part::KEY_PLAYING)
            for(auto &s:activeNotes(d))
                insertLegatoNote(d.note, d.sendto, s);
}
Exemplo n.º 5
0
bool NotePool::synthFull(int sdesc_count) const
{
    int actually_free=sizeof(sdesc)/sizeof(sdesc[0]);
    for(const auto &desc:activeDesc()) {
        actually_free -= desc.size;
    }
    return actually_free < sdesc_count;
}
Exemplo n.º 6
0
//There should only be one pair of notes which are still playing
void NotePool::applyLegato(LegatoParams &par)
{
    for(auto &desc:activeDesc()) {
        desc.note = par.midinote;
        for(auto &synth:activeNotes(desc))
            synth.note->legatonote(par);
    }
};
Exemplo n.º 7
0
void NotePool::releasePlayingNotes(void)
{
    for(auto &d:activeDesc()) {
        if(d.playing()) {
            d.setStatus(KEY_RELEASED);
            for(auto s:activeNotes(d))
                s.note->releasekey();
        }
    }
}
Exemplo n.º 8
0
void NotePool::makeUnsustainable(uint8_t note)
{
    for(auto &desc:activeDesc()) {
        if(desc.note == note) {
            desc.makeUnsustainable();
            if(desc.sustained())
                release(desc);
        }
    }
}
Exemplo n.º 9
0
void NotePool::releasePlayingNotes(void)
{
    for(auto &d:activeDesc()) {
        if(d.status == Part::KEY_PLAYING) {
            d.status = Part::KEY_RELEASED;
            for(auto s:activeNotes(d))
                s.note->releasekey();
        }
    }
}
Exemplo n.º 10
0
//There should only be one pair of notes which are still playing
void NotePool::applyLegato(LegatoParams &par)
{
    for(auto &desc:activeDesc()) {
        desc.note = par.midinote;
        for(auto &synth:activeNotes(desc))
            try {
                synth.note->legatonote(par);
            } catch (std::bad_alloc& ba) {
                std::cerr << "failed to create legato note: " << ba.what() << std::endl;
            }
    }
}
Exemplo n.º 11
0
int NotePool::getRunningNotes(void) const
{
    bool running[256] = {0};
    for(auto &desc:activeDesc()) {
        printf("note!(%d)\n", desc.note);
        running[desc.note] = true;
    }

    int running_count = 0;
    for(int i=0; i<256; ++i)
        running_count += running[i];

    return running_count;
}
Exemplo n.º 12
0
void NotePool::dump(void)
{
    printf("NotePool::dump<\n");
    const char *format =
        "    Note %d:%d age(%d) note(%d) sendto(%d) status(%s) legato(%d) type(%d) kit(%d) ptr(%p)\n";
    int note_id=0;
    int descriptor_id=0;
    for(auto &d:activeDesc()) {
        descriptor_id += 1;
        for(auto &s:activeNotes(d)) {
            note_id += 1;
            printf(format,
                    note_id, descriptor_id,
                    d.age, d.note, d.sendto,
                    getStatus(d.status), d.legatoMirror, s.type, s.kit, s.note);
        }
    }
    printf(">NotePool::dump\n");
}
Exemplo n.º 13
0
void NotePool::killAllNotes(void)
{
    for(auto &d:activeDesc())
        kill(d);
}