Feeding raw PCM to an OutputStream?

View: New views
1 Messages — Rating Filter:   Alert me  

Feeding raw PCM to an OutputStream?

by Peter Mosedal Laursen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,
 
I am wondering how I might feed more data into an outputstream created with AudioDevice::OpenBuffer?
 
Here is some sample code - it only takes a certain number of frames from the beginning of a raw 16 bit mono file. What I should want ideally is to be able to read more data into my buffer and then play it when the first buffer has finished playing.
 
Any reply is very much appreciated.
Peter.
 
-- Sample Code --
// LoadFile.cpp
// Compiled on MS Visual C++ on Windows XP Pro SP 2
#include <windows.h>
#include <audiere.h>
#include <stdio.h>
using namespace audiere;
using namespace std;
int main() {
int BytesToRead = 102400 * sizeof(short);
char* Buffer = new char[BytesToRead];
AudioDevicePtr Device(OpenDevice());
printf(Device->getName());
FILE* fin = fopen("temp.raw", "rb");
if (fin) printf("\nFile opened.\n");
fread(Buffer, 1, BytesToRead, fin);
OutputStreamPtr Stream;
SampleFormat SF = SF_S16;
Stream = Device->openBuffer(Buffer, 102400, 1, 22050, SF);
Stream->play();
printf("Time to sleep.\n");
Sleep(30000);
delete[] Buffer;
}
-- End of code --
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audiere-users mailing list
Audiere-users@...
https://lists.sourceforge.net/lists/listinfo/audiere-users
LightInTheBox - Buy quality products at wholesale price