Is this possible?

I was trying to create a command line program which first plays a song specified in the argument to the program and then asks the user for point A (startpoint of loop), point B (endpoint) and then infinitely loops between points A and B.

The user would specifiy the points as soon as he hears them. The code for the loop function looks like this (keep in mind that the stream is already playing when the loop function is called).

Note: also I’m unsure on how to get C++ to read just carriage returns from the command line so I sort of hacked the functionality of reading in points A and B by reading in any arbitrary number.

EDIT: Done it! Was using getcurrentposition instead of getposition. The following code does the job:

[code:aczianyu]void loop (FSOUND_STREAM* song, int Channel)


int startpoint = 0;
int endpoint = 0;

int anyresponse = 0;
int anyresponse2 = 0;

cout << "Press enter to set point A:";

cin >> anyresponse;

startpoint = FSOUND_Stream_GetPosition(song);

cout << "Press enter to set point B:";

cin >> anyresponse2;

endpoint = FSOUND_Stream_GetPosition(song);

int loopNum = 0;

cout << "Please enter number of times to loop segment: ";

cin >> loopNum;

FSOUND_Stream_SetPosition(song, startpoint);

int i = 0;

while ( i < loopNum )


if (FSOUND_Stream_GetPosition(song) &gt;= endpoint)


    FSOUND_Stream_SetPosition(song, startpoint);





  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.