Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

synchronisation ???

Status
Not open for further replies.

starn

Programmer
Mar 12, 2002
18
BE
Hi!!

I read 64 bytes from a file like this:

ifstream in ("music.wav", ios::in | ios::binary );
in.read (buffer,64);

What do I have to do to read these 64 bytes 192000 times a second? (192kHz)

It's to simulate an input that recieve sound samples at 192 kHz....

Thanks a lot for any help and sorry for my english :)

Starn
 
??? Why read them 192000 times a second??? I'm pretty certain it is imposible to do that with the current hardware-well, almost, if you exclud the buffered io Anyway, that would mean... 12GB/s!!.

You have to read that file just once into memory and the use the Windows API's to play the sound. (for example the PlaySound function) [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Well, I meant 64 bits at 192 kHz...

Now, I m trying to take a sound file with samples of 24 bits for each channel and transform it in the AES/EBU format : 2 channels of 24 bits + 8 bits of control, that makes 64 bits.
AES/EBU is a transport protocol of uncompressed sound but I dont have any reciever for it. So, to test my software, I would like to simulate it : I send to a buffer 64 bits samples at 192 kHz...
That's the only idea I got to do that...

But maybe, for the first step, how do I synchronise the reading from a file?
I don't know, maybe 64 bits every second...

Again sorry for my english and thanks a lot for the help!!

Starn

 
As far as I know, it is not possible to sleep or wait for a time less than 1 millisecond in Win32. So I think your only chance is to make an idle loop and measure its time so you can adjust it depending on processor speed. It has to run on real-time priority in order to prevent other processes taking over the cpu, which means that your system is going to be inresponsive. Not a good solution I suppose ..
BTW, who is going to buy a 12 GB disk from someone who claims 192000 * 64 = 12 GB?? :)
 

Well,12MB is better... ;-)

Do you know any function that read "x" bytes every "y" microseconds?
There is no other way to play with time other than with CPU speed?
I know that I'm going to have trouble trying to make real-time with Windows... Windows is not a real-time OS like Unix... But there isn't any way to give priority to an application?
(I know, the last question is off-topic...)


Thanks!

Starn
 
Gulp... Yep... Well... uuh... Luckly I'm not selling computers...
Actually I was doing 192K*64/1024... I should divide that again... [morning]

No, there is no such function, you have to write it yourself.
I guess that the solution proposed by MK should do it and it would be the best, even if it seems a bit awkward and does not represent necesarly a correct solution, just because the priorities.
On Windows you have a function for that, SetThreadPriority so I suppose there is one on UNIX also.

[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top