pouët.net

Go to bottom

Music defined so that a programmer understands it

category: music [glöplog]
OK, so I'm playing around a bit with a device. The sound output is a piezo buzzer, meaning I can generate a square tone at different frequencies by turning it on and off and delay an appropriate amount of microseconds between it.
It would be fun to get it to play something that resembles music (as it is single channel and only squarewave I'm guessing it would sound like crap)
However I know nothing about music or notes or any of that stuff.
To make sense to me, a tune would be defined as:

Play a tone of 2400Hz for 240ms
Silence for 120 ms
Play a tone of 3200Hz for 340ms
Play a tone of 1200Hz for 70ms
Silence for 50 ms
etc.

Then it would be easy to write code that plays it.
Anyone have a link or something to a simple tune defined such as this?
added on the 2010-06-25 13:26:38 by Sdw Sdw
You might want to figure out the various Hz for all the notes comprising a few octaves on a keyboard (http://www.phy.mtu.edu/~suits/notefreqs.html), and then just nick the notes off of some random mod to try out.
added on the 2010-06-25 13:32:46 by uncle-x uncle-x
They format you need is very much like the way trackers store their note data, so extract the note data from a .MOD or (slightly more complex) write a MIDI file importer.
added on the 2010-06-25 13:35:39 by trc_wm trc_wm
i know of at least two 1-bit trackers that are open source on the internets.
they use the system speaker

but i wouldn't know where to find them anymore.
Quote:
However I know nothing about music or notes or any of that stuff.


I think I heard a friend of mine, who is a coder, saying one should never start to work on a topic he doesn't know about. You should better start to learn a bit about music before even starting to code.

If you want something to sound good, you should start to investigate chords, progression, tonic notes and related.
chords, progression
jazz musician, talking
added on the 2010-06-25 14:32:10 by hollowman hollowman
oh fuck, didn't even notice... starting... coding. here, it's better now.
What's wrong with the old "frequency.duration"? I know I used the internal 4DOS command "beep" to write simple songs like that in batch-files. A long, LONG time ago. :)
added on the 2010-06-25 14:51:52 by gloom gloom
Anyho, this might answer your question better - http://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language
added on the 2010-06-25 14:53:01 by gloom gloom
If the device is not very primitive you could ramp the volume on/off and play samples that way. 1-bit samples won't sound good, but using pulse-width modulation and exact CPU timing you could get something recognizable out.
added on the 2010-06-25 15:02:12 by Marq Marq
If you have a piezo buzzer and quite exact means to control it my guess is that you have a microcontroller with plenty of power to switch it more than 20kHz. If you can write the output at ~300kHz or more you can implement a pwm-dac and generate generic waveform sounds.
added on the 2010-06-25 15:10:17 by bore bore
I think it's for a ZX81, so 300kHz is out of the question :)
added on the 2010-06-25 15:47:51 by trc_wm trc_wm
Thanks gloom, that ringtone-thing seems like the perfect base. With the chart that uncle-x posted, it should be easy to write a converter to a frequencey+duration based format!

Good guess on the microcontroller btw. bore, it's an AVR Butterfly that I'm tinkering around with.
Storage space is very limited though, so sample-play is out of the question.
added on the 2010-06-25 16:39:51 by Sdw Sdw
Is this for Pet? I started a driver on there a while back if you want it, maybe we can finish the thing off? ( rangerx8000@googlemail.com )
added on the 2010-06-25 16:56:00 by 4mat 4mat
Oh, AVR! Plenty of cycles and PWM support in the timers. You can do some pretty nifty things there!
added on the 2010-06-25 20:16:09 by trc_wm trc_wm
In fact, you can easily connect an SD card in SPI mode to the AVR and get a couple of GB of storage space! There is no excuse not to play samples! :)))
added on the 2010-06-25 20:17:27 by trc_wm trc_wm
url=http://www.scene.org/file.php?file=/resources/seminars/music/bp06_happy-hardcore-crash-course-for-coders_by_skrebbel_xvid.avi&fileinfo]a certain seminar by skrebbel spring to mind[/url]
And then there's MML (shameless plug), which may or may not be overkill depending on the exact capabilities of the target chip.
added on the 2010-06-25 20:54:37 by mic mic
@mic: that looks pretty cool! Do you have any links to prods that were made with your tools?
added on the 2010-06-25 22:22:15 by trc_wm trc_wm
@trc_wm: I'm not aware of any such prods. The only people I've talked to about it are some musicians, mainly from 8bitcollective. European chipmusicians seem to prefer trackers while MML is fairly popular in Japan, but there's a language barrier there since I don't know japanese and they often know very little english.
added on the 2010-06-25 22:32:08 by mic mic

login

Go to top