Files
haiku-beta6/src/kits/midi/MidiText.cpp
T

187 lines
5.0 KiB
C++
Raw Normal View History

2003-03-17 22:30:19 +00:00
/*
* Copyright (c) 2002-2003 Matthijs Hollemans
* Copyright (c) 2002 Jerome Leveque
* Copyright (c) 2002 Paul Stadler
*
2003-03-17 22:30:19 +00:00
* 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.
*/
2003-03-17 22:30:19 +00:00
#include <stdio.h>
#include "debug.h"
#include "MidiText.h"
//------------------------------------------------------------------------------
2002-07-09 12:24:59 +00:00
BMidiText::BMidiText()
{
startTime = 0;
2002-07-09 12:24:59 +00:00
}
//------------------------------------------------------------------------------
BMidiText::~BMidiText()
{
2003-03-17 22:30:19 +00:00
// do nothing
2002-07-09 12:24:59 +00:00
}
//------------------------------------------------------------------------------
void BMidiText::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::ControlChange(
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::ProgramChange(
uchar channel, uchar programNumber, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::ChannelPressure(uchar channel, uchar pressure, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
{
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
}
//------------------------------------------------------------------------------
2003-03-17 22:30:19 +00:00
void BMidiText::SystemExclusive(void* data, size_t length, uint32 time)
{
WaitAndPrint(time);
2003-03-17 22:30:19 +00:00
printf("SYSTEM EXCLUSIVE;\n");
for (size_t t = 0; t < length; ++t)
{
2003-03-17 22:30:19 +00:00
printf("%02X ", ((uint8*) data)[t]);
2002-07-09 12:24:59 +00:00
}
2003-03-17 22:30:19 +00:00
printf("\n");
2002-07-09 12:24:59 +00:00
}
//------------------------------------------------------------------------------
void BMidiText::SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::SystemRealTime(uchar status, uint32 time)
{
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
}
//------------------------------------------------------------------------------
void BMidiText::ResetTimer(bool start)
{
startTime = start ? B_NOW : 0;
2002-07-09 12:24:59 +00:00
}
//------------------------------------------------------------------------------
void BMidiText::_ReservedMidiText1() { }
2003-03-17 22:30:19 +00:00
void BMidiText::_ReservedMidiText2() { }
void BMidiText::_ReservedMidiText3() { }
//------------------------------------------------------------------------------
void BMidiText::Run()
{
while (KeepRunning())
{
snooze(50000);
2002-07-09 12:24:59 +00:00
}
}
//------------------------------------------------------------------------------
void BMidiText::WaitAndPrint(uint32 time)
{
if (startTime == 0) { startTime = time; }
SnoozeUntil(time);
2004-05-13 09:44:22 +00:00
printf("%lu: ", time - startTime);
2002-07-09 12:24:59 +00:00
}
//------------------------------------------------------------------------------