MidiPlayerWindow::~MidiPlayerWindow()
{
	StopSynth();

	//bridge->Unregister();
	bridge->Release();
}
void
MidiPlayerWindow::OnPlayStop()
{
	if (playing) {
		playButton->SetEnabled(false);
		scopeView->SetPlaying(false);
		scopeView->Invalidate();
		UpdateIfNeeded();

		StopSynth();
	} else {
		playButton->SetLabel(B_TRANSLATE("Stop"));
		scopeView->SetPlaying(true);
		scopeView->Invalidate();

		StartSynth();
	}
}
Exemple #3
0
void MidiPlayerWindow::LoadFile(entry_ref* ref)
{
    if (playing)
    {
        scopeView->SetPlaying(false);
        scopeView->Invalidate();
        UpdateIfNeeded();

        StopSynth();
    }

    synth.UnloadFile();

    if (synth.LoadFile(ref) == B_OK)
    {
        // Ideally, we would call SetVolume() in InitControls(),
        // but for some reason that doesn't work: BMidiSynthFile
        // will use the default volume instead. So we do it here.
        synth.SetVolume(volume / 100.0f);

        playButton->SetEnabled(true);
        playButton->SetLabel(B_TRANSLATE("Stop"));
        scopeView->SetHaveFile(true);
        scopeView->SetPlaying(true);
        scopeView->Invalidate();

        StartSynth();
    }
    else
    {
        playButton->SetEnabled(false);
        playButton->SetLabel(B_TRANSLATE("Play"));
        scopeView->SetHaveFile(false);
        scopeView->SetPlaying(false);
        scopeView->Invalidate();

        (new BAlert(NULL,
                    B_TRANSLATE("Could not load song"),
                    B_TRANSLATE("OK"), NULL, NULL,
                    B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
    }
}