sound.samples not 16 bit - PLEASE HELP!

BlitzMax Forums/BlitzMax Programming/sound.samples not 16 bit - PLEASE HELP!

Taron(Posted 2008) [#1]
I have no shame of sounding desperate here!

BlitzMax doesn't seem to create 16 bit sample data for the audio, or do I miss something?
Strict
Local sample:TAudioSample=CreateAudioSample(10000, 44100, SF_MONO16BE)

For Local i = 0 To 10000
	sample.samples[i] = Sin(i*3.6)*127
Next

Local sound:TSound = LoadSound(sample)
Local channel:TChannel = CueSound(sound)
ResumeChannel channel
Input


sample.samples[] will not contain floating point data!

What am I doing wrong? How can I get to write, read and play floating point data through BRL.Audio?

Any answer will do... "impossible!", "sure you can, good luck!" or "I dunno whatcha talking about?!". Anything would help, really. I've already written a beautiful interface with fully zoom, pan and editable markers for volume on samples. Just now I decided to go deeper and find out I'm stuck with 8bit data... tell me that can't be, please!


BTW, I've tried writing data into memory and using the static audio, but it turns out to have the same troubles. It only needs integer arrays as far as I can tell?!


REDi(Posted 2008) [#2]
Local AudioPtr:Short Ptr = Short Ptr(sample.samples)
For Local i = 0 To 10000
	AudioPtr[i] = Sin(i*3.6)*5000
Next

sample.samples is a byte pointer, so anything you write to it will only be in bytes, so you need to use a short pointer for 16bit sound.

floating point audio is 32bit and not supported by blitzmax audio.


Taron(Posted 2008) [#3]
THANKS, particularely for the quick reply, I had no hopes there.

I've tried bytes in one of my tests with the static audio, but came to the same weirdness, that if I play the audio it still looks at it as 8bit between -127 to 127.

If I load the result of your loop, I get the same effect. Except *5000 clips the hell out of it, of course.

Am I doing something wrong in loading the sound?

(..really, thanks again for being there for me so quickly, I really appreciate it very, very much!)


REDi(Posted 2008) [#4]
This shows how to read 16bit samples from the sample data, if thats any help.
Strict
Local sample:TAudioSample=CreateAudioSample(10000, 44100, SF_MONO16BE)

Local AudioPtr:Short Ptr = Short Ptr(sample.samples)
Local av:Int
For Local i = 0 To 10000
	AudioPtr[i] = Sin(i*3.6)*5000
	av=AudioPtr[i]
	If av>32767 Then av:-65535		' signed shorts are not supported, so you'll need to handle it yourself
	Print av
Next

Local sound:TSound = LoadSound(sample)
Local channel:TChannel = CueSound(sound)
ResumeChannel channel
Input



Taron(Posted 2008) [#5]
ARRRRRRRRRRRR............

NEVER MIND!!!

(SF_MONO16LE as opposed to ...BE)

YES! The joy... THE JOOOY! THANKS!

8)


Taron(Posted 2008) [#6]
REDi, honestly, I don't know how to tell you what you've done for me right now. I might sound like having some sort of bipolar happiness attack, but you've truely, deeply saved my day and brought plenty of joy for the coming days! I'll let you know, when there's something to cool enough to play with my synth, but so far it's already a riot! I've been working with audio for the last 22 years, but never once programmed anything for it on a PC (did some C64 code and a tiny bit on Amiga, but man... ). So now I can finally try what I always wanted to be able to do with really simple sound design.

Again: YOU ROCK!

Thank's REDi!


REDi(Posted 2008) [#7]
my pleasure.


Taron(Posted 2008) [#8]
(red: volume)
(yellow: pitch)




Ginger Tea(Posted 2008) [#9]
thats a pretty little spiral :)


EOF(Posted 2008) [#10]
Good luck with this one. Looks interesting.
For inpiration have a look at this -- http://www.ludumdare.com/compo/2007/12/13/sfxr-sound-effects-for-all/


Taron(Posted 2008) [#11]
Wow that's hillarious! Awesome little tool, thanks!
I'm a little too happy about being very much in charge of creating funky sounds consciously and wish for them to be beyond standart identification, but I have to admit I find it very inspiring to consider some randomizing possibilities. Could be loads of fun. The best part is the categorized randoms, haha... jump, hit'n'run, coin, explosion and so on... that's wonderful. I think, once I have it all in the can, I'll have a go at that, too! 8)))

THANKS JIM... (i even saved two wavs already, too cool) ...by the way, my app won't export wavs, but just a tiny bundle of creation data.


BlitzSupport(Posted 2008) [#12]
Basically off-topic: Although I'd seen sfxr before (and it's great), I don't think I realised it's by DrPetter, whose "RigidRacing" project I found quite interesting, mostly because of the vibration effect he introduced for high-speed driving (with 'Turbo' mode on), a combination of visual vibration effects and convincing wind noise -- it's really cool on the fast straights.

http://www.cyd.liu.se/~tompe573/hp/old/project_rigid.html

Besides this, nice code example!


Taron(Posted 2008) [#13]
Uh, hey James! Thanks for chiming in! :)
Sounds fascinating, I'll check it out right away. 8)

My little synthi is getting cooler and cooler, while I'm getting the wildest problems, though. EVENT_MOUSEUP somehow gets ignored when I do a specific move at a specific moment, while under most circumstances it works fine. Anyone has a clue why that might be?

I checked it by printing hints at all important places and found that it goes through the event loop, ignores the MOUSEUP and bounces right back into the redraw, basically getting trapped in that loop. It's during dragging, of course, where that happens. Mouseup should stop the process...

I should call this thread differently, but while it's here!


Taron(Posted 2008) [#14]
Thanks again for the heads up and bearing with me...


Here's a link to the fruit of my struggles so far...
SYNTH01 - mini taronizer - alpha 0.1

Don't mind the few kinks and some sloppy stuff, but it's a first look at the synth. By the end, I'm sure, it's probably not recognizable anymore, but hey... I'm incredibly thrilled!

HOTKEYS:
"SPACE" - play
"S" - save (wav format, saves incrementally, but just for fun...)
"DELETE" - deletes marker
"ESCAPE" - exit

INTERFACE:

toolbar from left to right
- display resets (full reset, x reset, y reset)
- console (play, pause/play, stop) (I can't elegantly use the toogle gadget)
- waveforms (sine, saw, square, noise)

slider for resonance (YAAUUUWWWWWW)
bipolar filter option (EEEEYYYYAAAAAAAAAHHHHHUUUWWWEEEEEEeeeewww, oh god)

textfield for optional marker value input and supervision of value dragging

DISPLAY:
bars
red - volume
yellow - pitch
cyan - filter (lowpass)

left click on a bar to create a marker!
right click and drag up and down for value of currently selected marker!
middle click and drag left/right to offset marker position
(beware, it's a little sloppy code so far...still gotta make it nicer!)

left click on wave display to drag the display around
right click to zoom around (x stays under mouse pointer, y ignores it)
wheel for proportional scaling.


Filters are still unbalanced and cause wild spiking if resonance is up. Manually compensate with the volume, but later I'll even it all out more pleasantly. I do like some of the beautiful distortion though, particulare in bipolar mode and square waves at low pitches (0.125, 0.25 or 0.5). For anyone, who understands the concept of them, you can make great melodies with it already! 8)