2003-03-17 22:30:19 +00:00
|
|
|
/*
|
2006-07-06 08:56:18 +00:00
|
|
|
* Copyright 2006, Haiku.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2002-2003 Matthijs Hollemans
|
|
|
|
|
* Copyright (c) 2002 Jerome Leveque
|
|
|
|
|
* Copyright (c) 2002 Paul Stadler
|
2006-06-19 13:24:04 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
2002-11-01 15:07:39 +00:00
|
|
|
*
|
2006-06-19 13:24:04 +00:00
|
|
|
* Authors:
|
|
|
|
|
* Jérôme Leveque
|
|
|
|
|
* Matthijs Hollemans
|
|
|
|
|
* Paul Stadler
|
2002-11-01 15:07:39 +00:00
|
|
|
*/
|
|
|
|
|
|
2003-03-17 22:30:19 +00:00
|
|
|
#include <stdio.h>
|
2006-06-19 13:24:04 +00:00
|
|
|
#include <MidiText.h>
|
2002-11-01 15:07:39 +00:00
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
BMidiText::BMidiText()
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
fStartTime = 0;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
|
|
|
|
BMidiText::~BMidiText()
|
|
|
|
|
{
|
2003-03-17 22:30:19 +00:00
|
|
|
// do nothing
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::NoteOff(
|
2002-11-01 15:07:39 +00:00
|
|
|
uchar channel, uchar note, uchar velocity, uint32 time)
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"B_NOTE OFF; channel = %d, note = %d, velocity = %d\n",
|
|
|
|
|
channel, note, velocity);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::NoteOn(
|
2002-11-01 15:07:39 +00:00
|
|
|
uchar channel, uchar note, uchar velocity, uint32 time)
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"B_NOTE ON; channel = %d, note = %d, velocity = %d\n",
|
|
|
|
|
channel, note, velocity);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::KeyPressure(
|
2002-11-01 15:07:39 +00:00
|
|
|
uchar channel, uchar note, uchar pressure, uint32 time)
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"KEY PRESSURE; channel = %d, note = %d, pressure = %d\n",
|
|
|
|
|
channel, note, pressure);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::ControlChange(
|
2002-11-01 15:07:39 +00:00
|
|
|
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"CONTROL CHANGE; channel = %d, control = %d, value = %d\n",
|
|
|
|
|
channel, controlNumber, controlValue);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::ProgramChange(
|
2002-11-01 15:07:39 +00:00
|
|
|
uchar channel, uchar programNumber, uint32 time)
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"PROGRAM CHANGE; channel = %d, program = %d\n",
|
|
|
|
|
channel, programNumber);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::ChannelPressure(uchar channel, uchar pressure, uint32 time)
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"CHANNEL PRESSURE; channel = %d, pressure = %d\n",
|
|
|
|
|
channel, pressure);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"PITCH BEND; channel = %d, lsb = %d, msb = %d\n",
|
|
|
|
|
channel, lsb, msb);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::SystemExclusive(void* data, size_t length, uint32 time)
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2003-03-17 22:30:19 +00:00
|
|
|
printf("SYSTEM EXCLUSIVE;\n");
|
|
|
|
|
for (size_t t = 0; t < length; ++t)
|
|
|
|
|
printf("%02X ", ((uint8*) data)[t]);
|
|
|
|
|
printf("\n");
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::SystemCommon(
|
2002-11-01 15:07:39 +00:00
|
|
|
uchar status, uchar data1, uchar data2, uint32 time)
|
|
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf(
|
|
|
|
|
"SYSTEM COMMON; status = %d, data1 = %d, data2 = %d\n",
|
|
|
|
|
status, data1, data2);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::SystemRealTime(uchar status, uint32 time)
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
_WaitAndPrint(time);
|
2003-03-17 22:30:19 +00:00
|
|
|
printf("SYSTEM REAL TIME; status = %d\n", status);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::ResetTimer(bool start)
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
fStartTime = start ? B_NOW : 0;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
|
|
|
|
void BMidiText::_ReservedMidiText1() { }
|
2003-03-17 22:30:19 +00:00
|
|
|
void BMidiText::_ReservedMidiText2() { }
|
|
|
|
|
void BMidiText::_ReservedMidiText3() { }
|
2002-11-01 15:07:39 +00:00
|
|
|
|
|
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::Run()
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
|
|
|
|
while (KeepRunning())
|
|
|
|
|
snooze(50000);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-01 15:07:39 +00:00
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
void
|
|
|
|
|
BMidiText::_WaitAndPrint(uint32 time)
|
2002-11-01 15:07:39 +00:00
|
|
|
{
|
2006-06-19 13:24:04 +00:00
|
|
|
if (fStartTime == 0)
|
|
|
|
|
fStartTime = time;
|
2002-11-01 15:07:39 +00:00
|
|
|
|
|
|
|
|
SnoozeUntil(time);
|
|
|
|
|
|
2006-06-19 13:24:04 +00:00
|
|
|
printf("%lu: ", time - fStartTime);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
2002-11-01 15:07:39 +00:00
|
|
|
|