19 May '13 - 17:46 *
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: Faster bass Encoding?  (Read 990 times)
Sn!per X
Posts: 9


« on: 14 Oct '10 - 12:10 »
Reply with quoteQuote

Hello,
I am using delphi to encode an Audio File to wav:
I used: BASS_Encode_Start(channel, 'output.wav', BASS_ENCODE_PCM or BASS_ENCODE_AUTOFREE, nil, nil);
after that i use:
BASS_ChannelPlay(channel, False); // start the channel playing & encoding

The problem is the encoding will take long time to finish, its like Recording a song,
what i need is faster way, Like Encoding without playing the sample song?

Thanks In Advance
Logged
radio42
Posts: 4012


« Reply #1 on: 14 Oct '10 - 13:52 »
Reply with quoteQuote

Just create a decoding stream (using the BASS_DECODE flag with BASS_StreamCreateFile) and then call BASS_ChannelGetData in a loop.
Logged
Sn!per X
Posts: 9


« Reply #2 on: 14 Oct '10 - 16:43 »
Reply with quoteQuote

Hello,
radio42 thanks for your reply  Smiley

Still little Stucked:

type
  TBuf       = array of SmallInt;
var
  Buffer : TBuf;
  Stream : HSTREAM;
begin
   Stream := BASS_StreamCreateFile(False, PChar(FileName), 0, 0, BASS_STREAM_DECODE);
   BASS_Encode_Start(Stream, 'output.wav', BASS_ENCODE_PCM, nil, nil);
   BASS_ChannelGetData(Stream, @Buffer, BASS_DATA_FFT1024);
{what i am missing?}
End;
You mean Like above?
and how to call back BASS_ChannelGetData?

Please give me a sample code

Thanks again
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #3 on: 14 Oct '10 - 16:50 »
Reply with quoteQuote

You need to call BASS_ChannelGetData repeatedly until all of the source stream has been processed. The loop could look something like this...

while (BASS_ChannelIsActive(Stream) && BASS_Encode_IsActive(Stream)) { // decoder and encoder are still going
BYTE buf[20000];
BASS_ChannelGetData(Stream, buf, sizeof(buf)); // process some data
}
Logged
Sn!per X
Posts: 9


« Reply #4 on: 14 Oct '10 - 19:11 »
Reply with quoteQuote

Thanks Ian  Smiley

What you pointed to is worked for me  Cheesy

Just wondering, what the best Buffer size i should use?
More bigger buffer = Faster, but sometimes the end of the file will be there Much 0 Bytes, so what you suggest?

Thanks again and have a nice day
Logged
AndyMK
Posts: 171


« Reply #5 on: 15 Oct '10 - 08:41 »
Reply with quoteQuote

Quote
but sometimes the end of the file will be there Much 0 Bytes, so what you suggest?

Before you start your encoding, get the size of the source in bytes. Choose a buffer size and loop through the decoding, updating how much you have decoded. Each loop, check how much you have decoded against the total size of the source and if the amount decoded plus the buffer size is greater than the total, decode the total amount minus the amount already decoded to finish the remainder.
« Last Edit: 15 Oct '10 - 09:53 by AndyMK » Logged
radio42
Posts: 4012


« Reply #6 on: 15 Oct '10 - 09:27 »
Reply with quoteQuote

Quote
More bigger buffer = Faster
This is not necessarily true and depends on the encoder and if you are encoding a file or a CD track. So a general answer can not be given.
For CD tracks a good number is 235200 bytes - as this is the size of 100 sectors.
For files you might use 128KB or more...you'll notice, that the encoding speed is much more limited by the encoder encoding itself than your buffer size.
Logged
Sn!per X
Posts: 9


« Reply #7 on: 15 Oct '10 - 16:33 »
Reply with quoteQuote

Hello,

Finally i used the whole file size as a buffer and looped throught it

Thanks guys for the big help and support  Smiley
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines