[Stk] RtAudio - Read entire file to memory

Stephen Sinclair sinclair at music.mcgill.ca
Tue Mar 30 03:19:48 PDT 2010


Thomas,

You've only posted file reading code, but no audio play-back code
(RtAudio or WvOut), so I don't think I can tell you why your program
is not playing.  You'll have to post the entire code.

Steve

On Tue, Mar 30, 2010 at 10:48 AM, TJF <tjfoerster at web.de> wrote:
> Hi,
>
> I cannot find the solution for my problem: I want to read an entire
> raw-file to memory and play it. My example here is the basic playraw.cpp.
> The problem is, that the new code (s.below the replaced code) could be
> compiled without any problem (i.e. Win) and the program starts without
> problem and it ends without any problems. But it ends immediately. It
> does not play anything. If I do any SLEEP, I can see that the entire
> file is loaded to memory, but will not be played.
>
> Any idea?
>
> Thanks a lot.
> Regards
> Thomas
>
>
>
> FORMAT RTAUDIO_SINT16
>
> // -------- original section rawplay.cpp - beginning
> -------------------------------------------------------------------------------------------------------------
> /*
>  OutputData data;
>  data.fd = fopen( file, "rb" );
>  if ( !data.fd ) {
>    std::cout << "Unable to find or open file!\n";
>    exit( 1 );
>  }
> */
> // -------- original - end
> ---------------------------------------------------------------------------------------------------------------------
>
> // -------- replaced code - beginning
> -------------------------------------------------------------------------------------------------------
>
>    OutputData data;
>    int Size;
>    void *buffer;
>    size_t result;
>    data.fd = fopen ( file , "rb" );
>    std::cout << "\ndata.fd1 " << data.fd << std::endl;
>    if (data.fd==NULL) {
>        std::cout << "Unable to find or open file!\n";
>        exit (1);
>    }
>    fseek (data.fd , 0 , SEEK_END);
>    Size = ftell (data.fd);
>    buffer = calloc (Size,1);
>    std::cout << "\nbuffer:  " << buffer << std::endl;
>    if (buffer == NULL) {
>        std::cout << "Memory error!\n";
>        exit (2);
>    }
>    rewind (data.fd);
>    result = fread (buffer,1,Size,data.fd);
>    std::cout << "\ndata.fd2 " << data.fd << std::endl;
>    if (result != Size) {
>        std::cout << "Reading error!\n";
>        exit (3);
>    }
>
> // -------- replaced code - end
> -------------------------------------------------------------------------------------------------------
>
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>
>
>



More information about the Stk mailing list