i want to access the data held in memory for a FSOUND_Sample… is the Sample just a sequence of bytes representing the recording (its a new sample on which i have recorded) or does it contain extra information? If i try to save it to a file byte after byte will i also save other info (like sample length, sampling rate etc?)
In general, can what i’m trying to do work? 😮
- McWeasel asked 14 years ago
You can get wathever Fmod can handle (except for midi) in a dsp callback and then, yes, you must write to a fill with some informations depending of the file format … or without ! You will get a raw pcm data file (must be 44100/16/stereo).
unless i got the byte count wrong (Sample_GetLength*16/8) then i’m sure everything else is as it should be. the strange thing is that the fault i’m getting is trying to write to memory location 0x00000000 which might be something although i don’t know what, maybe you’ve seen this before.
i’ve got windows 2000 btw
what exactly is trivial? maybe it is but i guess i’m standing too close to see it… anyway, what i want to ask you now is this:
can I use Stream_OpenFile to play a sample I have just recorded or not? and if I can, what would the reasons be if it failed?
yoooooohooo got the Sample_Lock thing to work! amazing…
i was doing:
FSOUND_Sample_Lock(recSample, offset, 10000, &buf1, &buf2, &length1, 0);
and that last parameter was making it crash
i changed it to &length2 and everything works fine.
took me a while 😉
anyway, i’m still interested in the answer of my previous question
hey… i checked out the code you gave me and i think its kind of advanced for me at the moment. Still, i tried to understand how
Sample_Lock works and this is my code:
int samplescount = FSOUND_Sample_GetLength(recSample);
int numBytes = (samplescount*16)/8;
void *buf1, *buf2;
unsigned int length1 = (unsigned int) numBytes;
if(FSOUND_Sample_Lock(recSample, 0, numBytes, &buf1, NULL, &length1 , 0))
cout << “Lock successfull.” << endl;
when i run my program i get a (windows 2000) error message saying memory at blah blah could not be written. can you see any problems with the code?
listen… i used Lock to lock a sample and then I flushed it to a file… a pcm file. Then when I play the file I can hear the recording but there is a large amount of noise in it. What do you suppose can be causing that? The sample sounds perfectly fine when I play it right after recording it. The code I use to flush it is this:
FSOUND_Sample_Lock(recSample, offset, numBytes, &buf1, &buf2, &length1, &length2);
cout << “sample in bytes: ” << (samplescount*16)/8 << endl;
char * myPointer = (char *) buf1;
int counter = 0;
while(counter < numBytes)
//cout << “Counter: ” << counter << endl;
outfile << *myPointer;
FSOUND_Sample_Unlock(recSample, &buf1, &buf2, length1, length2);
void *buf1; // buffer of the first part of the buffer
void *buf2; // buffer of the second part of the buffer, FMOD will return NULL if the data hasn’t wrapped the end of the buffer (remember : audio data are circular buffers)
unsigned int length1 = (unsigned int) numBytes; // no !! this job is for fmod, it will return you how much bytes was locked for the first part of the buffer, so don’t initialise it
unsigned int length1, length2;
offset = 0;
if(FSOUND_Sample_Lock(recSample, offset, numBytes, &buf1, &buf2, &length1 , 0))
cout << "Lock successfull." << endl;
offset += numBytes;
I’m killing you with my questions but here is another one (you could probably take all these q&a and put them in a FAQ or something) :
what would a STREAMCALLBACK function would have to contain in order to be considered complete?
hi again 😉 sorry for too many questions
maybe you can explain briefly what sample_lock is supposed to be doing cause i don’t get it 😡
PS: i’m still getting that memory can’t be written thing… i even added void * buf1 = new void*; but nothing
sample_lock is (i think) supposed to fill a block of data to a buffer. Though, Fmod need to know how much data you want and then, fmod will return exactly how much data has been written to this buffer.
Concerning your segfault, do you use the sample_unlock function just after writing the data to your file ? You MUST use it (Fmod will know it can release/free the buffer).
so then if lock does not do anything to memory why am i getting a “memory could not be written” fault? i can show u my code if you want and maybe u can figure it out… but what i do is very simple, i just record a sample and then i try to lock it and i get the fault
PS: Iron Maiden – Fear of the dark
lock doesnt fill the pointer with anything, you are just getting a pointer back that points to the raw data. If you want to know the format you would use FSOUND_Sample_GetMode and FSOUND_Sample_GetDefaults.
Ah ok 😳
Please login first to submit.