Example #1
0
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();
		}
	}
}
Example #2
0
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();
        }
    }
}