PDA

View Full Version : comp music with pic Sounds - Aka BeepMaster



flipper_md
- 30th October 2009, 21:37
Ok, here's one little thing I came to spend time on and turned out to be quite funny, so for the musician, here you go:

I wanted an easy-er way to create tunes with the sound command, else than testing/programming over 40 times to get the notes right.
Initial plan was to create everything from a windows apps, then output notes to pic, but finally I was tempted to use the PIC as a sound card...

Result is, a small application running under windows, showing you a virtual music keyboard and notes supported by the PB sound command.(I did my best to match the real frequencies with the ones emitted by a PIC, but they are not all 100% accurate).
You can clic the keyboard, and notes will be sent on the serial port to the PIC for playback.
Of course you can record/delete clicked notes to a list, and in the end ask the software to output a PBasic command line to put into a program.

http://www.flipperdesign.com/beepmaster.gif

not 100% bulletproof tested, but functionnal over here.
Made at least 6 tunes in less than 15 minutes with it.
It come pre-loaded with JS Bach Minuet =)

program EXE is here:
http://www.flipperdesign.com/BeepMaster.rar


Code required in the PIC to get the notes is here:


; sound generator PIC12F683, @20Mhz
; testing Sounds, and they wait for Data from seial to play more..
; For use with BEEPMaster.exe Program to create tunes

'-------------------------------------------------------------------
' PIC12F683
'-------------------------------------------------------------------
' PIN NAME USE/CONNECTION
' 1 Vdd +5VDC
' 2 GPIO.5 XT
' 3 GPIO.4 XT
' 4 GPIO.3 N/C, MCLR
' 5 GPIO.2 LED OUTPUT
' 6 GPIO.1 SERIAL INPUT
' 7 GPIO.0 SPEAKER OUTPUT, with a small caps
' 8 VSS GROUND
'-------------------------------------------------------------------

DEFINE DEBUG_REG GPIO
DEFINE DEBUG_BIT 1 ' GPIO.1
DEFINE DEBUG_MODE 0 ' 1 = inverted, 0 = true
DEFINE DEBUG_BAUD 38400 ' test 38400(fonctionne pas toujours sur le INTOSC)

DEFINE DEBUGIN_REG GPIO
DEFINE DEBUGIN_BIT 2 ' GPIO.2
DEFINE DEBUGIN_MODE 0 ' 1 = inverted, 0 = true

DEFINE OSC 20

CMCON0 = 7 'Analog Comparators OFF
ANSEL = %00000000 ' Set A/D OFF, necessaire pour SOUND!
ADCON0 = %00000000 'Analog converter OFF(test)

WPU = 0 ' Internal pull-ups = off, maybe REQUIRED for MCLR_OFF

INPUT GPIO.2
OUTPUT GPIO.1

Speaker var GPIO.0
output Speaker

Freqtest var Word

Duration var byte

curNote var byte

;LedPort var GPIO.2
;Output Speaker

dlzic var byte

curNote=0

;High LedPort
Pause 200

dlzic=40

pause 100
sound Speaker,[105,dlzic,99,dlzic,102,dlzic,90,dlzic*2,0,15,90,dl zic,102,dlzic,105,dlzic,99,dlzic ]


; Super Cool warp!
for Freqtest= 200 to 600
FREQOUT Speaker,10,Freqtest
next Freqtest

;High LedPort

; NOW that fun is over, lets wait for client input

waitforkeydata:
pause 1
DEBUGIN [WAIT("DT")]
DEBUGIN [HEX2 curnote]
DEBUGIN [WAIT(",")]
DEBUGIN [HEX2 duration]
DEBUGIN [WAIT(13)] ; wait carriage return

pause 2

sound Speaker,[curnote,duration ]

;High LedPort

GOTO waitforkeydata

END


note: The windows BEEP option to have sounds played under windows does not work with all computers... here.

mackrackit
- 31st October 2009, 00:31
Now that is an interesting project!!!

Acetronics2
- 31st October 2009, 16:13
Hi, Flipper

Ha que voilà une application des plus sympas !!!

Merci encore.

PS: dis m'sieur ... on pourrait aussi avoir le bruit Blanc, histoire d'étendre le domaine d'utilisation aux bruitages ??? ...

Merci d'avance.

Alain

PS: Sous XP SP3, les touches du clavier et la légende des cases à cocher n'apparaissent pas ...

flipper_md
- 1st November 2009, 02:45
Salut Alain

oh, no keys appearing?
could you send a snapshot of what it looks like on your PC?
flipperdesign at gmail ... dot

this is hard to imagine as i'm forcing colors...but will check back what could cause that.

White noise, yes it could be. Maybe on another piano bar.
I've just added it for a quick test but it's not implemented with recording.
you can redownload from the same link

Thanks for the idea!

fratello
- 1st November 2009, 07:45
Wonderfull project ! It is possible to use 12F675 instead 12F683 ? Thanks !

flipper_md
- 1st November 2009, 15:50
any PIC will do

it just we to wait for the correct data to come in, which is set by the sending program.

the only real important part is here:


waitforkeydata:
pause 1
DEBUGIN [WAIT("DT")]
DEBUGIN [HEX2 curnote]
DEBUGIN [WAIT(",")]
DEBUGIN [HEX2 duration]
DEBUGIN [WAIT(13)] ; wait carriage return

pause 2

sound Speaker,[curnote,duration ]

;High LedPort

GOTO waitforkeydata

fratello
- 1st November 2009, 18:04
Merci beaucoup ! ;)

flipper_md
- 7th January 2010, 15:02
a quick note to let you know that there is a visual bug under any OS that is set to use the fancy windows themes, like rounded buttons and fades...

to get things right, you new to switch into Perfomance mode under XP, or set the theme to "Classic" in Win7. Yah, it will reminds you of the good old Win2000 days ;)

that is until I find a way to set colors properly into that fancy world.

thanks goes to Brad for help finding this out.

flipper_md
- 7th January 2010, 15:51
You can now re-download from the same link, and a newer version is there. Look in the top right corner options if you can't see the interface.

try barbie pink interface!! :D it's NIce


also fixed a bug with noise notes code, that would try to send data even if PIC option was not selected.

Dennis
- 7th January 2010, 23:00
Hi Flipper

WOW this really is something !

You know anyone could (with some tweaking to a Jean Michel Jarre with a PIC !

Combine your PIC code with something Skimask was busy on
http://www.picbasic.co.uk/forum/showthread.php?t=5407&highlight=finger+touch and maybe a few Led's and a laser pointer or two and whammo you have a hit !
In fact , interface your Windows proggie with a media player, feed it to the same sound source and you have an LED touch DJ panel with sound to light !

I will keep an eye out for it !

Many thanks

Kind regards
Dennis

flipper_md
- 8th January 2010, 22:31
agreed that possibilities are totally endless :)


I already hooked a frequency bargraph on my board right aside, since I needed a frequency analyser to catch the sounds emitted by the pic in the first place.


here is a newer Beta version, with Basic MIDI output, and some other tweak.
http://www.flipperdesign.com/BeepMaster_midi.rar

watch out, it could be pretty loud and there no volume control :p
But i do like the midi sounds...a bit more than the PC beeper LOL

Dennis
- 8th January 2010, 23:34
Hey Flipper

Awesome !!
Will give it a shot and feedback when I can :-)
Maybe a light organ ??

http://www.picbasic.co.uk/forum/showthread.php?t=5407&highlight=finger+touch
.....Or touch-sensitive :-)
Think the light-organ would be something even more quite unique as an add-on or option for your code (or new code!)

Would love to try it out if ever you get to do it !

Dennis

flipper_md
- 9th January 2010, 00:39
Hi Dennis

I'm not too sure on how things would get hooked between light sensor/program/ and another pic making sound?, but if you can describe the loop I might check into it.

I would hope to add multitrack capability one day, or maybe easier and more powerfull, a plain Midi track importer/converter.
Then a whole bunch of 12f683 would share the data, singing along :D


here is a light organ, sort of :)


http://www.youtube.com/watch?v=aOZEpP_zzaw

i've just added it into my program, as default sample track.

flipper_md
- 28th January 2010, 21:56
updated program recently, some added functions and checks.

and created a new utility to process midi files for import(work ok with clean tracks, ie no multi-tones as the pic can't do that)


more info in this web page:
http://www.flipperdesign.com/projects_beepmaster.html

Glenn
- 6th February 2010, 23:43
Very cool, except that I can't get it to work, if I press any key (on the little piano-keayboard) that has a decimal point I get the error message "xxx.xxx is not a valid floating point value"


I GUESS that this can be due to that the official floating point marker in Sweden is comma (,) and not a dot (.) (even if many people use a dot anyway).

Would it be possible to fix this bug ? probably by reading that info from windows in some way ? ..it's actually the first time I seen this problem.

flipper_md
- 7th February 2010, 02:06
thanks for reporting this error Glenn

I believe you have pinpoint the bug. my programming didn't checked for coma or point separator.
Now it will update the frequency list at startup, after checking system settings.
(a message will appear in the application title area)

please redownload BeepMaster_midi.rar and let me know.

Glenn
- 17th February 2010, 23:27
Sorry for the late reply, but it works much better now :)

But I still cant get it to convert a MIDI file, but since I'm not very good at MIDI files and you make some notes about what's supportet I guess it's my file that is the problem..

flipper_md
- 18th February 2010, 00:55
good!

check back on my website(scroll way down), as I updated some information about midi stuff.
If you have other question on un-explained stuff just ask, I will try to update the info.


DS

flipper_md
- 20th September 2010, 06:04
updated version with some more control is now available

http://www.flipperdesign.com/BeepMaster2010grid.rar

don't be afraid to Right Click over grids and buttons, they will often reveal magic functions :rolleyes: