Hey, just for the hell of it I wrote a small program to play MIDI files over a PC speaker. Specifically a piezoelectric speaker that can only play a single frequency at a time (no PWM for me :/).
I'm still working on it but I have something that vaguely resembles the MIDI coming out of the speaker. 'Cept it only works on a single channel at a time because the piezo speaker can't play polyphonic sound (in PC's as far as I know).
Does anyone know a good method to combine frequencies to produce a good approximate sound. Given how people percieve pitch I was hoping somebody knew a function that woould combine frequencies to produce the best 'precieved average' or something of the sounds. That way I might be able to combine multiple channels to make a better sounding playback.
Posting here because its a program I'm writing and I figure the general knowledge level in here is higher than /music/.
Name:
Anonymous2006-06-25 1:49
Here's two ideas:
- Quickly switch between the frequencies. This probably sounds like shit once the frequency of switching becomes an audible tone itself. (10-20hz is probably an ok speed for less than 5 simultaneous notes)
- Mix the audio yourself, and then use the speaker to play a 1-bit representation of it (i.e. on when above zero, off when below zero). This will also sound like shit, if it even works with a piezo.
Name:
Anonymous2006-06-25 3:08
>>2
One idea I was thinking I could use, that would also allow me to play any music file, is to do a Fourier Tranform on samples of music and then take an average of the higher amplitude frequencies to get the average frequency. Unfortuantely, it's pretty far beyond what I know about mathematics so I can't quite figure it out. I've got FFTW library linking into a small application but I am having trouble using it since I don't know which tranforms (r2c, r2r?) to use and to format/interpret the input and output.
>>4
The main idea behind this driver is to switch the PC speaker on, then off before the speaker reaches the "top", thus making it acts like a "real" speaker. Unfortunately, it works very bad with a piezoelectric speaker and makes a shitty sound.
I remember FastTracker II using this trick to play 4+ channels modules on a PC speaker
Name:
Anonymous2008-01-11 8:45
>>3
it doesn't work like that. a human doesn't hear the average of the frequencies but the individual frequencies.
also, r2r is probably most appropriate if you don't need phase information.
Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy