sound.samples not 16 bit - PLEASE HELP!
BlitzMax Forums/BlitzMax Programming/sound.samples not 16 bit - PLEASE HELP!
| ||
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?! |
| ||
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. |
| ||
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!) |
| ||
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 |
| ||
ARRRRRRRRRRRR............ NEVER MIND!!! (SF_MONO16LE as opposed to ...BE) YES! The joy... THE JOOOY! THANKS! 8) |
| ||
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! |
| ||
my pleasure. |
| ||
(red: volume) (yellow: pitch) ![]() |
| ||
thats a pretty little spiral :) |
| ||
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/ |
| ||
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. |
| ||
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! |
| ||
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! |
| ||
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) |