I originally wrote the Silverlight Synthesizer as a sound test to figure out how to create sound in Silverlight, specifically for the Commodore 64 emulator. It evolved from there to become a testbed for multi-oscillator real-time sound generation using Silverlight 3+. The current version of the synthesizer targets Silverlight 4.
Synthesizer Information
Issues
- My mixing algorithm is bad. If anyone knows the right algorithm
for mixing multiple channels of sound, while keeping the same end
volume regardless of how many channels are mixed (including times
when some of the channels are silent) I'd love to know it. Please
share!
- Related to above, you can get distortion pretty quickly when
you press more than a few notes
- Fair bit of dead code - this is a test project
:)
None of those are Silverlight issues - they're issues with my
code.
One key thing that changed in Silverlight 3 RTW vs. the beta was
the addition of the new MediaStreamSource AudioBufferLength
property. It represents the number of milliseconds of sound to
buffer before output. The minimum value is 15, but on most machines
you won't be able to get close to that unless you have highly
optimized sound generation code (doing wavetable lookups rather
than real-time sawtooth waves, for example)
This value is highly machine dependent, so if you do anything
serious with this code, you'll want to make that something the user
can change to suit their own machine. To low a value and the sound
will stutter, too high and the sound will have an audible
delay.
The value is in the InitializeMediaStreamSource method of
Synthesizer.MediaStreamSource.cs
AudioBufferLength = 30;