Page 1 of 1

6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Wed May 30, 2012 1:53 pm
by Brian Griffin
Project Name: 6-voice Phase Modulated Synthesis Mini-Music Box.

Author/Designer: Y H

Project Description: A port from the skds40A - http://forum.cytron.com.my/viewtopic.php?f=30&t=11600, using SKPIC32.

The architecture and the cache in the microcontroller lets it do even more. Future plans including using an entire external DAC and a bigger sine table to reduce noise.

Compiler: MPLAB X IDE 1.10, MPLAB XC32 1.00

Hardware: skPIC32, Carrefour Speakers, breadboard, RC filter (R = 270ohm, C = 0.05uF).

PWM Frequency is 78.125kHZ and module is running at 72MHz

Source code: Attached.

Note: Please modify TEMPO, PRESCALER_HIGH_BIT, PRESCALER_LOW_BIT if the song zips too fast. The Prescalers are to slow down the timer for playing the notes.

Schematic:
skpic32musicbox.jpg
Schematic


Video:


References: Auto-Composing Piano by Chaorong Chen and Siyu Zhan - http://people.ece.cornell.edu/land/cour ... 899_sz259/

Analog Dialogue - http://www.analog.com/library/analogDia ... 8/dds.html

elm-chan wavetable melody generator - http://elm-chan.org/works/mxb/report.html

Markus Gritsch's Music Box - http://dangerousprototypes.com/forum/vi ... =56&t=3472

Edit: This mini music box can be used in a doorbell, clocks, music-box and others. Programmers are welcome to experiment on it.

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Wed May 30, 2012 8:32 pm
by yonghui
Great project!

cant wait to see the video.

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Wed May 30, 2012 8:40 pm
by Brian Griffin
yonghui WROTE:Great project!

cant wait to see the video.


Thanks and no worries! Uploading the video now. :)

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Fri Jun 01, 2012 1:16 pm
by sich
Wow...you've ported from dsPIC to PIC32! Nice nice nice...

I have to suggest one more improvement... What about combine this one with SKPIC32-based Experimental Mini-Game using VGA since both are using SKPIC32 now. That gives it both audio and visual outputs. What do you think? :D

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Fri Jun 01, 2012 2:18 pm
by Brian Griffin
sich WROTE:Wow...you've ported from dsPIC to PIC32! Nice nice nice...

I have to suggest one more improvement... What about combine this one with SKPIC32-based Experimental Mini-Game using VGA since both are using SKPIC32 now. That gives it both audio and visual outputs. What do you think? :D


The porting is only a slight modification of the code, fortunately. :)

I will combine it but it takes a lot of time to modify the game logic as it is not really structured and it imitates the old game console mentioned. As for the mini-game system, it is best realized by simple square-waves and not FM/PM synthesis, due to the era of the game itself.

The sound part can be put inside the horizontal-sync in the system, but I'd risk losing the timing later on. Sound processing should be done seperately - I'll try to use the PIC161503 as it is an easy thing to model square waves and some noise.

However, the FM/PM synthesis is effective for recreating 16-bit systems such as Sega Genesis where they used those inside.

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Tue Jul 10, 2012 7:11 am
by takao21203
How much computation power does this sound generation code actually need?

Can it become ported to 18F PIC?

Space for the sound data is not a problem, I use 512 kbyte serial flash chips,
and data is written to them by GAL programmer.
For instance BMP file is read directly by the programmer software,
and stored at memory address, then the chip is written with many BMP files loaded.

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Tue Jul 10, 2012 8:52 am
by Brian Griffin
takao21203 WROTE:How much computation power does this sound generation code actually need?

Can it become ported to 18F PIC?

Space for the sound data is not a problem, I use 512 kbyte serial flash chips,
and data is written to them by GAL programmer.
For instance BMP file is read directly by the programmer software,
and stored at memory address, then the chip is written with many BMP files loaded.


Due to the multiplication and division involved inside the sound generation code (it is a proof-of-concept), so it is considered a lot. I used dsPIC/PIC32 because of the mul/div hardware contained inside.

You can port it to the 18F PIC but you have to write it in assembly.

For sound data, you can even use an SPI EEPROM. I have made an old toy using that (using squarewaves), but I have cannibalized the components inside for a WAV player. :)

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Tue Jul 10, 2012 9:02 am
by takao21203
OK I ask because I am interested in this to use it for sound output.
But I make an extra thread for my circuit...

And I don't think I want to use assembler again :D

Re: 6-voice Polyphony Mini Music Box on SKPIC32

PostPosted: Tue Jul 10, 2012 9:27 am
by Brian Griffin
takao21203 WROTE:OK I ask because I am interested in this to use it for sound output.
But I make an extra thread for my circuit...

And I don't think I want to use assembler again :D


No prob. You can do it, but slower on those low-end PICs. Maybe only 3-4 channels. :)