b. Playing Midi Sounds

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 11 - Audio Primitives >

b. Playing Midi Sounds

This section shows how to play the MIDI (Musical Instrumental Digital Interface) sounds using the MPlay() command.

 

 

Command Prototype

 

uint16_t MPlay(int16_t Instrument,int16_t Delay,const char* String)

 

Parameters

Description

Instrument

sound value

Delay

Pitch value

String

note string

 

 

Code

 

 

void setup()

{

/* Initialize CleO - needs to be done only once */

 CleO.begin();

}

 

void loop()

{

/* Select Sound, pitch and notes string */

 CleO.MPlay(PIANO, 400, "E5A5E5B5E5G5A5E5C6E5D6E5B5C6E5A5E5B5E5G5A5E5C6E5D6E5B5C6E5B5");

 delay(2000);

}

 

 

Description

 

In the above code snippet, a PIANO sound is selected with pitch 400.

The MIDI note string contains the notes i.e. E5, A5, E5, etc.