0
0

Hi everybody,

I work on a projet for my school ( Encryption of FM transmission ) and I try to create a program that get the line in of the computer ,then crypt the data from this line in and play the encrypted sound on the line out.

Now i have the program that get the line in on put it on the line out.( i take the reccord.cpp demo and i modify it)
My major problems is to modify the data.
I created a function in order to do that …

void CopySample_v2(FSOUND_SAMPLE *srcSample,int recordpos)
{
void *t1_deb=NULL;
void *t2_deb=NULL;
unsigned int t1_len;
unsigned int t2_len;
if(FSOUND_Sample_Lock(srcSample,recordpos,CRYPT_LENGTH,&t1_deb,&t2_deb,&t1_len,&t2_len) == TRUE )
{
*((short *)(t1_deb)) = 0;
FSOUND_Sample_Unlock(srcSample,t1_deb,t2_deb,t1_len+1,t2_len);
}
else
{
printf(“Encryption error”);
}
}

I think that *((short *)(t1_deb)) is a part of the data that i want to modify ( maybe i’m wrong….).that’s why,in order to test it,i put this data to 0.
My purpose was to see if,even there is sound in line in , the line out stay quiet .(that would mean that my encryption function is good… )

I have heard also about fmod upload function but it doesn”t work too.( i didn’t really understand how this function work so i must use it in bad ways)
But it doesn’t work and after many weeks working on it,i now ask you the question :

What is wrong in my function or in my fmod programming???

Is there another way to modify sound data in real time using FMOD???
(If you are another solution with other languages or library ,i’m interested )

I hope you could help me soon…( My project presentation is in one week …)

Thanks you in advance and please forgive my poor english …

Sm@llpox 😳

  • You must to post comments
0
0

Hi,

What you are doing wrong is that you are just setting the first value in the sample buffer to 0

To set the whole sample buffer you have locked, you need to do something like this:

[code:3exvhsho]

if(FSOUND_Sample_Lock(srcSample,recordpos,CRYPT_LENGTH,&t1_deb,&t2_deb,&t1_len,&t2_len) == TRUE )
{
for (count = 0; count < CRYPT_LENGTH; count++)
{
*((short *)(t1_deb))++ = 0;
}

FSOUND_Sample_Unlock(srcSample,t1_deb,t2_deb,t1_len+1,t2_len);
}

[/code:3exvhsho]

  • You must to post comments
0
0

thanks you for your quick answer !!! :)

If my CRYPT_LENGHT (that is the lenght in octet to crypt each time I call my
function) is 1.The loop would be useless because it will be

for (count = 0; count < 1; count++)
{
*((short *)(t1_deb))++ = 0;
}
that is the same thing as : *((short *)(t1_deb)) = 0;

I’m going to try your solution for a CRYPT_LENGHT > 1 in order to see if you are right …

if i read correctly the fmod manual ( thing that is a little difficult to me because it has not yet be traduced in french 😆 ),my “t1_deb” variable is contain the adress of a part of my data (adress of the sample + offset…) .

Another question :
If i use record_pos = FSOUND_Record_GetPosition(),
Is record_pos is the position of the next data that has not been written or of the last data that has been written?
Is record_pos an adesse or an offset from the begining of the sample ?
(Sames questions for FSOUND_GetCurrentPosition).

Do you think it is a good solution to do that kind of code to modify data using fmod ???

  • You must to post comments
0
0

[quote:q7ygzlv0] this is incorrect. dereferencing a short pointer is only going to modify the first short, not the whole buffer. [/quote:q7ygzlv0]

But doing

[quote:q7ygzlv0]
for (count = 0; count < 1; count++)
{
*((short *)(t1_deb))++ = 0;
}
[/quote:q7ygzlv0]

Would modify the whole data in one time and each time i would call my function…. What i want is to change the octet that has just been wirtten (because it is a REAL TIME program)

Do you know how to do that ?

  • You must to post comments
0
0

I’m trying to pocess data in chunks as you said but it doesn’t work for the moment.

Did FSOUND_Sample_Upload() is needed to modify the data??? even reading the manual i don’t understand its advantage.

[quote:2wt60sdw]

if(FSOUND_Sample_Lock(srcSample,recordpos,CRYPT_LENGTH,&t1_deb,&t2_deb,&t1_len,&t2_len) == TRUE )
{
for (count = 0; count < CRYPT_LENGTH; count++)
{
*((short *)(t1_deb))++ = 0;
}

FSOUND_Sample_Unlock(srcSample,t1_deb,t2_deb,t1_len+1,t2_len);
}
[/quote:2wt60sdw]

Why ++ ??? if i modify the data in front of the recorder,it would change the data in the next loop,erasing the 0.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.