Author Topic: [Code Snippets] ASIO, WASAPI, No mixer Direct output by PureBasic  (Read 12052 times)

Oryaaaaa

  • Posts: 44
Hello. I finished my software project "Bug head Ver1.x". This is eternal freeware.
Development was very because in this forum, there was no culture of the code sharing.
My software was made spending four months aiming at the highest sound quality in the world.

The sound of all the music software such as Foobar2000 and J-RIVER was dropped from the stage.
Does being possible to fight come in this sound? The sound of XMPlay is very bad.

Bug head Ver1.x, Digital remaster music player
http://www.un4seen.com/forum/?topic=13591.msg94713

The sound of considerable DAC of 1000 dollars is achieved with REALTEK AUDIO CODEC.
Invention of original sound processing technology that improves MP3-128kbps to high sound quality that equals SACD.
Victory complete compared with sound quality of which existing MP3 sound quality improvement technology.
If it is FLAC, the sound quality that competes for DSD and SACD is achieved.

The verification of the above-mentioned was executed with the high-level sound equipment of 2500 Euro.

I was a gratitude, and 300Euro paid un4seen SharewareLicense.
Ver2.x will shareware. A professional translator is writing an English manual.
Then, there is 100 Euro. There is no sales experience of Shareware though I want to sell this.
I have the sales base in Japan only.  It is worry today.

Condition that sound worsens
  • Use Bassmix libraly. If you use hardware mixer, then more bad sounds.
  • An already-known sound processing technology is trusted.
  • It doesn't verify it with the highest audio device in the world.
  • It doesn't have the ideal of an ultimate in one's own way sound.
  • There is no experience such as remodeling an analog amplifier.

Condition that sound improves
  • The weak point in the BASS library is completely understood.
  • The weak point of other music players is researched.
  • Fact confirmation to "Bug head" that reaches ultimate sound quality by using BASS library.
  • I point out that an already-known sound processing technology is worst.
  • The verification is confirmed repeatedly by dare wrong.  Overturn it in the latest environment.
  • I don't have the experience of learning the sound processing technology.
  • A wavy display of the output data of "Bug head" is abnormal.
  • Still, when becoming a sound wave, it was able to be recognized the charming sound.
  • Throw away common sense.

I want to share code for Bass developer.
Code: [Select]
Select UCase(ext)
  Case "MP3", "OGG", "WAV"
    chan = BASS_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
   
  Case "M4A", "AAC"
    chan = BASS_AAC_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
    If chan=0
      chan = BASS_ALAC_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
      If chan=0
        chan = BASS_MP4_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
      EndIf
    EndIf
   
  Case "WMA"
    chan = BASS_WMA_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
   
  Case "FLAC"
    chan = BASS_FLAC_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
   
  Case "CDA"
    chan = BASS_CD_StreamCreate(Drive, track, #BASS_SAMPLE_FLOAT|#BASS_STREAM_DECODE)
   
  Case "WV"
    chan = BASS_WV_StreamCreateFile(#False, @Filename, 0, 0, #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN)
   
EndSelect

Code: [Select]
Procedure.l AsioProc(input.b, channel.l, *buffer, length.l, *user)
  Shared chan4.l, Endpos.b, UST.b
  Protected infopos.q, infolen.q
  Protected *b=*buffer
  Protected C.l = 0
  Select chan4
    Case #chan3
      If (out_2s-out_2p)>length
        CopyMemory(*out_2+out_2p, *b, length)
        out_2p + length : C = length
      ElseIf out_2s>out_2p
        CopyMemory(*out_2+out_2p, *b, out_2s-out_2p)
        C = out_2s - out_2p : out_2p = out_2s
        If out_1s>out_1p
          CopyMemory(*out_1+out_1p, *b+C, length-C)
          out_1p = length - C : C = length
          chan4 = #chan2
        EndIf
      EndIf
     
    Case #chan2
      If (out_1s-out_1p)>length
        CopyMemory(*out_1+out_1p, *b, length)
        out_1p + length : C = length
      ElseIf out_1s>out_1p
        CopyMemory(*out_1+out_1p, *b, out_1s-out_1p)
        C = out_1s - out_1p : out_1p = out_1s
        If out_2s>out_2p
          CopyMemory(*out_2+out_2p, *b+C, length-C)
          out_2p = length - C : C = length
          chan4=#chan3
        EndIf
      EndIf
     
  EndSelect
   
  ProcedureReturn C
EndProcedure

BASS_ASIO_ChannelEnable(0,0,@AsioProc(), 0)

Procedure.l WasapiProc( *buffer, length.l, *user)
  Shared chan4.l, Endpos.b, UST.b
  Protected infopos.q, infolen.q
  Protected *b=*buffer
  Protected C.l = 0
  Select chan4
    Case #chan3
      If (out_2s-out_2p)>length
        CopyMemory(*out_2+out_2p, *b, length)
        out_2p + length : C = length
      ElseIf out_2s>out_2p
        CopyMemory(*out_2+out_2p, *b, out_2s-out_2p)
        C = out_2s - out_2p : out_2p = out_2s
        If out_1s>out_1p
          CopyMemory(*out_1+out_1p, *b+C, length-C)
          out_1p = length - C : C = length
          chan4 = #chan2
        EndIf
      EndIf
     
    Case #chan2
      If (out_1s-out_1p)>length
        CopyMemory(*out_1+out_1p, *b, length)
        out_1p + length : C = length
      ElseIf out_1s>out_1p
        CopyMemory(*out_1+out_1p, *b, out_1s-out_1p)
        C = out_1s - out_1p : out_1p = out_1s
        If out_2s>out_2p
          CopyMemory(*out_2+out_2p, *b+C, length-C)
          out_2p = length - C : C = length
          chan4=#chan3
        EndIf
      EndIf
     
  EndSelect
 
  ProcedureReturn C
EndProcedure

BASS_WASAPI_Init(WasapiSelectDevice, freq, 2, #BASS_WASAPI_BUFFER | #BASS_WASAPI_EXCLUSIVE, 0.2, 0, @WasapiProc(), 0)

Code: [Select]
<Sound Thread>
pos.q = BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
Pos2.q = BASS_ChannelGetPosition(chan,#BASS_POS_BYTE)
If (pos-Pos2)<=#BUF1
  pdiv = pos-Pos2
  K = Bass_ChannelGetData(chan, *out2, pdiv)
  If K>0
    pdiv = K
  EndIf
  NextPlaysongs()
  If chan<>0
    pos=BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
    If pos>(#BUF1-pdiv)
      K = Bass_ChannelGetData(chan, *out2+pdiv, #BUF1-pdiv)
      If K>0
        pdiv + K
      EndIf
    EndIf
  Else
    LockMutex(Mutex) :Endpos=2 : UnlockMutex(Mutex)
  EndIf
Else
  pdiv = #BUF1
  K = Bass_ChannelGetData(chan, *out2, pdiv)
  If K>0
    pdiv = K
  EndIf
EndIf
LockMutex(Mutex)
Select ch
  Case 1
    CopyMemory(*out2, *out_2, pdiv)
    NowChan = #chan2 : chan4 = #chan2 : out_2s = pdiv : out_2p = 0
  Case 2
    CopyMemory(*out2, *out_1, pdiv)
    NowChan = #chan3 : chan4 = #chan3 : out_1s = pdiv : out_1p = 0
EndSelect
ready=pdiv
UnlockMutex(Mutex)

kstuart

  • Posts: 31
Unfortunately, your English language skills are not as good as your coding skills appear to be.

So, it is not clear exactly what you are doing.

I suggest finding a friend who speaks English well and having the friend post a better translation.