Menu

#2 sound skips and is very distorted

open
nobody
None
7
2010-02-16
2010-02-16
BenRayfield
No

This was not always true, at least on Windows XP where I test it most, but on gNewSense Linux (and a few other operating systems) the sound is almost nothing like it should be.

The simplest way to play a sound is to type this into a specific 1 of the 3 windows that CodeSimian 0.65 opens when you start it. Type this:

sound(sine(count))

then click "compile code" and it should play a constant frequency sound at 22050 hz (22 khz).

The "count" function starts at 0 and increases by 1 each time it runs.

The "sound" function is a loop that continues until a different "sound" function is run. Example: sound(0) would play the sound 0 which is silent because it does not change. There is some way to stop the sound completely for efficiency, and its code is in 1 of the buttons in the window.

sound(sine(count)) plays the simplest possible sound, and it is distorted and jumps around, so there is something very wrong.

CodeSimian's sound system smoothly interpolates between sound speeds, both in speaker speeds and microphone speeds, so if you call the "microphone" function a different number of times than the "sound" function, it will adjust to that different ratio gradually, and if the sound skips or your sound card has a hard to predict buffer, it tries to adjust for that too. All of that costs some CPU time, and that may be why its distorted now (running too slow or not balanced right), but that system is necessary because of the advanced way CodeSimian 0.65 does sound.

Maybe some of the sound code from Audivolv 0.1.7 would solve some of these problems.

Fix CodeSimian's sound system. sound(sine(count)) should play a smooth constant frequency, and that frequency is exactly 22050/(Math.PI*2) hz.

Also, if speed allows, upgrade CodeSimian to use 44.1 khz audio and stereo sound. The "sound" function can be modified to take 1 or 2 parameters, depending on how many audio channels you want.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.