<< Chapter < Page Chapter >> Page >

Input requirements

  • string in (string type)
  • delta-time / event pairs (string type)

Output requirements

  • string out (string type)

Behavior requirements

  • Create a track chunk ID sub-string (MTrk)
  • Create a sub-string for a zero delta-time followed by an end-of-track meta-event
  • Determine the total number of bytes in the track, and create a four-byte substring that represents this value
  • Assemble the sub-strings into a string in order as chunk ID, chunk length, inbound string, and zero delta-time, and end-of-track meta-event, and output this result

Your finished subVI should behave like this one:

Coding tips

Watch the screencast video to learn how to use the nodes String Length and To Unsigned Long Integer to determine the number of bytes in the track.

[video] Learn how to determine the length of string

Midi_tovlf.vi

midi_ToVLF.vi accepts a 32-bit unsigned integer and produces an output string that is anywhere from one to four bytes in length (recall that VLF = variable length format). You may find this subVI to be one of the more challenging to implement! Review the module Standard MIDI Files to learn about variable-length format.

Input requirements

  • x (32-bit unsigned integer)
  • string in (string type)

Output requirements

  • string out (string type)

Behavior requirements

  • Accept a numerical value to be converted into a sub-string one to four bytes in length in variable-length format
  • Append the sub-string to the inbound string, and output the result

Your finished subVI should behave like this one:

Coding tips

Watch the screencast video to learn how to convert a numerical value to and from the Boolean Array data type, an easy way to work with values at the bit level.

[video] Learn how to convert a numerical value to a Boolean array in order to work at the individual bit level

Midi_makedtevent.vi

midi_MakeDtEvent.vi creates a delta-time / event pair. The subVI accepts a delta-time in ticks, a MIDI message selector, the channel number, and two data values for the MIDI message. The delta-time is converted into variable-length format, and the (typically) three-byte MIDI message is created. Both of these values are appended to the inbound string to produce the output string. Review the module MIDI Messages to learn more.

Input requirements

  • string in (string type)
  • delta time (32-bit unsigned integer; defaults to 0)
  • event (enumerated data type with values Note Off, Note On, Control Change, Program Change, Pitch Wheel; defaults to Note Off)
  • channel (8-bit unsigned integer; defaults to 1)
  • data 1 (8-bit unsigned integer; defaults to 0)
  • data 2 (8-bit unsigned integer; defaults to 0)

Output requirements

  • string out (string type)

Behavior requirements

  • Convert the delta time value to VLF format using the midi_ToVLF.vi subVI you created in a previous step
  • Subtract 1 from the inbound channel number (this way you can refer to channel numbers by their standard numbers (in the range 1 to 16) outside the subVI.
  • Create a MIDI message status byte using the channel number and event selector
  • Finish the MIDI message by appending the appropriate byte values; depending on the MIDI message you need to create, you may use both‘data 1’and‘data 2’, or just‘data 1’(Program Change message), or you may need to modify the incoming data value slightly (for example, outside the subVI it is more convenient to refer to the tone number for a Program Change message as a value between 1 and 128)
  • Append the delta-time sub-string and the MIDI message sub-string to the inbound string, and output the result

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Musical signal processing with labview (all modules). OpenStax CNX. Jan 05, 2010 Download for free at http://cnx.org/content/col10507/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Musical signal processing with labview (all modules)' conversation and receive update notifications?

Ask