Results 1 to 2 of 2

Thread: BASS- how to know when song is complete?

  1. #1

    BASS- how to know when song is complete?

    Well? Can anyone give me some code examples on knowing when a playing audio file is complete, without OOP or classes? IE, my current setup is...

    [pascal]
    Procedure PlaySound;
    begin
    music_file := ' ';
    StrPCopy(music_file,musicfile[x]);
    //music_file := 'C:\Projects\Task Scheduler\test.wav';
    init_stuff;
    load_song;
    BASS_setvolume(volume[x]);
    totallength := round(BASS_ChannelBytes2Seconds(stream,BASS_Stream GetLength(stream)));
    Writeln('Playing file ',MUSIC_FILE,'.');
    readkey; //Instead of readkey, I want to check if song is finished, and if yes, continue procedure.
    stop_song;
    done_stuff;
    end;
    [/pascal]

    And in case your wondering, the music_file := ' ..' is like that because if the size of the var is too small (empty) the StrPCopy won't work properly...
    --MagicRPG--

  2. #2

    BASS- how to know when song is complete?

    Well, I found a solution. But, it opens another problem... Which I also found a solution to

    [pascal]
    Procedure PlaySound;
    begin
    music_file := ' ';
    StrPCopy(music_file,musicfile[x]);
    //music_file := 'C:\Projects\Task Scheduler\test.wav';
    init_stuff;
    load_song;
    BASS_setvolume({volume[x]}100);
    totallength := round(BASS_ChannelBytes2Seconds(stream,BASS_Stream GetLength(stream)));
    textcolor(12);
    Writeln('Playing file ',MUSIC_FILE,'.');
    textcolor(7);
    play_song;
    y := 1;
    repeat
    y := y+1;
    delay(1000);
    until y = totallength+2;
    y := 0;
    stop_song;
    done_stuff;
    textcolor(7);
    end;
    [/pascal]

    Now, how I did it, was using the totallength := round(BASS_ChannelBytes2Seconds(stream,BASS_Stream GetLength(stream))); which gets the totallength, in seconds, of the song, and made a repeat.. until which made y increment by 1 every second, until y was equal to totallength plus 2 seconds... (to make sure none of the song/sound is cut off). So, yeah. Now I have the problem that the delay forces the program to stop, so I'm just gonna make it launch an external program which plays the sound and such.
    --MagicRPG--

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •