19 Jun '13 - 16:52 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: problem with BASS_StreamCreateFile  (Read 813 times)
mikhail
Guest
« on: 29 Jul '12 - 11:08 »
Reply with quoteQuote

I use this code to create first 5sec stream from opened file:

chan := BASS_StreamCreateFile(FALSE, PChar(OpenD.FileName), BASS_ChannelSeconds2Bytes(chan, 0), BASS_ChannelSeconds2Bytes(chan, 5), BASS_SAMPLE_FX or BASS_SAMPLE_LOOP {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
   
but why bass plays all file?
Logged
Ian @ un4seen
Administrator
Posts: 15365


« Reply #1 on: 30 Jul '12 - 16:58 »
Reply with quoteQuote

The BASS_StreamCreateFile "offset" and "length" parameters deal in encoded file data, while BASS_ChannelSeconds2Bytes deals in decoded sample data, so the latter can't be used to set the former. If you want to play the first 5 seconds of a file, you can instead use a "mixtime" BASS_SYNC_POS sync and BASS_ChannelStop to end the stream after 5 seconds, like this...

stream=BASS_StreamCreateFile(FALSE, filename, 0, 0, 0); // create a stream
QWORD endpos=BASS_ChannelSeconds2Bytes(stream, 5); // translate 5 seconds to bytes
BASS_ChannelSetSync(stream, BASS_SYNC_POS|BASS_SYNC_MIXTIME, endpos, EndSyncProc, 0); // set a POS sync there
BASS_ChannelPlay(stream, 0); // start playing

...

void CALLBACK EndSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
BASS_ChannelStop(channel); // end the stream
}
Logged
mikhail
Guest
« Reply #2 on: 31 Jul '12 - 10:06 »
Reply with quoteQuote

I want to split file, not only play, ie I thought that I can load the file with this parameters and then save, and in the saved file will be only the first 5 seconds of song. How can I do so?
Logged
fmcoder
Posts: 387


« Reply #3 on: 31 Jul '12 - 10:28 »
Reply with quoteQuote

You'll need to use bassenc addon to do that.
Logged
mikhail
Guest
« Reply #4 on: 31 Jul '12 - 20:05 »
Reply with quoteQuote

I wait what Ian @ un4seen says. Please, give me example!
Logged
mikhail
Guest
« Reply #5 on: 6 Aug '12 - 15:35 »
Reply with quoteQuote

I use this code to encode, but how cut some interval from chan2 ?

chan2:=BASS_StreamCreateFile(FALSE, PChar(OpenD.FileName), 0, 0, BASS_STREAM_DECODE {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
enc:=BASS_Encode_Start(chan2, 'out.wav', BASS_ENCODE_PCM {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF}, nil, 0);
while ((BASS_ChannelIsActive(chan2)>0) AND (BASS_Encode_IsActive(enc)>0)) do
       begin
        BASS_ChannelGetData(chan2,@buffer, sizeof(buffer));
        application.processmessages;
        end;
Logged
White-Tiger
Guest
« Reply #6 on: 6 Aug '12 - 23:25 »
Reply with quoteQuote

u r a programmer (or at least u think u r xD) so find it out by your own^^
But this might help:
http://www.un4seen.com/doc/bass/BASS_ChannelSeconds2Bytes.html
http://www.un4seen.com/doc/bass/BASS_ChannelSetPosition.html
Logged
Ian @ un4seen
Administrator
Posts: 15365


« Reply #7 on: 7 Aug '12 - 14:45 »
Reply with quoteQuote

I use this code to encode, but how cut some interval from chan2 ?

If you want to extract/encode a part of a stream, you can do that by using BASS_ChannelSetPosition and limiting the amount of data that is processed via BASS_ChannelGetData. Here is some example code that was posted a few days ago...

   www.un4seen.com/forum/?topic=13915.msg96990#msg96990
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines