20 May '13 - 03:24 *
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: wma encoding lower level than wav  (Read 808 times)
atza
Posts: 69


« on: 29 Aug '11 - 11:39 »
Reply with quoteQuote

If I encode the same channel to wma,mp3 or wav,the resulting mp3 and wma files are much quieter than wav file.

if format='Wav' then    BASS_Encode_Start(chan,pchar(outpath),BASS_ENCODE_PCM,nil,nil);

if format='Wma' then    wmaencoder:=BASS_WMA_EncodeOpenFile(44100, 2, 0, 128000,pchar(outpath));

Only difference in code are above lines everything else is the same (channel processing etc...)
 Channel is stereo,44100
Logged
atza
Posts: 69


« Reply #1 on: 30 Sep '11 - 14:31 »
Reply with quoteQuote

No suggestions?
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #2 on: 30 Sep '11 - 15:36 »
Reply with quoteQuote

MP3 and WMA are both lossy formats, so they won't precisely match the original, but they should still sound about the same.

If you try using the pre-compiled CONTEST.EXE example in the BASSenc package (C\BIN directory) to encode the same file to MP3, does the resulting MP3 file sound much quieter too? If not, check what else you are doing in your app, eg. do you have any DSP/FX set on the source ("chan") when performing the encoding?
Logged
atza
Posts: 69


« Reply #3 on: 30 Sep '11 - 19:27 »
Reply with quoteQuote

Actually,I was testing it in winamp,and it turned out that winamp was set somehow to reproduce wav and wma at different levels...
So,it was my mistake not to notice this before,but on the other hand who would have thought...

But other issue arrives...  Now decoding an midi channel I get wav and mp3 files all right,but wma contains some crackling noise every few sec..
Now I now its hard to give an answer ,but maybe that's a  known issue to someone here?

BASS_Init(-1, 44100, 0, Handle, nil)

chan := BASS_MIDI_StreamCreateFile(FALSE,PChar(sourcefilename),0,0,0 or BASS_STREAM_DECODE or BASS_MIDI_DECAYEND or BASS_SAMPLE_FLOAT,0);

   if format='Wma' then


   wmaencoder:=BASS_WMA_EncodeOpenFile(44100, 2, BASS_SAMPLE_FLOAT, 128000,pchar(outpath));


    if format='Mp3' then
    begin
    cmdline:=mp3cmdline(samplerate,bitrate,channels,outpath);

    BASS_Encode_Start(chan,pchar(cmdline),BASS_ENCODE_FP_32BIT,nil,nil);
   
    end;

    if format='Wav' then
    begin
    BASS_Encode_Start(chan,pchar(outpath),BASS_ENCODE_PCM,nil,nil);
    end;
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #4 on: 3 Oct '11 - 14:27 »
Reply with quoteQuote

What does your BASS_WMA_EncodeWrite call (and the code around it) look like?
Logged
atza
Posts: 69


« Reply #5 on: 4 Oct '11 - 06:06 »
Reply with quoteQuote

while (BASS_ChannelIsActive(chan) > 0) do
         begin
                BytesRead:=BASS_ChannelGetData(chan, @buf, 10000);
                if format='Wma' then BASS_WMA_EncodeWrite(wmaencoder,@buf,10000);
                Application.ProcessMessages;
                if CancelOp then Break;

                if bytesread=0 then break;
           end;

  BASS_Encode_Stop(chan);
  BASS_WMA_Encodeclose(wmaencoder);
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #6 on: 4 Oct '11 - 15:08 »
Reply with quoteQuote

                BytesRead:=BASS_ChannelGetData(chan, @buf, 10000);
                if format='Wma' then BASS_WMA_EncodeWrite(wmaencoder,@buf,10000);

That looks like it could be the cause of the problem; the BASS_WMA_EncodeWrite call is writing a fixed amount of data (10000 bytes) instead of the amount delivered by the BASS_ChannelGetData call. Try changing it like this...

                BASS_WMA_EncodeWrite(wmaencoder,@buf,BytesRead);
Logged
atza
Posts: 69


« Reply #7 on: 5 Oct '11 - 08:08 »
Reply with quoteQuote

Hm, I was sure that it was going to solve it but it didn't - strangely

I also tried all flag combinations in encodewrite to no avail.
Even tried to set buf to all zeros before every GetData repeat

Anyway once again you surprised me by with whatever small amount of information you have you always come up with something which could be solution

Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #8 on: 5 Oct '11 - 14:07 »
Reply with quoteQuote

OK. To narrow down where the problem lies, please try writing a WAV file (using BASS_Encode_Start + BASS_ENCODE_PCM) at the same time as the WMA, and then check if the noise is present in the WAV file as well as the WMA file. You could also try removing the BASS_SAMPLE_FLOAT flag from the BASS_MIDI_StreamCreateFile and BASS_WMA_EncodeOpenFile calls, and see if that makes any difference.
Logged
atza
Posts: 69


« Reply #9 on: 5 Oct '11 - 14:46 »
Reply with quoteQuote

Wav file is OK
And removing float flag doesn't help

It's just one of those things...when everything is OK but it doesn't work-(happens a lot in programming...)

No ,big deal I 'll remove that option ('export wma') from my app

Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #10 on: 6 Oct '11 - 14:32 »
Reply with quoteQuote

It would still be good to know what's wrong. I'll send you a debug BASSWMA version to confirm what the WMA encoder is receiving.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines