tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / midi / MidiText.cpp
blobc3f5037aaac7aac8fd3a0c1315ea791c25eb8993
1 /*
2 * Copyright 2006, Haiku.
4 * Copyright (c) 2002-2003 Matthijs Hollemans
5 * Copyright (c) 2002 Jerome Leveque
6 * Copyright (c) 2002 Paul Stadler
7 * Distributed under the terms of the MIT License.
9 * Authors:
10 * Jérôme Leveque
11 * Matthijs Hollemans
12 * Paul Stadler
15 #include <stdio.h>
16 #include <MidiText.h>
18 #include "debug.h"
21 BMidiText::BMidiText()
23 fStartTime = 0;
27 BMidiText::~BMidiText()
29 // do nothing
33 void
34 BMidiText::NoteOff(
35 uchar channel, uchar note, uchar velocity, uint32 time)
37 _WaitAndPrint(time);
38 printf(
39 "B_NOTE OFF; channel = %d, note = %d, velocity = %d\n",
40 channel, note, velocity);
44 void
45 BMidiText::NoteOn(
46 uchar channel, uchar note, uchar velocity, uint32 time)
48 _WaitAndPrint(time);
49 printf(
50 "B_NOTE ON; channel = %d, note = %d, velocity = %d\n",
51 channel, note, velocity);
55 void
56 BMidiText::KeyPressure(
57 uchar channel, uchar note, uchar pressure, uint32 time)
59 _WaitAndPrint(time);
60 printf(
61 "KEY PRESSURE; channel = %d, note = %d, pressure = %d\n",
62 channel, note, pressure);
66 void
67 BMidiText::ControlChange(
68 uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
70 _WaitAndPrint(time);
71 printf(
72 "CONTROL CHANGE; channel = %d, control = %d, value = %d\n",
73 channel, controlNumber, controlValue);
77 void
78 BMidiText::ProgramChange(
79 uchar channel, uchar programNumber, uint32 time)
81 _WaitAndPrint(time);
82 printf(
83 "PROGRAM CHANGE; channel = %d, program = %d\n",
84 channel, programNumber);
88 void
89 BMidiText::ChannelPressure(uchar channel, uchar pressure, uint32 time)
91 _WaitAndPrint(time);
92 printf(
93 "CHANNEL PRESSURE; channel = %d, pressure = %d\n",
94 channel, pressure);
98 void
99 BMidiText::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
101 _WaitAndPrint(time);
102 printf(
103 "PITCH BEND; channel = %d, lsb = %d, msb = %d\n",
104 channel, lsb, msb);
108 void
109 BMidiText::SystemExclusive(void* data, size_t length, uint32 time)
111 _WaitAndPrint(time);
113 printf("SYSTEM EXCLUSIVE;\n");
114 for (size_t t = 0; t < length; ++t)
115 printf("%02X ", ((uint8*) data)[t]);
116 printf("\n");
120 void
121 BMidiText::SystemCommon(
122 uchar status, uchar data1, uchar data2, uint32 time)
124 _WaitAndPrint(time);
125 printf(
126 "SYSTEM COMMON; status = %d, data1 = %d, data2 = %d\n",
127 status, data1, data2);
131 void
132 BMidiText::SystemRealTime(uchar status, uint32 time)
134 _WaitAndPrint(time);
135 printf("SYSTEM REAL TIME; status = %d\n", status);
139 void
140 BMidiText::ResetTimer(bool start)
142 fStartTime = start ? B_NOW : 0;
146 void BMidiText::_ReservedMidiText1() { }
147 void BMidiText::_ReservedMidiText2() { }
148 void BMidiText::_ReservedMidiText3() { }
151 void
152 BMidiText::Run()
154 while (KeepRunning())
155 snooze(50000);
159 void
160 BMidiText::_WaitAndPrint(uint32 time)
162 if (fStartTime == 0)
163 fStartTime = time;
165 SnoozeUntil(time);
167 printf("%" B_PRIu32 ": ", time - fStartTime);