26 May '13 - 08: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: Bug? BASS_StreamCreateFile have a problem.  (Read 849 times)
Oryaaaaa
Posts: 24


« on: 7 Jun '12 - 01:07 »
Reply with quoteQuote

I made "Bug head".
http://www.un4seen.com/forum/?topic=13591.0

Output 32FLOAT/176.4kHz Wavefile to memory

handle = BASS_StreamCreateFile(#True, *out, 0, size+44, #BASS_STREAM_DECODE|#BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)

This method is high quality
!=Foobar2000, coz "no use LPF", Bug head have super quality digital low-path filter.

LPF Specification
http://nr3.coolverse.jp/_src/sc167/Web_logo3.png

But.... Cry

Input 32FLOAT/176.4kHz Wavefile form file

handle = BASS_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)

This sound is lossy quality. why?
=Foobar2000, maybe "use LPF"

What BASS library have the pre-processing when reading from a file?

Thank you
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #1 on: 7 Jun '12 - 16:16 »
Reply with quoteQuote

To confirm, are you saying that BASS is changing a WAV file's sample data? If so, that shouldn't be. To check whether it is, you could write the decoded data to another WAV file and then compare it with the original file. For example, if you load both files into Audacity, "Invert" one of them, and then "Mix and Render" them, you will end up with total silence (all 0s) if the files are identical.

Using the the BASSenc add-on, the file writing could be done like this...

HSTREAM decoder=BASS_StreamCreateFile(FALSE, filename, 0, 0, BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT); // create a "decoder" for the original file
BASS_Encode_Start(decoder, "output.wav", BASS_ENCODE_PCM|BASS_ENCODE_AUTOFREE); // set a WAV writer on it
while (BASS_ChannelIsActive(decoder)) {
BYTE buf[20000];
BASS_ChannelGetData(decoder, buf, sizeof(buf)); // process some data
}
BASS_StreamFree(decoder); // free the decoder and WAV writer

If you find that there is a difference, please upload the WAV file (original) to have a look at here...

   ftp.un4seen.com/incoming/
Logged
Oryaaaaa
Posts: 24


« Reply #2 on: 8 Jun '12 - 12:20 »
Reply with quoteQuote

Thank you, Ian@un4seen.

16/44.1PCM 10MB to 32/176.4PCM 80MB. I will search rellly short test music.
I use BASSmix to BASSasio... then decoreder change mixhandle. It's OK.
I didn't know BASSenc. one songs size is 280MB over.

I use why? bug?, coz I don't have an oscilloscope.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #3 on: 8 Jun '12 - 16:23 »
Reply with quoteQuote

Does the ASIO device/driver support the WAV file's sample format, eg. are you successfully calling BASS_ASIO_SetRate to set the device to the file's sample rate? If not, resampling will be required (either by BASSmix or BASSASIO or perhaps your own code?), which will modify the sample data.
Logged
Oryaaaaa
Posts: 24


« Reply #4 on: 10 Jun '12 - 10:10 »
Reply with quoteQuote

Yes, no problems. ASIO and WASAPI output OK.

32/176.4
WAVE VS WavPak
Size 420MB vs 280MB
CPU LOAD over vs 98%

WAVE loading process is very slow. I want to more quick loading FLOAT WAVE files.
and ... I change output foramt WavPak. I use "wavpackdll.dll". BASS lib slow Wave
Loading process. WavPak lib fast loading process. only 0.5...1.0 sec waiting time,
however Realtime processing critical waiting time.


The quality of tone quality is really a little. However, I am embarrassed because
 I understand plainly when becoming the environment of high-end.

File output code
DataSection
  Wave32header:
  Data.b $52,$49,$46,$46 ; RIFF : 0 :4
  Data.b 0,0,0,0 ; Size - 8 : 4 : 8
  Data.b $57,$41,$56,$45,$66,$6D,$74,$20 ; WAVEfmt : 8 : 16
  Data.b $10,$00,$00,$00 ; PCM : 16 : 20
  Data.b $03,$00 ; Float32 : 20 : 22
  Data.b $02,$00 ; Streo 2ch : 22 : 24
  Data.b 0,0,0,0 ; Format : 24 : 28
  Data.b 0,0,0,0 ; Speed : 28 : 32
  Data.b 0,0 ; BlockSize Byte/SamplexCh : 32 : 34
  Data.b 0,0 ; Bit : 34 : 36
  Data.b $64,$61,$74,$61 ; Data : 36 : 40
  Data.b 0,0,0,0,0,0 ; Raw Size : 40 : 44
  Data.b 0,0,0,0,0,0 ; Raw Size : 40 : 44
EndDataSection

Global callFile = CreateFile(#PB_Any, "C:\test_chk.wav")

Filename.s = OpenFileRequester("TEST", "*.*", "*.*;*.*", 0)
BASS_Init(0, 44100,0,0,#Null)
chan = BASS_FLAC_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
start =1
pos.q = BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
CopyMemory(?Wave32header, *out2, 44)
PokeL(*out2+24, 176400) ; Format
PokeL(*out2+28, 176400*8) ; Speed
PokeW(*out2+32, 8) ; BlockSize
PokeW(*out2+34, 32) ; Bit
PokeL(*out2+4, pos*2*4+44-8) ; Size - 8
PokeL(*out2+40, pos*2*4)
WriteData(callFile, *out2, 44)

....

  WriteData(callFile, *out2+44, posSinc)
  ;
Until Endpos=2

CloseFile(callFile)
MessageRequester("Finish", "")

Play output code for BASSmix
            pos.q = BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
            Pos2.q = BASS_ChannelGetPosition(chan,#BASS_POS_BYTE)
            CopyMemory(?Wave32header, *out2, 44)
            PokeL(*out2+24, freq) ; Format
            PokeL(*out2+28, freq*8) ; Speed
            PokeW(*out2+32, 8) ; BlockSize
            PokeW(*out2+34, 32) ; Bit
            If (pos-Pos2)<=#BUF1
              pdiv = pos-Pos2
              Bass_ChannelGetData(chan, *out2+44, pdiv)
              NextPlaysongs()
              If chan<>0
                pos=BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
                If pos>(#BUF1-pdiv)
                  Bass_ChannelGetData(chan, *out2+44+pdiv, #BUF1-pdiv)
                  pdiv=#BUF1
                EndIf
              Else
                LockMutex(Mutex) :Endpos=2 : UnlockMutex(Mutex)
              EndIf
            Else
              pdiv = #BUF1
              Bass_ChannelGetData(chan, *out2+44, pdiv)
            EndIf
            PokeL(*out2+4, pdiv+44-8);+44) ; Size - 8
            PokeL(*out2+40, pdiv)
            LockMutex(Mutex)
            Select ch
              Case 1
                BASS_StreamFree(chan2)
                CopyMemory(*out2, *out_2, pdiv+44)
                chan2 = BASS_StreamCreateFile(#True, *out_2, 0, pdiv+44, #BASS_STREAM_DECODE|#BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
                NowChan = chan2 : chan4 = chan2
              Case 2
                BASS_StreamFree(chan3)
                CopyMemory(*out2, *out_1, pdiv+44)
                chan3 = BASS_StreamCreateFile(#True, *out_1, 0, pdiv+44, #BASS_STREAM_DECODE|#BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
                NowChan = chan3 : chan4 = chan3
            EndSelect
            ready=pdiv
            UnlockMutex(Mutex)


ASIO Proc by BASSmix
Procedure.l AsioProc(input.b, channel.l, *buffer, length.l, *user)
  ;http://www.un4seen.com/forum/?topic=11261.0
  Shared mixer.l, chan4.l, chan3.l, chan2.l, Endpos.b
  Protected *b=*buffer
  Protected done.l = 0
  Protected C.l, c2.l
  C.l = BASS_ChannelGetData(mixer, *b+done, length-done); // get some data from the source
  If C=-1
    C=0
  EndIf
  done+C
  If done=length; // got the wanted amount of data
    C=length
  ElseIf chan4
    BASS_Mixer_StreamAddChannel(mixer, chan4, #BASS_MIXER_NORAMPIN)
    BASS_ChannelSetPosition(mixer, 0, #BASS_POS_BYTE)
    c2.l = BASS_ChannelGetData(mixer, *b+done, length-done); // get some data from the source
    If c2=-1
      c2=0
    EndIf
    C+c2
    If chan4=chan2 And Endpos=1
      chan4=chan3
    ElseIf chan4=chan3 And Endpos=1
      chan4=chan2
    Else
      chan4=0
    EndIf
  EndIf
  ProcedureReturn C
EndProcedure
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #5 on: 11 Jun '12 - 15:30 »
Reply with quoteQuote

Unfortunately, I think we are hitting a slight language barrier, and I am having some trouble understanding what problem you are having (and I guess the same is true for you with my replies). Are you now saying that BASS_StreamCreateFile calls on WAV files are slow, eg. the following calls?

                chan2 = BASS_StreamCreateFile(#True, *out_2, 0, pdiv+44, #BASS_STREAM_DECODE|#BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
...
                chan3 = BASS_StreamCreateFile(#True, *out_1, 0, pdiv+44, #BASS_STREAM_DECODE|#BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)

If you are experiencing a delay, I very much doubt that those calls are the cause of it (I would expect them to take less than 1ms). Please try timing the calls (eg. to a log file) to confirm things.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines