IOCT Masters in Creative Technogies
Major Project
An augmented reality game based on "Breakout"

Tuesday 8 July 2008

Sound code

I have researched the ways to add sound effects using c code and OpenCV. The best way appears to be to use a Musical Instrument Digital Interface (MIDI) voice. MIDI works by transmitting digital data about the pitch, intensity and length of notes, for example.

In the code I set up sound as an integer variable to include:
  • Frequency (as a floating point number)
  • Duration (as an integer variable)
  • Volume (as an integer variable)
  • Voice (as an integer variable)
  • Tempo (as a floating point number)

Volume ranges from 0 – 127, or off to loudest
Voice ranges from 0 – 127, each number representing a different voice or instrument effect

This took some time for experimentation and research to find the noises I wanted to include in the game.

A sample of the code looks like this: