6-voice Polyphony Mini Music Box on SKPIC32

Works done? Proud of it? Show off here! Let's see what you've built can help inspire others.

6-voice Polyphony Mini Music Box on SKPIC32

Postby Brian Griffin » Wed May 30, 2012 1:53 pm

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.
Attachments
skpic32-fmod.X.zip
Source Code
(91.99 KiB) Downloaded 502 times
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby yonghui » Wed May 30, 2012 8:32 pm

Great project!

cant wait to see the video.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby Brian Griffin » Wed May 30, 2012 8:40 pm

yonghui WROTE:Great project!

cant wait to see the video.


Thanks and no worries! Uploading the video now. :)
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby sich » Fri Jun 01, 2012 1:16 pm

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
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby Brian Griffin » Fri Jun 01, 2012 2:18 pm

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.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby takao21203 » Tue Jul 10, 2012 7:11 am

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.
User avatar
takao21203
Discoverer
 
Posts: 111
Joined: Mon Mar 19, 2012 7:52 pm
Location: Ireland, Europe

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby Brian Griffin » Tue Jul 10, 2012 8:52 am

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. :)
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby takao21203 » Tue Jul 10, 2012 9:02 am

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
User avatar
takao21203
Discoverer
 
Posts: 111
Joined: Mon Mar 19, 2012 7:52 pm
Location: Ireland, Europe

Re: 6-voice Polyphony Mini Music Box on SKPIC32

Postby Brian Griffin » Tue Jul 10, 2012 9:27 am

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. :)
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am


Return to Project Showcase

Who is online

Users browsing this forum: No registered users and 4 guests