Chameleon-PIC Nurve Networks, Chameleon-PIC Datasheet - Page 219

MCU, MPU & DSP Development Tools PIC24 & PROPELLER DEV SYSTEM (SBC)

Chameleon-PIC

Manufacturer Part Number
Chameleon-PIC
Description
MCU, MPU & DSP Development Tools PIC24 & PROPELLER DEV SYSTEM (SBC)
Manufacturer
Nurve Networks
Datasheet

Specifications of Chameleon-PIC

Processor To Be Evaluated
PIC24
Data Bus Width
16 bit
Interface Type
USB, VGA, PS/2, I2C, ISP, SPI
Operating Supply Voltage
3.3 V, 5 V
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
General Requirements:
Controls Required:
Technical Overview
This demos uses the Sound API to plays tones on the speaker. You need to hook up the Chameleon’s audio out port to
the amplifier or the TV’s audio in. However, the program outputs to both the NTSC and VGA display for its text output.
This program is the most complex yet since it deals with sound. First off, we need a scale of frequencies which is at the
top of the program and shown below:
float adjacent_note = 1.059463094; // 2^(1/12) ratio between adjacent keys
// scale from middle A to one octave above A
int scale[] = {440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 880 };
/*
A
B flat 466
B
C
C sharp 554
D
D sharp 622
E
F
F sharp 740
G
A flat 831
A
*/
The array scale[] holds the scale from middle A at 440Hz then from this we can compute any octave or half notes, etc.
which are used to generate chords. There are all kinds of chords and all kinds of theory about what sounds good and
doesn’t. One method of computing chords is to play 2-3 notes that are related to each other by adjacent notes from the
base note. There are formulas you can use to calculate these notes and simply experiment to see what sounds “good”,
“dissonant”, “resonant” or just plain bad. The program plays a number of chords in an increasing fashion, then in
decreasing. Below is a copy of the increasing code, so you can see the computation of the chord frequencies as well as
the sound API calls to play the actual chord.
NTSC_Term_Print("Going up...");
NTSC_Term_Char( 0x0D );
// play the scale up
for (note = 0; note < NUM_NOTES; note++)
494
523
587
659
784
880
{
// compute chord to play
chord_freq_1 = scale[ note ]/2 * pow ( adjacent_note, 4);
// play these an octave above
chord_freq_2 = scale[ note ] * pow ( adjacent_note, 5);
chord_freq_3 = scale[ note ] * pow ( adjacent_note, 6);
sprintf(sbuffer,"Playing Chord [%d, %d, %d]", (int)chord_freq_1, (int)chord_freq_2, (int)chord_freq_3 );
// play the notes (we have a freq limit of 2049 hz with the current API interface,
// the driver can do whatever you want though
// so you will have to create new messages and a 16-bit format if you want to play higher frequencies
Sound_Play(0, (int)chord_freq_1, 1);
Sound_Play(1, (int)chord_freq_2, 1);
Sound_Play(2, (int)chord_freq_3, 1);
// print on NTSC terminal screen
NTSC_Term_Print(sbuffer);
NTSC_Term_Char( 0x0D );
// print on VGA terminal screen
VGA_Term_Print(sbuffer);
VGA_Term_Char( 0x0D );
// slow things down a bit, so we can read the text!
} // end for index
DELAY_MS(500);
440
698
Video port connected to NTSC or VGA monitors, RCA audio connected to an amplifier or
the TV’s audio input.
None.
© 2009 NURVE NETWORKS LLC “Exploring the Chameleon PIC 16-Bit”
219

Related parts for Chameleon-PIC