i try to get the sampledata of a sample which is loaded by fmod with:
if FSOUND_sample_lock(sample,0,FSOUND_sample_getLength(sample)*4,ptr1,ptr2,len1,len2) then
myBuffer is an array of smallint.
and i get an access violation at the move-statement, but if i wanna write data to the sample (the same thing, just in the other direction) with
so i don´t understand why! perhaps, here´s another deplhi-coder who has the answer?
I’m not sure if you can “force” fmod to have a buffer length of 576 samples, never tried, nor have I seen anything on it. I may be wrong.
But, what you can do is get the buffer and cast it into your own local buffer then return the result back to the DSP chain. Then you have a “copy” of the buffer. From there you just do some math to determine the number of samples, then truncate or add more until you reach the 576 samples you want.
You may even need to have a true stream buffer in the callback that doesn’t return the result to the DSP chain until you reach the 576. Just keep adding samples to the buffer until you reach 576.
Either way is a fairly involved process and can be daunting if you’ve never done it before. My first try took two days just to get the buffer to cast into a variable of my own just so I could see the data!
I would take a look at all the DSP samples you can find (I have a few in this forum), and maybe Sly can Up the new TestBed to some webspace for everyone to download. Sly added an oscilliscope to the TestBed source code, very nice.
Other than that, its trial and error. If someone, or even if I, have time maybe some code could be posted on retreiving a fixed amount of samples from a callback.
Two months since I’m trying to get vis working… With Winamp in_.dll plugin I found how to make it work, but I didn’t found how to delay the buffer. And I prefer to use FMOD.
I’ve made an announce at http://www.powerdivx.com , your help will be appreciated because I need to focus on the dev of my player and I hope you can help me…
I think you may have a problem using the array of SmallInt.
I had pretty much the same problem with some code I was doing for a callback to get the waveform data. I tried several Integer types before finding why SmallInt won’t work as is.
When you try to dereference ptr1^ into MyBuffer, your moving data that could be floating point into an integer array. Although SmallInt is valid for the range, you need to convert the floating point to an integer value. Since an Integer can be cast into a float variable it won’t cause an error going the other way. A Perfect example of this is :
I, J : Integer;
Value : Single;
Value := I / J;
This will work, where if you were to make I and J single and Value an Integer it wouldn’t even compile. The issue with pointers is that delphi may not know what “type” of data is at the address, but it does know the address of where it starts.
So I think its because you’re getting floating point values. Check your MIXER setting, however, even when I use AUTODETECT for the mixer type I always get FPU, so I just choose FPU and use the floating point conversions to get the proper data.
I hope this helps you out, you may want to check my Oscilloscope code, it may help you get ideas, or it may just confuse you. It confused me when I first tried it.
thank you for your answer, but i think you´re wrong: it´s right, that the buffervalues for callback-routines are floats (depending on your mixer-type), but a “normal” sample is represented as it is stored on harddisk (e.g. 16bit-stereo -> 2 smallints (left+right) for every sampleframe)
the mistake was anotherone AND I GOT IT!!! YESSSS! :
i´ve made a very stupid thing. i´ve called the initializing of the soundengine twice (it´s already a big big program with very much of sourcecode!) and between these calls, i load the samples, which of course are “broken” after the second init. just removing the second init did fix all my trouble. what a shame, it did cost me 2 long days!
I can’t tell you how many times I’ve done something along the same lines.
I write corporate SQL DBMS for a career and even after years of pretty much doing the same code, I still make little errors that can be a plague for days!
I’m glad you got it fixed.
Please login first to submit.