December 11th, 2004 05:07 PM
C++ buffers in buffers
I have a little problem. I made a program that record from the microphone and when I press a button plays it. But I want to made it to plays in realtime, not to press a button. I think it can be done by buffers. But I want to add buffers at design time (the number and the size of buffers). I tried with char buf[i]=malloc(size), but it didn't record anything. Can anybody help we. If you want I can post the source that I use.
December 11th, 2004 06:56 PM
I'm not sure that char buf[i] = malloc(size) makes any sense. What I would have thought you would do would be:
My code could be wrong because I'm not certain what you're trying to do. What you have written above says "create a character array of size 'i' and allocate size memory for it" (not sure about the last part). That doesn't really make too much sense. I would expect you to create an array first, then allocate sizes for the individual elements. But then again, I could be completely wrong because I'm not a hardcore c programmer
int length = 10, i=0;
for(i=0; i<length; i++)
buf[i] = malloc(size);
If that's not your problem, the other thing that I would suspect is that you're not accessing the buffer correctly. When I think about it now, I think what I said above was wrong. How are you attempting to write to the buffer? Are you getting a pointer to the buffer and then using it to access it? That's what you would need to do, I think.[/edit]
Hope that helps you,
December 13th, 2004 02:07 PM
Yes yes, i just type buf[i]=malloc(size) to save wirting )))
OK. My problem is:
I want to make a program that will play in real time everything I say in the microphone. I'm with Windows XP and Borland C++ Builder 6.0.
January 4th, 2005 11:41 PM
c'mon boyz I'm sure that someone can help. Please ... it is very important for. OK ... I can explain what I need. I need to write a program such a VoIP phone, but only p2p i pc2pc, not pc2phone or the other thing. Just ... argh how to say ... may be like voice chat.