Cleanup midi tests directory
* synth_file_reader: TList to BObjectList. * delete two old prototypes of MidiPlayer and the README noting that they should be removed * delete reference to PatchBay which was moved to src/apps in 2013. Fixes #7027.
This commit is contained in:
parent
4227495829
commit
459b8e9796
@ -1,9 +1,6 @@
|
||||
SubDir HAIKU_TOP src tests kits midi ;
|
||||
|
||||
#SimpleTest test1 : test1.cpp : libmidi.so be stdc++.r4 ;
|
||||
SimpleTest miditest1 : test1.cpp : libmidi.so be stdc++.r4 ;
|
||||
|
||||
#SubInclude HAIKU_TOP src tests kits midi midi_player ;
|
||||
#SubInclude HAIKU_TOP src tests kits midi midi_player_replacement ;
|
||||
#SubInclude HAIKU_TOP src tests kits midi synth_file_reader ;
|
||||
#SubInclude HAIKU_TOP src tests kits midi patchbay ;
|
||||
SubInclude HAIKU_TOP src tests kits midi synth_file_reader ;
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
The /current/src/tests directories are supposed to contain unit tests
|
||||
(CppUnit or otherwise) and not tryout programs (no matter how useful)
|
||||
That's why in due time we will remove the following items from this folder:
|
||||
|
||||
- midi_player and midi_player_replacement. The Midi Player is now the
|
||||
responsibility of the prefs/apps team, not of the Midi Team.
|
||||
|
||||
- synth_file_reader. It doesn't make much sense for us to reverse
|
||||
engineer the format of the soundbanks from the R5 softsynth, because
|
||||
we are not allowed to redistribute these banks anyway.
|
||||
|
||||
This README is just a reminder so we don't forget to clean this up someday.
|
||||
-- Matthijs
|
@ -1,9 +0,0 @@
|
||||
SubDir HAIKU_TOP src tests kits midi midi_player ;
|
||||
|
||||
SimpleTest MidiPlayer
|
||||
: MidiPlayer.cpp
|
||||
Midi1To2Bridge.cpp
|
||||
MidiDelay.cpp
|
||||
: midi midi2 be stdc++.r4
|
||||
;
|
||||
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
|
||||
Midi1To2Bridge.cpp
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
Midi Kit 1 input to Midi Kit 2 input (consumer) bridge.
|
||||
A Midi Kit 1 input node that passes the midi events via a
|
||||
Midi Kit 2 producer to Midi Kit 2 consumers.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "Midi1To2Bridge.h"
|
||||
|
||||
Midi1To2Bridge::Midi1To2Bridge(const char *name) {
|
||||
fOutput = new BMidiLocalProducer(name);
|
||||
fOutput->Register();
|
||||
}
|
||||
|
||||
Midi1To2Bridge::~Midi1To2Bridge() {
|
||||
fOutput->Unregister();
|
||||
fOutput->Release();
|
||||
}
|
||||
|
||||
void Midi1To2Bridge::NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayNoteOff(channel-1, note, velocity, ToBigtime(time));
|
||||
}
|
||||
|
||||
void Midi1To2Bridge::NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayNoteOn(channel-1, note, velocity, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayKeyPressure(channel-1, note, pressure, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayControlChange(channel-1, controlNumber, controlValue, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayProgramChange(channel-1, programNumber, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayChannelPressure(channel-1, pressure, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SprayPitchBend(channel-1, lsb, msb, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SpraySystemExclusive(data, dataLength, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW) {
|
||||
fOutput->SpraySystemCommon(statusByte, data1, data2, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::SystemRealTime(uchar statusByte, uint32 time = B_NOW) {
|
||||
fOutput->SpraySystemRealTime(statusByte, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::TempoChange(int32 bpm, uint32 time = B_NOW) {
|
||||
fOutput->SprayTempoChange(bpm, ToBigtime(time));
|
||||
}
|
||||
|
||||
|
||||
void Midi1To2Bridge::AllNotesOff(bool justChannel = true, uint32 time = B_NOW) {
|
||||
bigtime_t t = ToBigtime(time);
|
||||
for (uchar channel = 0; channel < 16; channel ++) {
|
||||
fOutput->SprayControlChange(channel, B_ALL_NOTES_OFF, 0, t);
|
||||
}
|
||||
}
|
||||
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
|
||||
Midi1To2Bridge.h
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
Midi Kit 1 input to Midi Kit 2 input (consumer) bridge.
|
||||
A Midi Kit 1 input node that passes the midi events via a
|
||||
Midi Kit 2 producer to Midi Kit 2 consumers.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _MIDI_BRIDGE_H
|
||||
#define _MIDI_BRIDGE_H
|
||||
|
||||
#include <Midi.h>
|
||||
#include <MidiProducer.h>
|
||||
|
||||
// Note channel starts with 0 in Midi Kit 2 and it starts with 1 in Midi Kit 1
|
||||
|
||||
class Midi1To2Bridge : public BMidi {
|
||||
BMidiLocalProducer* fOutput;
|
||||
|
||||
static inline bigtime_t ToBigtime(uint32 time) { return time * (bigtime_t)1000; }
|
||||
|
||||
public:
|
||||
Midi1To2Bridge(const char* name);
|
||||
~Midi1To2Bridge();
|
||||
|
||||
virtual void NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
|
||||
|
||||
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
|
||||
|
||||
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
|
||||
MidiDelay.cpp
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
A filter for Midi Kit 1 that sprays midi events
|
||||
when the performance time is reached.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include "MidiDelay.h"
|
||||
|
||||
void MidiDelay::NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayNoteOff(channel, note, velocity, time);
|
||||
}
|
||||
|
||||
void MidiDelay::NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayNoteOn(channel, note, velocity, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayKeyPressure(channel, note, pressure, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayControlChange(channel, controlNumber, controlValue, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayProgramChange(channel, programNumber, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayChannelPressure(channel, pressure, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayPitchBend(channel, lsb, msb, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SpraySystemExclusive(data, dataLength, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SpraySystemCommon(statusByte, data1, data2, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::SystemRealTime(uchar statusByte, uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SpraySystemRealTime(statusByte, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::TempoChange(int32 bpm, uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayTempoChange(bpm, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::AllNotesOff(bool justChannel = true, uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
for (uchar channel = 0; channel < 16; channel ++) {
|
||||
SprayControlChange(channel, B_ALL_NOTES_OFF, 0, time);
|
||||
}
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
|
||||
MidiDelay.h
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
A filter for Midi Kit 1 that sprays midi events
|
||||
when the performance time is reached.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _MIDI_DELAY_H
|
||||
#define _MIDI_DELAY_H
|
||||
|
||||
#include <Midi.h>
|
||||
|
||||
class MidiDelay : public BMidi {
|
||||
|
||||
static inline bigtime_t ToBigtime(uint32 time) { return time * (bigtime_t)1000; }
|
||||
|
||||
public:
|
||||
|
||||
virtual void NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
|
||||
|
||||
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
|
||||
|
||||
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
|
||||
main.cpp
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
Test application plays a midi file via a BMidiLocalProducer.
|
||||
|
||||
Authors:
|
||||
Michael Pfeiffer
|
||||
Paul Stadler
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <Application.h>
|
||||
#include <MidiStore.h>
|
||||
#include <Entry.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MidiDelay.h"
|
||||
#include "Midi1To2Bridge.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Error missing parameter!\n%s midi_file\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
BEntry entry(argv[1],true);
|
||||
if(!entry.Exists()) {
|
||||
fprintf(stderr, "File does not exist!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
new BApplication("application/vnd.obos-midiplayer");
|
||||
BMidiStore store;
|
||||
MidiDelay delay;
|
||||
Midi1To2Bridge bridge("MidiPlayer output");
|
||||
|
||||
entry_ref e_ref;
|
||||
entry.GetRef(&e_ref);
|
||||
store.Import(&e_ref);
|
||||
store.Connect(&delay);
|
||||
delay.Connect(&bridge);
|
||||
// Use PatchBay to connect the MidiProducer with a MidiConsumer
|
||||
// (or just MidiSynth 1.6)
|
||||
printf("Connect MidiPlayer output to a MidiConsumer.\n""Hit return to start! "); getchar();
|
||||
store.Start();
|
||||
while(store.IsRunning()) {
|
||||
snooze(100000);
|
||||
}
|
||||
store.Stop();
|
||||
store.Disconnect(&delay);
|
||||
delay.Disconnect(&bridge);
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
Author: Jerome LEVEQUE
|
||||
Email: jerl1@caramail.com
|
||||
*/
|
||||
#include "Activity.h"
|
||||
|
||||
#include <Window.h>
|
||||
#include <StringView.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
Activity::Activity(BRect rect)
|
||||
: BView(rect, "Midi Activity",
|
||||
B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
fActivity[i] = 0;
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Activity::AttachedToWindow(void)
|
||||
{
|
||||
Window()->SetPulseRate(200000);
|
||||
|
||||
AddChild(new BStringView(BRect( 65, 45, 80, 55), NULL, "1"));
|
||||
AddChild(new BStringView(BRect(125, 45, 140, 55), NULL, "2"));
|
||||
AddChild(new BStringView(BRect(185, 45, 200, 55), NULL, "3"));
|
||||
AddChild(new BStringView(BRect(245, 45, 260, 55), NULL, "4"));
|
||||
|
||||
AddChild(new BStringView(BRect( 65, 105, 80, 115), NULL, "5"));
|
||||
AddChild(new BStringView(BRect(125, 105, 140, 115), NULL, "6"));
|
||||
AddChild(new BStringView(BRect(185, 105, 200, 115), NULL, "7"));
|
||||
AddChild(new BStringView(BRect(245, 105, 260, 115), NULL, "8"));
|
||||
|
||||
AddChild(new BStringView(BRect( 65, 165, 80, 175), NULL, "9"));
|
||||
AddChild(new BStringView(BRect(123, 165, 140, 175), NULL, "10"));
|
||||
AddChild(new BStringView(BRect(183, 165, 200, 175), NULL, "11"));
|
||||
AddChild(new BStringView(BRect(243, 165, 260, 175), NULL, "12"));
|
||||
|
||||
AddChild(new BStringView(BRect( 63, 220, 80, 235), NULL, "13"));
|
||||
AddChild(new BStringView(BRect(123, 220, 140, 235), NULL, "14"));
|
||||
AddChild(new BStringView(BRect(183, 220, 200, 235), NULL, "15"));
|
||||
AddChild(new BStringView(BRect(243, 220, 260, 235), NULL, "16"));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Activity::Draw(BRect rect)
|
||||
{
|
||||
bigtime_t present = system_time() - 600000;
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
BPoint aPoint(i * 60 + 70, j * 60 + 70);
|
||||
SetHighColor(0, 0, 0);
|
||||
StrokeEllipse(aPoint, 5, 5);
|
||||
SetHighColor(0, 255, 0);
|
||||
if (present < fActivity[j * 4 + i])
|
||||
FillEllipse(aPoint, 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Activity::Pulse(void)
|
||||
{
|
||||
Invalidate(BRect(60, 60, 300, 300));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Activity::NoteOn(uchar channel, uchar note,
|
||||
uchar velocity, uint32 time = B_NOW)
|
||||
{//This function just update the variable
|
||||
fActivity[channel] = system_time();
|
||||
SprayNoteOn(channel, note, velocity, time);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
Author: Jerome LEVEQUE
|
||||
Email: jerl1@caramail.com
|
||||
*/
|
||||
#ifndef ACTIVITY_H
|
||||
#define ACTIVITY_H
|
||||
|
||||
#include <View.h>
|
||||
#include <Midi.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
class Activity : public BMidi, public BView
|
||||
{
|
||||
public:
|
||||
Activity(BRect rect);
|
||||
|
||||
virtual void AttachedToWindow(void);
|
||||
virtual void Draw(BRect rect);
|
||||
virtual void Pulse(void);
|
||||
virtual void NoteOn(uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
||||
|
||||
private:
|
||||
bigtime_t fActivity[16]; //16 channels
|
||||
|
||||
|
||||
};
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,17 +0,0 @@
|
||||
SubDir HAIKU_TOP src tests kits midi midi_player_replacement ;
|
||||
|
||||
SimpleTest MidiPlayer2
|
||||
: # Midi Class
|
||||
MidiDelay.cpp
|
||||
|
||||
# Application
|
||||
MidiPlayerWindow.cpp
|
||||
MidiPlayerView.cpp
|
||||
|
||||
# Display View
|
||||
Scope.cpp
|
||||
Activity.cpp
|
||||
|
||||
: midi be tracker
|
||||
;
|
||||
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
|
||||
MidiDelay.cpp
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
A filter for Midi Kit 1 that sprays midi events
|
||||
when the performance time is reached.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include "MidiDelay.h"
|
||||
|
||||
void MidiDelay::NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayNoteOff(channel, note, velocity, time);
|
||||
}
|
||||
|
||||
void MidiDelay::NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayNoteOn(channel, note, velocity, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayKeyPressure(channel, note, pressure, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayControlChange(channel, controlNumber, controlValue, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayProgramChange(channel, programNumber, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayChannelPressure(channel, pressure, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayPitchBend(channel, lsb, msb, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SpraySystemExclusive(data, dataLength, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SpraySystemCommon(statusByte, data1, data2, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::SystemRealTime(uchar statusByte, uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SpraySystemRealTime(statusByte, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::TempoChange(int32 bpm, uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
SprayTempoChange(bpm, time);
|
||||
}
|
||||
|
||||
|
||||
void MidiDelay::AllNotesOff(bool justChannel = true, uint32 time = B_NOW) {
|
||||
snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE);
|
||||
for (uchar channel = 0; channel < 16; channel ++) {
|
||||
SprayControlChange(channel, B_ALL_NOTES_OFF, 0, time);
|
||||
}
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
|
||||
MidiDelay.h
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
A filter for Midi Kit 1 that sprays midi events
|
||||
when the performance time is reached.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _MIDI_DELAY_H
|
||||
#define _MIDI_DELAY_H
|
||||
|
||||
#include <Midi.h>
|
||||
|
||||
class MidiDelay : public BMidi {
|
||||
|
||||
static inline bigtime_t ToBigtime(uint32 time) { return time * (bigtime_t)1000; }
|
||||
|
||||
public:
|
||||
|
||||
virtual void NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
|
||||
|
||||
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
|
||||
|
||||
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,11 +0,0 @@
|
||||
#include <Midi.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class MidiMeter : public BMidi, BView
|
||||
{
|
||||
public:
|
||||
MidiMeter(void);
|
||||
|
||||
|
||||
};
|
Binary file not shown.
@ -1,326 +0,0 @@
|
||||
/*
|
||||
Author: Jerome LEVEQUE
|
||||
Email: jerl1@caramail.com
|
||||
*/
|
||||
#include "MidiPlayerView.h"
|
||||
#include "Scope.h"
|
||||
#include "Activity.h"
|
||||
|
||||
#include <StringView.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <MenuField.h>
|
||||
#include <Button.h>
|
||||
#include <Window.h>
|
||||
#include <Synth.h>
|
||||
#include <Directory.h>
|
||||
#include <Slider.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
MidiPlayerView::MidiPlayerView(void)
|
||||
: BView(BRect(0, 0, 660, 360), "StandartView",
|
||||
B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
fInputStringView = new BStringView(BRect(10, 20, 200, 40), NULL, "None");
|
||||
fOutputStringView = new BStringView(BRect(10, 20, 200, 40), NULL, "None");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
MidiPlayerView::~MidiPlayerView(void)
|
||||
{
|
||||
delete fInputStringView;
|
||||
delete fOutputStringView;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerView::AttachedToWindow(void)
|
||||
{
|
||||
BPopUpMenu *Menu = NULL;
|
||||
BMenuField *Field = NULL;
|
||||
BMessage *msg = NULL;
|
||||
|
||||
AddChild(fInputBox = new BBox(BRect(10, 0, 290, 170), "InputBox"));
|
||||
Menu = new BPopUpMenu("Select Input");
|
||||
msg = new BMessage(INPUT_CHANGE_TO_FILE);
|
||||
Menu->AddItem(new BMenuItem("From File", msg));
|
||||
msg = new BMessage(INPUT_CHANGE_TO_MIDIPORT);
|
||||
Menu->AddItem(new BMenuItem("From MidiPort", msg));
|
||||
Field = new BMenuField(BRect(0, 0, 150, 20), NULL, NULL, Menu);
|
||||
fInputBox->SetLabel((BView*)Field);
|
||||
|
||||
AddChild(fOutputBox = new BBox(BRect(10, 180, 290, 350), "OutputBox"));
|
||||
Menu = new BPopUpMenu("Select Output");
|
||||
msg = new BMessage(OUTPUT_CHANGE_TO_FILE);
|
||||
Menu->AddItem(new BMenuItem("To File", msg));
|
||||
msg = new BMessage(OUTPUT_CHANGE_TO_BEOS_SYNTH);
|
||||
Menu->AddItem(new BMenuItem("To BeOS Synth", msg));
|
||||
msg = new BMessage(OUTPUT_CHANGE_TO_BEOS_SYNTH_FILE);
|
||||
Menu->AddItem(new BMenuItem("To Midi Synth File", msg));
|
||||
msg = new BMessage(OUTPUT_CHANGE_TO_MIDIPORT);
|
||||
Menu->AddItem(new BMenuItem("To MidiPort", msg));
|
||||
Field = new BMenuField(BRect(0, 0, 150, 20), NULL, NULL, Menu);
|
||||
fOutputBox->SetLabel((BView*)Field);
|
||||
|
||||
AddChild(fViewBox = new BBox(BRect(300, 0, 650, 350), "OutputBox")); //Width = 350, High = 350
|
||||
Menu = new BPopUpMenu("Select View");
|
||||
msg = new BMessage(VIEW_CHANGE_TO_NONE);
|
||||
Menu->AddItem(new BMenuItem("None", msg));
|
||||
msg = new BMessage(VIEW_CHANGE_TO_SCOPE);
|
||||
Menu->AddItem(new BMenuItem("Scope", msg));
|
||||
msg = new BMessage(VIEW_CHANGE_TO_ACTIVITY);
|
||||
Menu->AddItem(new BMenuItem("Midi activity", msg));
|
||||
Field = new BMenuField(BRect(0, 0, 150, 20), NULL, NULL, Menu);
|
||||
fViewBox->SetLabel((BView*)Field);
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
BPopUpMenu *popupmenu = NULL;
|
||||
BMenuField *Field = NULL;
|
||||
Activity *view = NULL;
|
||||
switch (msg->what)
|
||||
{
|
||||
//--------------
|
||||
//--------------
|
||||
//For The Input
|
||||
//--------------
|
||||
case INPUT_CHANGE_TO_FILE :
|
||||
RemoveAll(fInputBox);
|
||||
fInputBox->AddChild(fInputStringView);
|
||||
fInputBox->AddChild(new BButton(BRect(220, 20, 270, 40), NULL, "Select", new BMessage(CHANGE_INPUT_FILE)));
|
||||
fInputBox->AddChild(new BButton(BRect(50, 140, 100, 160), NULL, "Rewind", new BMessage(REWIND_INPUT_FILE)));
|
||||
fInputBox->AddChild(new BButton(BRect(110, 140, 160, 160), NULL, "Play", new BMessage(PLAY_INPUT_FILE)));
|
||||
fInputBox->AddChild(new BButton(BRect(170, 140, 220, 160), NULL, "Pause", new BMessage(PAUSE_INPUT_FILE)));
|
||||
break;
|
||||
//--------------
|
||||
case INPUT_CHANGE_TO_MIDIPORT :
|
||||
RemoveAll(fInputBox);
|
||||
msg->FindPointer("Menu", (void**)&popupmenu);
|
||||
fInputBox->AddChild(Field = new BMenuField(BRect(10, 25, 280, 45), NULL, "Selected", popupmenu));
|
||||
Field->SetDivider(60);
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//For the Output
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_FILE :
|
||||
RemoveAll(fOutputBox);
|
||||
fOutputBox->AddChild(fOutputStringView);
|
||||
fOutputBox->AddChild(new BButton(BRect(220, 20, 270, 40), NULL, "Select", new BMessage(CHANGE_OUTPUT_FILE)));
|
||||
fOutputBox->AddChild(new BButton(BRect(50, 140, 100, 160), NULL, "Rewind", new BMessage(REWIND_OUTPUT_FILE)));
|
||||
fOutputBox->AddChild(new BButton(BRect(170, 140, 220, 160), NULL, "Save", new BMessage(SAVE_OUTPUT_FILE)));
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_BEOS_SYNTH :
|
||||
RemoveAll(fOutputBox);
|
||||
SetBeOSSynthView(fOutputBox);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_BEOS_SYNTH_FILE :
|
||||
RemoveAll(fOutputBox);
|
||||
fOutputBox->AddChild(fOutputStringView);
|
||||
fOutputBox->AddChild(new BButton(BRect(220, 20, 270, 40), NULL, "Select", new BMessage(CHANGE_BEOS_SYNTH_FILE)));
|
||||
fOutputBox->AddChild(new BButton(BRect(50, 140, 100, 160), NULL, "Rewind", new BMessage(REWIND_BEOS_SYNTH_FILE)));
|
||||
fOutputBox->AddChild(new BButton(BRect(110, 140, 160, 160), NULL, "Play", new BMessage(PLAY_BEOS_SYNTH_FILE)));
|
||||
fOutputBox->AddChild(new BButton(BRect(170, 140, 220, 160), NULL, "Pause", new BMessage(PAUSE_BEOS_SYNTH_FILE)));
|
||||
SetBeOSSynthView(fOutputBox);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_MIDIPORT :
|
||||
RemoveAll(fOutputBox);
|
||||
msg->FindPointer("Menu", (void**)&popupmenu);
|
||||
fOutputBox->AddChild(Field = new BMenuField(BRect(10, 25, 280, 45), NULL, "Selected", popupmenu));
|
||||
Field->SetDivider(60);
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//For the display view
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_NONE :
|
||||
RemoveAll(fViewBox);
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_SCOPE :
|
||||
RemoveAll(fViewBox);
|
||||
fViewBox->AddChild(new Scope(BRect(10, 25, 340, 340)));
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_ACTIVITY :
|
||||
RemoveAll(fViewBox);
|
||||
msg->FindPointer("View", (void**)&view);
|
||||
fViewBox->AddChild(view);
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
default: BView::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
BStringView *MidiPlayerView::GetInputStringView(void)
|
||||
{
|
||||
return fInputStringView;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
BStringView *MidiPlayerView::GetOutputStringView(void)
|
||||
{
|
||||
return fOutputStringView;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerView::RemoveAll(BView *aView)
|
||||
{//Remove and delete all view from aView exept the first one an TheStringView (delete)
|
||||
BView *Temp = NULL;
|
||||
aView->Window()->Lock();
|
||||
Temp = aView->ChildAt(1);
|
||||
while (Temp != NULL)
|
||||
{
|
||||
aView->RemoveChild(Temp);
|
||||
if ((Temp != fInputStringView) && (Temp != fOutputStringView))
|
||||
delete Temp;
|
||||
Temp = aView->ChildAt(1);
|
||||
}
|
||||
aView->Window()->Unlock();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerView::SetBeOSSynthView(BView *aView)
|
||||
{
|
||||
BPopUpMenu *Menu = NULL;
|
||||
BMenuField *field = NULL;
|
||||
BMessage *msg = NULL;
|
||||
BMenuItem *item = NULL;
|
||||
int32 temp = 0;
|
||||
|
||||
Menu = new BPopUpMenu("Sample Rate");
|
||||
temp = be_synth->SamplingRate();
|
||||
msg = new BMessage(CHANGE_SAMPLE_RATE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("11025 Hz", msg));
|
||||
if (temp == 11025) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_SAMPLE_RATE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("22050 Hz", msg));
|
||||
if (temp == 22050) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_SAMPLE_RATE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("44100 Hz", msg));
|
||||
if (temp == 44100) item->SetMarked(true);
|
||||
field = new BMenuField(BRect(5, 50, 145, 70), NULL, "Sampling Rate", Menu);
|
||||
aView->AddChild(field);
|
||||
|
||||
Menu = new BPopUpMenu("Interpolation");
|
||||
temp = be_synth->Interpolation();
|
||||
msg = new BMessage(CHANGE_INTERPOLATION_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Drop", msg));
|
||||
if (temp == B_DROP_SAMPLE) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_INTERPOLATION_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("2 points", msg));
|
||||
if (temp == B_2_POINT_INTERPOLATION) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_INTERPOLATION_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Linear", msg));
|
||||
if (temp == B_LINEAR_INTERPOLATION) item->SetMarked(true);
|
||||
field = new BMenuField(BRect(145, 50, 285, 70), NULL, "Interpolation", Menu);
|
||||
aView->AddChild(field);
|
||||
|
||||
Menu = new BPopUpMenu("Reverb");
|
||||
temp = be_synth->Reverb();
|
||||
msg = new BMessage(CHANGE_REVERB_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("None", msg));
|
||||
if (!be_synth->IsReverbEnabled())
|
||||
{
|
||||
item->SetMarked(true);
|
||||
temp = -1;
|
||||
}
|
||||
msg = new BMessage(CHANGE_REVERB_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Closet", msg));
|
||||
if (temp == B_REVERB_CLOSET) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_REVERB_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Garage", msg));
|
||||
if (temp == B_REVERB_GARAGE) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_REVERB_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Ballroom", msg));
|
||||
if (temp == B_REVERB_BALLROOM) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_REVERB_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Cavern", msg));
|
||||
if (temp == B_REVERB_CAVERN) item->SetMarked(true);
|
||||
msg = new BMessage(CHANGE_REVERB_TYPE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("Dungeon", msg));
|
||||
if (temp == B_REVERB_DUNGEON) item->SetMarked(true);
|
||||
field = new BMenuField(BRect(5, 75, 145, 95), NULL, "Reverb", Menu);
|
||||
aView->AddChild(field);
|
||||
|
||||
BDirectory dir = BDirectory(BEOS_SYNTH_DIRECTORY);
|
||||
entry_ref refs;
|
||||
Menu = new BPopUpMenu("Standart File");
|
||||
while (dir.GetNextRef(&refs) != B_ENTRY_NOT_FOUND)
|
||||
{
|
||||
msg = new BMessage(CHANGE_FILE_SAMPLE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem(refs.name, msg));
|
||||
}
|
||||
field = new BMenuField(BRect(145, 75, 285, 95), NULL, "File", Menu);
|
||||
field->SetDivider(25);
|
||||
aView->AddChild(field);
|
||||
|
||||
BSlider *slider = new BSlider(BRect(5, 100, 275, 130), NULL, "Volume",
|
||||
new BMessage(CHANGE_VOLUME_SYNTH),
|
||||
0, 1500, B_TRIANGLE_THUMB);
|
||||
temp = (int32)(be_synth->SynthVolume() * be_synth->SampleVolume() * 1000);
|
||||
slider->SetValue(temp);
|
||||
slider->SetLimitLabels("Min", "Max");
|
||||
aView->AddChild(slider);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
Author: Jerome LEVEQUE
|
||||
Email: jerl1@caramail.com
|
||||
*/
|
||||
#ifndef MIDI_PLAYER_VIEW_H
|
||||
#define MIDI_PLAYER_VIEW_H
|
||||
|
||||
#include <View.h>
|
||||
#include <Box.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
#define INPUT_CHANGE_TO_FILE 'icfi'
|
||||
#define INPUT_CHANGE_TO_MIDIPORT 'icmp'
|
||||
//--------------
|
||||
#define OUTPUT_CHANGE_TO_FILE 'ocfi'
|
||||
#define OUTPUT_CHANGE_TO_BEOS_SYNTH 'ocbs'
|
||||
#define OUTPUT_CHANGE_TO_BEOS_SYNTH_FILE 'ocbf'
|
||||
#define OUTPUT_CHANGE_TO_MIDIPORT 'ocmp'
|
||||
//--------------
|
||||
#define VIEW_CHANGE_TO_NONE 'vcno'
|
||||
#define VIEW_CHANGE_TO_SCOPE 'vcsc'
|
||||
#define VIEW_CHANGE_TO_ACTIVITY 'vcta'
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
#define REWIND_INPUT_FILE 'reif'
|
||||
#define PLAY_INPUT_FILE 'plif'
|
||||
#define PAUSE_INPUT_FILE 'paif'
|
||||
#define REWIND_OUTPUT_FILE 'reof'
|
||||
#define SAVE_OUTPUT_FILE 'saof'
|
||||
//--------------
|
||||
#define CHANGE_INPUT_FILE 'chif'
|
||||
#define CHANGE_OUTPUT_FILE 'chof'
|
||||
#define CHANGE_INPUT_MIDIPORT 'chim'
|
||||
#define CHANGE_OUTPUT_MIDIPORT 'chom'
|
||||
//--------------
|
||||
#define CHANGE_BEOS_SYNTH_FILE 'cbsf'
|
||||
#define REWIND_BEOS_SYNTH_FILE 'rbsf'
|
||||
#define PLAY_BEOS_SYNTH_FILE 'plsf'
|
||||
#define PAUSE_BEOS_SYNTH_FILE 'pasf'
|
||||
//--------------
|
||||
#define CHANGE_SAMPLE_RATE_SYNTH 'csrs'
|
||||
#define CHANGE_INTERPOLATION_TYPE_SYNTH 'cits'
|
||||
#define CHANGE_REVERB_TYPE_SYNTH 'crts'
|
||||
#define CHANGE_FILE_SAMPLE_SYNTH 'cfss'
|
||||
#define CHANGE_VOLUME_SYNTH 'cvos'
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
#define BEOS_SYNTH_DIRECTORY "/boot/beos/etc/synth/"
|
||||
//--------------
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
class MidiPlayerView : public BView
|
||||
{
|
||||
public:
|
||||
MidiPlayerView(void);
|
||||
~MidiPlayerView(void);
|
||||
|
||||
virtual void AttachedToWindow(void);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
BStringView *GetInputStringView(void);
|
||||
BStringView *GetOutputStringView(void);
|
||||
|
||||
void RemoveAll(BView *aView);
|
||||
void SetBeOSSynthView(BView *aView);
|
||||
|
||||
private:
|
||||
BBox *fInputBox;
|
||||
BBox *fOutputBox;
|
||||
BBox *fViewBox;
|
||||
|
||||
BStringView *fInputStringView;
|
||||
BStringView *fOutputStringView;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
#endif
|
@ -1,659 +0,0 @@
|
||||
/*
|
||||
Author: Jerome LEVEQUE
|
||||
Email: jerl1@caramail.com
|
||||
*/
|
||||
#include "MidiPlayerWindow.h"
|
||||
#include "MidiDelay.h"
|
||||
#include "Activity.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Roster.h>
|
||||
#include <Resources.h>
|
||||
#include <Alert.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <StringView.h>
|
||||
#include <String.h>
|
||||
#include <File.h>
|
||||
#include <MidiStore.h>
|
||||
#include <MidiPort.h>
|
||||
#include <MidiSynth.h>
|
||||
#include <MidiSynthFile.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
class MidiPlayerApp : public BApplication
|
||||
{
|
||||
public:
|
||||
MidiPlayerApp(void)
|
||||
: BApplication("application/x-vnd.MidiPlayer")
|
||||
{
|
||||
app_info info;
|
||||
BFile file;
|
||||
BResources resource;
|
||||
size_t len;
|
||||
GetAppInfo(&info);
|
||||
if (file.SetTo(&(info.ref), B_READ_ONLY) != B_OK) return;
|
||||
resource.SetTo(&file);
|
||||
BPoint *origin((BPoint*)resource.LoadResource('BPNT', "origin", &len));
|
||||
if (origin == NULL)
|
||||
fWindows = new MidiPlayerWindow(BPoint(100.0, 100.0));
|
||||
else
|
||||
fWindows = new MidiPlayerWindow(*origin);
|
||||
}
|
||||
|
||||
//--------------
|
||||
|
||||
void ReadyToRun(void)
|
||||
{
|
||||
fWindows->Show();
|
||||
}
|
||||
|
||||
//--------------
|
||||
|
||||
void SetOrigin(BPoint origin)
|
||||
{
|
||||
app_info info;
|
||||
BFile file;
|
||||
BResources resource;
|
||||
int32 temp;
|
||||
GetAppInfo(&info);
|
||||
if (file.SetTo(&(info.ref), B_READ_WRITE) != B_OK) return;
|
||||
resource.SetTo(&file);
|
||||
temp = resource.RemoveResource('BPNT', 1);
|
||||
temp = resource.AddResource('BPNT', 1, &origin, sizeof(origin), "origin");
|
||||
}
|
||||
|
||||
//--------------
|
||||
|
||||
virtual void RefsReceived(BMessage *message)
|
||||
{
|
||||
message->what = B_SIMPLE_DATA;
|
||||
fWindows->PostMessage(message);
|
||||
}
|
||||
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
|
||||
private:
|
||||
MidiPlayerWindow *fWindows;
|
||||
|
||||
//--------------
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
MidiPlayerWindow::MidiPlayerWindow(BPoint start)
|
||||
: BWindow(BRect(start, start + BPoint(660, 360)), "Midi Player",
|
||||
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE),
|
||||
fMidiInput(NULL),
|
||||
fMidiOutput(NULL),
|
||||
fMidiDisplay(NULL),
|
||||
fInputType(0),
|
||||
fOutputType(0),
|
||||
fDisplayType(0),
|
||||
fInputFilePanel(NULL),
|
||||
fOutputFilePanel(NULL),
|
||||
fInputCurrentEvent(0),
|
||||
fOutputCurrentEvent(0)
|
||||
{
|
||||
AddChild(fStandartView = new MidiPlayerView());
|
||||
fMidiDelay = new MidiDelay();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
MidiPlayerWindow::~MidiPlayerWindow(void)
|
||||
{
|
||||
Disconnect();
|
||||
delete fMidiInput;
|
||||
delete fMidiOutput;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
bool MidiPlayerWindow::QuitRequested(void)
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerWindow::FrameMoved(BPoint origin)
|
||||
{
|
||||
((MidiPlayerApp*)be_app)->SetOrigin(origin);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
uint32 temp = 0;
|
||||
BPopUpMenu *MidiPortMenu = NULL;
|
||||
BMenuItem *item = NULL;
|
||||
BMessage message;
|
||||
entry_ref ref;
|
||||
switch (msg->what)
|
||||
{
|
||||
//--------------
|
||||
//For The Input
|
||||
//--------------
|
||||
//--------------
|
||||
case INPUT_CHANGE_TO_FILE :
|
||||
if (fInputType == FILE)
|
||||
break;
|
||||
fInputType = FILE;
|
||||
Disconnect();
|
||||
delete fMidiInput;
|
||||
fMidiInput = new BMidiStore();
|
||||
if (!fMidiInput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiStore object", "OK"))->Go();
|
||||
break;
|
||||
}
|
||||
Connect();
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case INPUT_CHANGE_TO_MIDIPORT :
|
||||
if (fInputType == MIDIPORT)
|
||||
break;
|
||||
fInputType = MIDIPORT;
|
||||
Disconnect();
|
||||
delete fMidiInput;
|
||||
fMidiInput = new BMidiPort();
|
||||
if (!fMidiInput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiPort object", "OK"))->Go();
|
||||
break;
|
||||
}
|
||||
MidiPortMenu = new BPopUpMenu("Midi Port");
|
||||
for(int i = ((BMidiPort*)fMidiInput)->CountDevices(); i > 0; i--)
|
||||
{
|
||||
char name[B_OS_NAME_LENGTH];
|
||||
((BMidiPort*)fMidiInput)->GetDeviceName(i - 1, name);
|
||||
MidiPortMenu->AddItem(new BMenuItem(name, new BMessage(CHANGE_INPUT_MIDIPORT)));
|
||||
}
|
||||
msg->AddPointer("Menu", MidiPortMenu);
|
||||
Connect();
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
//For the Output
|
||||
//--------------
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_FILE :
|
||||
if (fOutputType == FILE)
|
||||
break;
|
||||
fOutputType = FILE;
|
||||
Disconnect();
|
||||
delete fMidiOutput;
|
||||
fMidiOutput = new BMidiStore();
|
||||
if (!fMidiOutput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiStore object", "OK"))->Go();
|
||||
break;
|
||||
}
|
||||
Connect();
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_BEOS_SYNTH :
|
||||
if (fOutputType == BEOS_SYNTH)
|
||||
break;
|
||||
fOutputType = BEOS_SYNTH;
|
||||
Disconnect();
|
||||
delete fMidiOutput;
|
||||
fMidiOutput = new BMidiSynth();
|
||||
if (!fMidiOutput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiSynth object", "OK"))->Go();
|
||||
break;
|
||||
}
|
||||
Connect();
|
||||
((BMidiSynth*)fMidiOutput)->EnableInput(true, true);
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_BEOS_SYNTH_FILE :
|
||||
if (fOutputType == BEOS_SYNTH_FILE)
|
||||
break;
|
||||
fOutputType = BEOS_SYNTH_FILE;
|
||||
Disconnect();
|
||||
delete fMidiOutput;
|
||||
fMidiOutput = new BMidiSynthFile();
|
||||
if (!fMidiOutput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiSynth object", "OK"))->Go();
|
||||
break;
|
||||
}
|
||||
Connect();
|
||||
((BMidiSynthFile*)fMidiOutput)->EnableInput(true, true);
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_MIDIPORT :
|
||||
if (fOutputType == MIDIPORT)
|
||||
break;
|
||||
fOutputType = MIDIPORT;
|
||||
Disconnect();
|
||||
delete fMidiOutput;
|
||||
fMidiOutput = new BMidiPort();
|
||||
if (!fMidiOutput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiPort object", "OK"))->Go();
|
||||
break;
|
||||
}
|
||||
MidiPortMenu = new BPopUpMenu("Midi Port");
|
||||
for(int i = ((BMidiPort*)fMidiOutput)->CountDevices(); i > 0; i--)
|
||||
{
|
||||
char name[B_OS_NAME_LENGTH];
|
||||
((BMidiPort*)fMidiOutput)->GetDeviceName(i - 1, name);
|
||||
MidiPortMenu->AddItem(new BMenuItem(name, new BMessage(CHANGE_OUTPUT_MIDIPORT)));
|
||||
}
|
||||
msg->AddPointer("Menu", MidiPortMenu);
|
||||
Connect();
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
//For the display view
|
||||
//--------------
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_NONE :
|
||||
if (fDisplayType == 0)
|
||||
break;
|
||||
fDisplayType = 0;
|
||||
if (fMidiDisplay != NULL)
|
||||
fMidiDelay->Disconnect(fMidiDisplay); //Object will be deleted in MidiPlayerView::RemoveAll
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_SCOPE :
|
||||
if (fDisplayType == SCOPE)
|
||||
break;
|
||||
fDisplayType = SCOPE;
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_ACTIVITY :
|
||||
if (fDisplayType == ACTIVITY)
|
||||
break;
|
||||
fDisplayType = ACTIVITY;
|
||||
fMidiDisplay = (BMidi*)new Activity(BRect(10, 25, 340, 340));
|
||||
fMidiDelay->Connect(fMidiDisplay);
|
||||
((Activity*)fMidiDisplay)->Start();
|
||||
msg->AddPointer("View", fMidiDisplay);
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//Message from Input file
|
||||
//--------------
|
||||
case CHANGE_INPUT_FILE :
|
||||
if (fInputFilePanel)
|
||||
{
|
||||
entry_ref File;
|
||||
if (msg->FindRef("refs", &File) != B_OK)
|
||||
break;
|
||||
Disconnect();
|
||||
delete fMidiInput;
|
||||
fMidiInput = new BMidiStore();
|
||||
if (!fMidiInput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiPort object", "OK"))->Go();
|
||||
return;
|
||||
}
|
||||
Connect();
|
||||
if (((BMidiStore*)fMidiInput)->Import(&File) == B_OK)
|
||||
{
|
||||
BStringView *aStringView = fStandartView->GetInputStringView();
|
||||
aStringView->SetText(File.name);
|
||||
}
|
||||
delete fInputFilePanel;
|
||||
fInputFilePanel = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
BMessenger messenger(this)
|
||||
fInputFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger,
|
||||
NULL, B_FILE_NODE, false, msg);
|
||||
fInputFilePanel->Show();
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case REWIND_INPUT_FILE :
|
||||
((BMidiStore*)fMidiInput)->Stop();
|
||||
if (fMidiOutput) fMidiOutput->AllNotesOff();
|
||||
fInputCurrentEvent = 0;
|
||||
return;
|
||||
//--------------
|
||||
case PLAY_INPUT_FILE :
|
||||
((BMidiStore*)fMidiInput)->SetCurrentEvent(fInputCurrentEvent);
|
||||
((BMidiStore*)fMidiInput)->Start();
|
||||
break;
|
||||
//--------------
|
||||
case PAUSE_INPUT_FILE :
|
||||
fInputCurrentEvent = ((BMidiStore*)fMidiInput)->CurrentEvent();
|
||||
((BMidiStore*)fMidiInput)->Stop();
|
||||
if (fMidiOutput) fMidiOutput->AllNotesOff();
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//Message from Output file
|
||||
//--------------
|
||||
case CHANGE_OUTPUT_FILE :
|
||||
if (fOutputFilePanel)
|
||||
{
|
||||
const char *filename;
|
||||
msg->FindRef("directory", &fOutputFile);
|
||||
msg->FindString("name", &filename);
|
||||
BDirectory path(&fOutputFile);
|
||||
BFile fichier(&path, filename, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
if (fichier.InitCheck() == B_OK)
|
||||
{
|
||||
BStringView *aStringView = fStandartView->GetOutputStringView();
|
||||
BEntry entry(&path, filename);
|
||||
entry.GetRef(&fOutputFile);
|
||||
aStringView->SetText(fOutputFile.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
(new BAlert(NULL, "Can't Create File", "OK"))->Go();
|
||||
}
|
||||
delete fOutputFilePanel;
|
||||
fOutputFilePanel = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
BMessenger messenger(this)
|
||||
fOutputFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger,
|
||||
NULL, B_FILE_NODE, false, msg);
|
||||
fOutputFilePanel->Show();
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case REWIND_OUTPUT_FILE :
|
||||
Disconnect();
|
||||
delete fMidiOutput;
|
||||
fMidiOutput = new BMidiPort();
|
||||
if (!fMidiOutput)
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise a BMidiPort object", "OK"))->Go();
|
||||
return;
|
||||
}
|
||||
Connect();
|
||||
fOutputCurrentEvent = 0;
|
||||
return;
|
||||
//--------------
|
||||
case SAVE_OUTPUT_FILE :
|
||||
((BMidiStore*)fMidiOutput)->Export(&fOutputFile, 0);
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//Message from the input Midiport
|
||||
//--------------
|
||||
case CHANGE_INPUT_MIDIPORT :
|
||||
if (msg->FindPointer("source", (void**)&item) == B_OK)
|
||||
{
|
||||
((BMidiPort*)fMidiInput)->Open(item->Label());
|
||||
((BMidiPort*)fMidiInput)->Start();
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//Message from the output Midiport
|
||||
//--------------
|
||||
case CHANGE_OUTPUT_MIDIPORT :
|
||||
if (msg->FindPointer("source", (void**)&item) == B_OK)
|
||||
{
|
||||
((BMidiPort*)fMidiOutput)->Open(item->Label());
|
||||
((BMidiPort*)fMidiOutput)->Start();
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//Message from the BeOS Synth
|
||||
//--------------
|
||||
case CHANGE_BEOS_SYNTH_FILE:
|
||||
if (fOutputFilePanel)
|
||||
{
|
||||
msg->FindRef("refs", &fOutputFile);
|
||||
((BMidiSynthFile*)fMidiOutput)->UnloadFile();
|
||||
if (((BMidiSynthFile*)fMidiOutput)->LoadFile(&fOutputFile) == B_OK)
|
||||
{
|
||||
BStringView *aStringView = fStandartView->GetOutputStringView();
|
||||
aStringView->SetText(fOutputFile.name);
|
||||
}
|
||||
delete fOutputFilePanel;
|
||||
fOutputFilePanel = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
BMessenger messenger(this)
|
||||
fOutputFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger,
|
||||
NULL, B_FILE_NODE, false, msg);
|
||||
fOutputFilePanel->Show();
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case REWIND_BEOS_SYNTH_FILE :
|
||||
((BMidiSynthFile*)fMidiOutput)->Stop();
|
||||
fOutputCurrentEvent = 0;
|
||||
return;
|
||||
//--------------
|
||||
case PLAY_BEOS_SYNTH_FILE :
|
||||
if (fOutputCurrentEvent == 1)
|
||||
((BMidiSynthFile*)fMidiOutput)->Resume();
|
||||
else
|
||||
((BMidiSynthFile*)fMidiOutput)->Start();
|
||||
fOutputCurrentEvent = 0;
|
||||
break;
|
||||
//--------------
|
||||
case PAUSE_BEOS_SYNTH_FILE :
|
||||
fOutputCurrentEvent = 1;
|
||||
((BMidiSynthFile*)fMidiOutput)->Pause();
|
||||
break;
|
||||
//--------------
|
||||
case CHANGE_SAMPLE_RATE_SYNTH :
|
||||
msg->FindInt32("index", (int32*)&temp);
|
||||
switch(temp)
|
||||
{
|
||||
case 0 : be_synth->SetSamplingRate(11025); break;
|
||||
case 1 : be_synth->SetSamplingRate(22050); break;
|
||||
case 2 : be_synth->SetSamplingRate(44100); break;
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case CHANGE_INTERPOLATION_TYPE_SYNTH :
|
||||
msg->FindInt32("index", (int32*)&temp);
|
||||
switch(temp)
|
||||
{
|
||||
case 0 : be_synth->SetInterpolation(B_DROP_SAMPLE); break;
|
||||
case 1 : be_synth->SetInterpolation(B_2_POINT_INTERPOLATION); break;
|
||||
case 2 : be_synth->SetInterpolation(B_LINEAR_INTERPOLATION); break;
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case CHANGE_REVERB_TYPE_SYNTH :
|
||||
msg->FindInt32("index", (int32*)&temp);
|
||||
switch(temp)
|
||||
{
|
||||
case 0 :
|
||||
be_synth->EnableReverb(false);
|
||||
break;
|
||||
case 1 :
|
||||
be_synth->EnableReverb(true);
|
||||
be_synth->SetReverb(B_REVERB_CLOSET);
|
||||
break;
|
||||
case 2 :
|
||||
be_synth->EnableReverb(true);
|
||||
be_synth->SetReverb(B_REVERB_GARAGE);
|
||||
break;
|
||||
case 3 :
|
||||
be_synth->EnableReverb(true);
|
||||
be_synth->SetReverb(B_REVERB_BALLROOM);
|
||||
break;
|
||||
case 4 :
|
||||
be_synth->EnableReverb(true);
|
||||
be_synth->SetReverb(B_REVERB_CAVERN);
|
||||
break;
|
||||
case 5 :
|
||||
be_synth->EnableReverb(true);
|
||||
be_synth->SetReverb(B_REVERB_DUNGEON);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case CHANGE_FILE_SAMPLE_SYNTH :
|
||||
if (msg->FindPointer("source", (void**)&item) == B_OK)
|
||||
{
|
||||
BString path = BString(BEOS_SYNTH_DIRECTORY);
|
||||
path += item->Label();
|
||||
BEntry entry = BEntry(path.String());
|
||||
if (entry.InitCheck() == B_OK)
|
||||
{
|
||||
entry_ref ref;
|
||||
be_synth->Unload();
|
||||
entry.GetRef(&ref);
|
||||
be_synth->LoadSynthData(&ref);
|
||||
((BMidiSynth*)fMidiOutput)->EnableInput(true, true);
|
||||
if (!be_synth->IsLoaded())
|
||||
{
|
||||
(new BAlert(NULL, "Instrument File can't be loaded correctly", "OK"))->Go();
|
||||
}
|
||||
((BMidiSynthFile*)fMidiOutput)->LoadFile(&fOutputFile);
|
||||
((BMidiSynthFile*)fMidiOutput)->Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
(new BAlert(NULL, "Can't initialise instrument File", "OK"))->Go();
|
||||
}
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case CHANGE_VOLUME_SYNTH :
|
||||
msg->FindInt32("be:value", (int32*)&temp);
|
||||
be_synth->SetSynthVolume(temp / 1000.0);
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//For the drag and drop function
|
||||
//--------------
|
||||
case B_SIMPLE_DATA : //A file had been dropped into application
|
||||
if (msg->FindRef("refs", &ref) == B_OK)
|
||||
{
|
||||
message = BMessage(INPUT_CHANGE_TO_FILE);
|
||||
PostMessage(&message);
|
||||
message = BMessage(*msg);
|
||||
message.what = CHANGE_INPUT_FILE;
|
||||
BMessenger messenger(this)
|
||||
fInputFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger,
|
||||
NULL, B_FILE_NODE, false, msg);;
|
||||
PostMessage(&message);
|
||||
message = BMessage(OUTPUT_CHANGE_TO_BEOS_SYNTH);
|
||||
PostMessage(&message);
|
||||
message = BMessage(PLAY_INPUT_FILE);
|
||||
PostMessage(&message);
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
case B_CANCEL :
|
||||
msg->FindInt32("old_what", (int32*)&temp);
|
||||
if (temp == CHANGE_INPUT_FILE)
|
||||
{
|
||||
delete fInputFilePanel;
|
||||
fInputFilePanel = NULL;
|
||||
}
|
||||
if (temp == CHANGE_OUTPUT_FILE)
|
||||
{
|
||||
delete fOutputFilePanel;
|
||||
fOutputFilePanel = NULL;
|
||||
}
|
||||
break;
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
//--------------
|
||||
default : BWindow::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerWindow::Disconnect(void)
|
||||
{//This function must be rewrited for a better disconnection
|
||||
if (fMidiInput != NULL)
|
||||
{
|
||||
fMidiInput->AllNotesOff(false);
|
||||
fMidiInput->Disconnect(fMidiDelay);
|
||||
}
|
||||
if (fMidiOutput != NULL)
|
||||
{
|
||||
fMidiOutput->AllNotesOff(false);
|
||||
fMidiDelay->Disconnect(fMidiOutput);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void MidiPlayerWindow::Connect(void)
|
||||
{//This function must be rewrited for a better connection
|
||||
if (fMidiInput != NULL)
|
||||
fMidiInput->Connect(fMidiDelay);
|
||||
if (fMidiOutput != NULL)
|
||||
fMidiDelay->Connect(fMidiOutput);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
MidiPlayerApp *App = new MidiPlayerApp();
|
||||
App->Run();
|
||||
delete App;
|
||||
return B_NO_ERROR;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
Author: Jerome LEVEQUE
|
||||
Email: jerl1@caramail.com
|
||||
*/
|
||||
#ifndef MIDI_PLAYER_WINDOW_H
|
||||
#define MIDI_PLAYER_WINDOW_H
|
||||
|
||||
#include "MidiPlayerView.h"
|
||||
|
||||
#include <Window.h>
|
||||
#include <Midi.h>
|
||||
#include <FilePanel.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
#define FILE 'file'
|
||||
#define BEOS_SYNTH 'besy'
|
||||
#define BEOS_SYNTH_FILE 'besf'
|
||||
#define MIDIPORT 'mipo'
|
||||
//--------------
|
||||
#define SCOPE 'scop'
|
||||
#define ACTIVITY 'actv'
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
class MidiPlayerWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
MidiPlayerWindow(BPoint start);
|
||||
~MidiPlayerWindow(void);
|
||||
|
||||
virtual bool QuitRequested(void);
|
||||
virtual void FrameMoved(BPoint origin);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
virtual void Disconnect(void);
|
||||
virtual void Connect(void);
|
||||
|
||||
private:
|
||||
MidiPlayerView *fStandartView;
|
||||
|
||||
BMidi *fMidiInput;
|
||||
BMidi *fMidiOutput;
|
||||
BMidi *fMidiDisplay;
|
||||
BMidi *fMidiDelay;
|
||||
|
||||
uint32 fInputType;
|
||||
uint32 fOutputType;
|
||||
uint32 fDisplayType;
|
||||
|
||||
BFilePanel *fInputFilePanel;
|
||||
BFilePanel *fOutputFilePanel;
|
||||
|
||||
entry_ref fOutputFile;
|
||||
|
||||
uint32 fInputCurrentEvent;
|
||||
uint32 fOutputCurrentEvent;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
#endif
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
Author: Michael Pfeiffer
|
||||
Email: michael.pfeiffer@utanet.at
|
||||
*/
|
||||
#include "Scope.h"
|
||||
|
||||
#include <MessageQueue.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Synth.h>
|
||||
#include <Window.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
Scope::Scope(BRect rect) :
|
||||
BView(rect, NULL,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_PULSE_NEEDED) {
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
|
||||
mWidth = (int) rect.Width(); mHeight = (int)rect.Height();
|
||||
mSampleCount = mWidth;
|
||||
mLeft = new int16[mSampleCount]; mRight = new int16[mSampleCount];
|
||||
|
||||
mBitmap = new BBitmap(BRect(0, 0, mWidth, mHeight), B_RGB_16_BIT, true, true);
|
||||
if (mBitmap->Lock()) {
|
||||
mOffscreenView = new BView(mBitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
mOffscreenView->SetHighColor(0, 0, 0, 0);
|
||||
|
||||
mBitmap->AddChild(mOffscreenView);
|
||||
mOffscreenView->FillRect(mBitmap->Bounds());
|
||||
mOffscreenView->Sync();
|
||||
mBitmap->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Scope::Draw(BRect updateRect) {
|
||||
DrawBitmap(mBitmap, BPoint(0, 0));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Scope::DrawSample() {
|
||||
int32 size = be_synth->GetAudio(mLeft, mRight, mSampleCount);
|
||||
|
||||
if (mBitmap->Lock()) {
|
||||
mOffscreenView->SetHighColor(0, 0, 0, 0);
|
||||
mOffscreenView->FillRect(mBitmap->Bounds());
|
||||
if (size > 0) {
|
||||
mOffscreenView->SetHighColor(255, 0, 0, 0);
|
||||
mOffscreenView->SetLowColor(0, 255, 0, 0);
|
||||
#define N 16
|
||||
int32 x, y, sx = 0, f = (mHeight << N) / 65535, dy = mHeight / 2;
|
||||
for (int32 i = 0; i < mWidth; i++) {
|
||||
x = sx / mWidth;
|
||||
y = ((mLeft[x] * f) >> N) + dy;
|
||||
mOffscreenView->FillRect(BRect(i, y, i, y));
|
||||
y = ((mRight[x] * f) >> N) + dy;
|
||||
mOffscreenView->FillRect(BRect(i, y, i, y), B_SOLID_LOW);
|
||||
sx += size;
|
||||
}
|
||||
}
|
||||
mOffscreenView->Flush();
|
||||
mBitmap->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
#define PULSE_RATE 1 * 100000
|
||||
void Scope::AttachedToWindow(void) {
|
||||
Window()->SetPulseRate(PULSE_RATE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Scope::DetachedFromWindow(void) {
|
||||
Window()->SetPulseRate(0);
|
||||
delete mLeft; delete mRight;
|
||||
|
||||
if (mBitmap->Lock()) {
|
||||
mBitmap->RemoveChild(mOffscreenView);
|
||||
delete mOffscreenView;
|
||||
mBitmap->Unlock();
|
||||
}
|
||||
delete mBitmap;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
void Scope::Pulse() {
|
||||
DrawSample();
|
||||
BMessage *m;
|
||||
BMessageQueue *mq = Window()->MessageQueue();
|
||||
int i = 0;
|
||||
while ((m = mq->FindMessage(B_PULSE, 0)) != NULL) mq->RemoveMessage(m), i++;
|
||||
Invalidate();
|
||||
}
|
||||
//----------------------------------------------------------
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
Author: Michael Pfeiffer
|
||||
Email: michael.pfeiffer@utanet.at
|
||||
*/
|
||||
#ifndef SCOPE_H
|
||||
#define SCOPE_H
|
||||
|
||||
#include <View.h>
|
||||
|
||||
class Scope : public BView {
|
||||
BBitmap *mBitmap;
|
||||
BView *mOffscreenView;
|
||||
int mWidth, mHeight;
|
||||
int32 mSampleCount;
|
||||
int16 *mLeft, *mRight;
|
||||
public:
|
||||
Scope(BRect rect);
|
||||
|
||||
void Draw(BRect updateRect);
|
||||
void DrawSample();
|
||||
|
||||
void Pulse();
|
||||
void AttachedToWindow(void);
|
||||
void DetachedFromWindow(void);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
SubDir HAIKU_TOP src tests kits midi synth_file_reader ;
|
||||
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
SimpleTest sfr
|
||||
: SynthFileReader.cpp
|
||||
SynthFile.cpp
|
||||
|
@ -77,9 +77,9 @@ SInstrument::SInstrument(uint8 instrument)
|
||||
|
||||
// SSynthFile
|
||||
|
||||
static int bySoundId(const SSound** a, const SSound** b)
|
||||
static int bySoundId(const SSound* a, const SSound* b)
|
||||
{
|
||||
return (*a)->Id() - (*b)->Id();
|
||||
return (a)->Id() - (b)->Id();
|
||||
}
|
||||
|
||||
SSynthFile::SSynthFile(const char* fileName)
|
||||
@ -123,8 +123,7 @@ void
|
||||
SSynthFile::InstrumentAtPut(int i, SInstrument* instr)
|
||||
{
|
||||
ASSERT(fInstruments.CountItems() == 128);
|
||||
SInstrument** array = (SInstrument**)fInstruments.Items();
|
||||
array[i] = instr;
|
||||
fInstruments.ReplaceItem(i, instr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
||||
#define _SYNTH_FILE_H
|
||||
|
||||
#include "SynthFileReader.h"
|
||||
#include "TList.h"
|
||||
#include <ObjectList.h>
|
||||
|
||||
|
||||
class SSound {
|
||||
@ -85,7 +85,7 @@ class SInstrument {
|
||||
uint8 fId;
|
||||
BString fName;
|
||||
SSound* fDefaultSound;
|
||||
TList<SSoundInRange> fSounds;
|
||||
BObjectList<SSoundInRange> fSounds;
|
||||
|
||||
public:
|
||||
SInstrument(uint8 instrument);
|
||||
@ -101,15 +101,15 @@ public:
|
||||
void SetDefaultSound(SSound* sound) { fDefaultSound = sound; }
|
||||
SSound* DefaultSound() const { return fDefaultSound; }
|
||||
|
||||
TList<SSoundInRange>* Sounds() { return &fSounds; }
|
||||
BObjectList<SSoundInRange>* Sounds() { return &fSounds; }
|
||||
};
|
||||
|
||||
|
||||
class SSynthFile;
|
||||
|
||||
class SSynthFile {
|
||||
TList<SInstrument> fInstruments;
|
||||
TList<SSound> fSounds;
|
||||
BObjectList<SInstrument> fInstruments;
|
||||
BObjectList<SSound> fSounds;
|
||||
SSynthFileReader fReader;
|
||||
status_t fStatus;
|
||||
|
||||
|
@ -279,7 +279,7 @@ void SSynthFileReader::Dump(bool play, uint32 instrOnly) {
|
||||
Read(elems);
|
||||
rest -= 4;
|
||||
|
||||
printf("elems = %ld\n", elems);
|
||||
printf("elems = %d\n", elems);
|
||||
|
||||
if (elems > 0 || rest >= 16) {
|
||||
Dump(elems * 8 + 21); printf("\n");
|
||||
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
|
||||
TList.h
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO: Move this header file into a "common" directory!
|
||||
This class is an minor extended version of the one found in
|
||||
current/src/add-ons/print/drivers/pdf/source
|
||||
*/
|
||||
|
||||
#ifndef _TLIST_H
|
||||
#define _TLIST_H
|
||||
|
||||
#include <List.h>
|
||||
|
||||
template <class T>
|
||||
class TList {
|
||||
private:
|
||||
BList fList;
|
||||
bool fOwnsItems;
|
||||
|
||||
typedef int (*sort_func)(const void*, const void*);
|
||||
|
||||
public:
|
||||
TList(bool ownsItems = true) : fOwnsItems(ownsItems) { }
|
||||
virtual ~TList();
|
||||
void MakeEmpty();
|
||||
int32 CountItems() const;
|
||||
T* ItemAt(int32 index) const;
|
||||
void AddItem(T* p);
|
||||
T* Items();
|
||||
void SortItems(int (*comp)(const T**, const T**));
|
||||
|
||||
};
|
||||
|
||||
// TList
|
||||
template<class T>
|
||||
TList<T>::~TList() {
|
||||
MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::MakeEmpty() {
|
||||
const int32 n = CountItems();
|
||||
if (fOwnsItems) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
delete ItemAt(i);
|
||||
}
|
||||
}
|
||||
fList.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
int32 TList<T>::CountItems() const {
|
||||
return fList.CountItems();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::ItemAt(int32 index) const {
|
||||
return (T*)fList.ItemAt(index);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::AddItem(T* p) {
|
||||
fList.AddItem(p);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::Items() {
|
||||
return (T*)fList.Items();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::SortItems(int (*comp)(const T**, const T**)) {
|
||||
sort_func sort = (sort_func)comp;
|
||||
fList.SortItems(sort);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user