void MidiPlayerWindow::OnInputChanged(BMessage* msg) { int32 newId; if (msg->FindInt32("id", &newId) == B_OK) { BMidiProducer* endp; endp = BMidiRoster::FindProducer(inputId); if (endp != NULL) { endp->Disconnect(bridge); endp->Release(); } inputId = newId; endp = BMidiRoster::FindProducer(inputId); if (endp != NULL) { if (!instrLoaded) { scopeView->SetLoading(true); scopeView->Invalidate(); UpdateIfNeeded(); bridge->Init(B_BIG_SYNTH); instrLoaded = true; scopeView->SetLoading(false); scopeView->Invalidate(); } endp->Connect(bridge); endp->Release(); scopeView->SetLiveInput(true); scopeView->Invalidate(); } else { scopeView->SetLiveInput(false); scopeView->Invalidate(); } } }
void MidiSetup::ConnectProducer(BString name) { if (sMilkyMidiConsumer != NULL) { int32 id = 0; BMidiProducer* midiProducer = BMidiRoster::NextProducer(&id); while (midiProducer != NULL) { if (name == midiProducer->Name()) { midiProducer->Release(); break; } midiProducer->Release(); midiProducer = BMidiRoster::NextProducer(&id); } sMilkyMidiConsumer->ConnectProducer(id); } }
MidiEventMeter::MidiEventMeter(int32 producerID) : fCounter(NULL), fMeterLevel(0) { BMidiRoster* roster = BMidiRoster::MidiRoster(); if (roster != NULL) { BMidiProducer* producer = roster->FindProducer(producerID); if (producer != NULL) { BString name; name << producer->Name() << " Event Meter"; fCounter = new CountEventConsumer(name.String()); producer->Connect(fCounter); producer->Release(); } } }