The Midi Kit: BMidiText

Derived from: public BMidi

Declared in: <midi/MidiText.h>


Overview

A BMidiText object displays, to standard output, a textual description of each MIDI message it receives. You use BMidiText objects to debug and monitor your application; it has no other purpose.

To use a BMidiText object, you construct it and connect it to some other BMidi object as shown below:

   BMidiText *midiText;
   
   midiText = new BMidiText();
   otherMidiObj->Connect(midiText);
   
   /* Start a performance here ... */

BMidiText's output (the text it displays) is timed: When it receives a MIDI message that's timestamped for the future, the object waits until that time has come to display its textual representation of the message. While it's waiting, the object won't process any other in- coming messages. Because of this, you shouldn't connect the same BMidiText object to more than one BMidi object. To monitor two or more MIDI-producing objects, you should connect a separate BMidiText object to each.

The text that's displayed by a BMidiText follows this general format:

timestamp: MESSAGE TYPE; message data

(Message-specific formats are given in the function descriptions, below.) Of particular note is the timestamp field. Its value is the number of milliseconds that have elapsed since the object received its first message. The time value is computed through the use of an internal timer; to reset this timer--a useful thing to do between performances, for example--you call the ResetTimer() function.

The BMidiText class doesn't generate or spray MIDI messages, so the performance and connection functions that it inherits from BMidi have no effect.


Constructor and Destructor


BMidiText()

      BMidiText(void)

Creates a new BMidiText object. The object's timer is set to zero and doesn't start ticking until the first message is received. (To force the timer to start, call ResetTimer(TRUE).)


~BMidiText()

      virtual ~BMidiText(void)

Does nothing.


Member Functions


ChannelPressure()

      virtual void ChannelPressure(char channel,
         char pressure,
         ulong time = B_NOW)

Responds to a Channel Pressure message by printing the following:

timestamp: CHANNEL PRESSURE; channel = channel, pressure = pressure

The channel and pressure values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


ControlChange()

      virtual void ControlChange(char channel,
         char ctrl_num,
         char ctrl_value,
         ulong time = B_NOW)

Responds to a Control Change message by printing the following:

timestamp: CONTROL CHANGE; channel = channel, control = ctrl_num, value = ctrl_value

The channel, ctrl_num, and ctrl_value values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


KeyPressure()

      virtual void KeyPressure(char channel,
         char note,
         char pressure,
         ulong time = B_NOW)

Responds to a Key Pressure message by printing the following:

timestamp: KEY PRESSURE; channel = channel, note = note, pressure = pressure

The channel, note, and pressure values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


NoteOff()

      virtual void NoteOff(char channel,
         char note,
         char velocity,
         ulong time = B_NOW)

Responds to a Note Off message by printing the following:

timestamp: NOTE OFF; channel = channel, note = note , velocity = velocity

The channel, note, and velocity values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


NoteOn()

      virtual void NoteOn(char channel,
         char note,
         char velocity,
         ulong time = B_NOW)

Responds to a Note On message by printing the following:

timestamp: NOTE ON; channel = channel, note = note , velocity = velocity

The channel, note, and velocity values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


PitchBend()

      virtual void PitchBend(char channel,
         char lsb,
         char msb,
         ulong time = B_NOW)

Responds to a Pitch Bend message by printing the following:

timestamp: PITCH BEND; channel = channel, lsb = lsb , msb = msb

The channel, lsb, and msb values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


ProgramChange()

      virtual void ProgramChange(char channel,
         char program_num,
         ulong time = B_NOW)

Responds to a Program Change message by printing the following:

timestamp: PROGRAM CHANGE; channel = channel, program = program_num

The channel and program_num values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


ResetTimer()

      void ResetTimer(bool start = FALSE)

Sets the object's internal timer to zero. Lacking a start argument --or with a start of FALSE--the timer doesn't start ticking until the next MIDI message is received. If start is TRUE , the timer begins immediately.

The timer value is used to compute the timestamp that's displayed at the beginning of each message description.


SystemCommon()

      virtual void SystemCommon(char status,
         char data1,
         char data2,
         ulong time = B_NOW)

Responds to a System Common message by printing the following:

timestamp: SYSTEM COMMON; status = status, data1 = data1, data2= data2

The channel, data1, and data2 values are taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


SystemExclusive()

      virtual void SystemExclusive(void *data,
         long data_length,
         ulong time = B_NOW)

Responds to a System Exclusive message by printing the following:

timestamp: SYSTEM EXCLUSIVE;

This is followed by the data itself, starting on the next line. The data is displayed in hexadecimal, byte by byte. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).


SystemRealTime()

      virtual void SystemRealTime(char status, ulong time = B_NOW)

Responds to a System Real Time message by printing the following:

timestamp: SYSTEM REAL TIME; status = status

The status value is taken directly from the arguments that are passed to the function. The timestamp value is the number of milliseconds that have elapsed since the timer started (see ResetTimer() for more information on time).




The Be Book, HTML Edition, for Developer Release 8 of the Be Operating System.

Copyright © 1996 Be, Inc. All rights reserved.

Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.

Last modified September 6, 1996.