fbsound 1.0 Win/Lin 32/64-bit (wav mp3 ogg mod it xm s3m)

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

fbsound 1.0 Win/Lin 32/64-bit (wav mp3 ogg mod it xm s3m)

Postby D.J.Peters » Apr 28, 2011 13:50

fbsound Version is 1.0 for Windows and Linux 32/64-bit
It's for free: Image;-)

Download binary release: fbsound-1.0.zip

Download source code: fbsound-1.0-src.zip

Tested successful on:
Windows XP 32-bit
Windows 7 32-bit
Windows 10 64-bit
Slackware Linux 32-bit
Slackware Linux 64-bit
Ubuntu 64-bit

What is included:

fbsound-1.0.html

Fresh build of libraries for windows x86:
lib/win32/libdumb.a
lib/win32/libdsp.a
lib/win32/libcpu.a
lib/win32/libmad.a
lib/win32/libogg.a
lib/win32/libvorbis.a
lib/win32/libvorbisfile.a
lib/win32/libfbsound.a
lib/win32/libplug-mm-32.dll.a
lib/win32/libplug-ds-32.dll.a

Fresh build of libraries for Windows x86_64:
lib/win64/libdumb.a
lib/win64/libdsp.a
lib/win64/libcpu.a
lib/win64/libmad.a
lib/win64/libogg.a
lib/win64/libvorbis.a
lib/win64/libvorbisfile.a
lib/win64/libfbsound.a
lib/win64/libplug-mm-64.dll.a
lib/win64/libplug-ds-64.dll.a

Fresh build of libraries for Linux x86:
lib/lin32/libdumb.a
lib/lin32/libdsp.a
lib/lin32/libcpu.a
lib/lin32/libmad.a
lib/lin32/libogg.a
lib/lin32/libvorbis.a
lib/lin32/libvorbisfile.a
lib/lin32/libfbsound.a
lib/lin32/libplug-alsa-32.so
lib/lin32/libplug-dsp-32.so
lib/lin32/libplug-arts-32.so

Fresh build of libraries for Linux x86_64:
lib/lin64/libdumb.a
lib/lin64/libdsp.a
lib/lin64/libcpu.a
lib/lin64/libmad.a
lib/lin64/libogg.a
lib/lin64/libvorbis.a
lib/lin64/libvorbisfile.a
lib/lin64/libfbsound.a
lib/lin64/libplug-alsa-64.so

examples:
fbs_create_wave.bas
fbs_destroy_wave.bas
fbs_get_keycode-window.bas
fbs_get_length.bas
fbs_get_playingsounds_mp3.bas
fbs_get_playingsounds_mp3stream.bas
fbs_get_playingsounds_ogg.bas
fbs_get_play_xyz.bas
fbs_get_soundpointers_mp3.bas
fbs_get_soundposition.bas
fbs_get_streambuffer_mp3stream.bas
fbs_init.bas
fbs_init_44_22_khz.bas
fbs_init_second_plugin.bas
fbs_load_and_destroy_wav.bas
fbs_load_and_play_wav.bas
fbs_load_and_reloading_mp3stream.bas
fbs_load_it.bas
fbs_load_mod.bas
fbs_load_mp3file_mixer.bas
fbs_load_oogfile.bas
fbs_load_s3m.bas
fbs_load_xm.bas
fbs_mp3stream_preview.bas
fbs_pause_rewind_sound.bas
fbs_set_get_pointers.bas
fbs_set_loadcallback_mod.bas
fbs_set_loadcallback_mp3.bas
fbs_set_loadcallback_ogg.bas
fbs_set_mastercallback.bas
fbs_set_masterfilter.bas
fbs_set_mp3streamcallback.bas
fbs_set_mp3streamcallback2.bas
fbs_set_soundcallback.bas
fbs_set_soundspeed.bas
fbs_set_soundspeed2.bas
fbs_set_sound_paused_muted.bas
fbs_soundobject_3d_set_cone.bas
fbs_soundobject_3d_set_maxrange.bas
fbs_soundobject_3d_set_position.bas
fbs_with_gfx.bas
Last edited by D.J.Peters on May 02, 2018 20:01, edited 33 times in total.
chung
Posts: 547
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Postby chung » May 17, 2011 14:23

excellent project

i have enhanced the speed of FBS_Load_wavFile if you are interested

in fbsound.bas

(i load the whole file data in an array then use file[i] instead of get #hfile)

Code: Select all

function _LoadWave(byval Filename        as string, _
                   byval nRateTarget     as integer , _
                   byval nBitsTarget     as integer , _
                   byval nChannelsTarget as integer , _
                   byval lpnBytes        as integer ptr) as any ptr

  dim as _PCM_FILE_HDR hdr
  dim as integer   hFile,SeekPos,nBytesTarget,nSamples,nSamplesTarget,i,oPos,cPos
  dim as single    l,r
  dim as double    Scale,nPos
  dim as ubyte     v8
  dim as short     v16
  dim as short ptr p16
  dim as ubyte ptr file
  dim as integer filepos=0

  oPos=-1
  if GetWaveInfo(Filename,hdr,@SeekPos)=true then
    nSamples=hdr.Chunkdatasize \ hdr.Framesize
    Scale=hdr.nRate/nRateTarget
    nSamplesTarget=nSamples*(1.0/Scale)
    nBytesTarget=nSamplesTarget*(nBitsTarget\8)*nChannelsTarget
    hFile=Freefile()
    if open(FileName for binary access read as #hFile)=0 then
      seek #hFile,SeekPos
      p16=callocate(nBytesTarget)
      file=callocate(lof(hfile)-seekpos+1)
      if p16=NULL or file=NULL then
        close #hFile
      deallocate(p16)
      deallocate(file)
        return NULL
      end if
      get #hFile,,*file,(lof(hfile)-seekpos+1)
    

      if nSamples<=nSamplesTarget then
        for i=0 to nSamplesTarget-1
          ' jump over in source
          if oPos<>cPos then
            ' read samples l,r -0.5 - 0.5
            if hdr.nBits=8 then
              'read ubyte 0<->255
              'get #hFile,,v8
              v8=file[filepos]:filepos+=1
           ' convert to -128.0 <-> +127.0
              l=csng(v8):l-=128
              ' convert to -0.5 <-> +0.5
              l*=(0.5f/128.0f)
              if hdr.nChannels=2 then
                'get #hFile,,v8
                v8=file[filepos]:filepos+=1
                r=csng(v8):r-=128
                ' convert to -0.5 <-> +0.5
                r*=(0.5f/128.0f) 
              else
                r=l
              end if
            else
              'get #hFile,,v16
           v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
           l=(0.5f/32767.0f)*v16
              if hdr.nChannels=2 then
                'get #hFile,,v16
             v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
            r=(0.5f/32767.0f)*v16
              else
                r=l
              end if
            end if
            oPos=cPos
          end if
          ' write every in target
          if nChannelsTarget=1 then
            p16[i    ]=cshort(l*16383f + r*16383f)
          else
            p16[i*2  ]=cshort(l*32767.0f)
            p16[i*2+1]=cshort(r*32767.0f)
          end if
          nPos+=scale:cPos=int(nPos)
          ' don't read more than len(source)
          if cPos>=nSamples then exit for
        next
      else ' read every source Sample
        scale=(1.0/scale)
        for i=0 to nSamples-1
          ' read samples l,r -0.5 - +0.5
          if hdr.nBits=8 then
            'read ubyte 0<->255
            'get #hFile,,v8
            v8=file[filepos]:filepos+=1
            ' convert to -128.0 <-> +127.0
            l=csng(v8):l-=128
            ' convert to -0.5 <-> +0.5
            l*=(0.5f/128.0f)
            if hdr.nChannels=2 then
              'get #hFile,,v8
              v8=file[filepos]:filepos+=1
              r=csng(v8):r-=128
              ' convert to -0.5 <-> +0.5
              r*=(0.5f/128.0f) 
            else
              r=l
            end if
          else
            'get #hFile,,v16
         v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
         l=(0.5f/32767.0f)*v16
            if hdr.nChannels=2 then
              'get #hFile,,v16
           v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
           r=(0.5f/32767.0f)*v16
            else
              r=l
            end if
          end if
          ' jump over in destination
          if oPos<>cPos then
            if nChannelsTarget=1 then
              p16[cPos    ]=cshort(l*16383.5f + r*16383.5f)
            else
              p16[cPos*2  ]=cshort(l*32767.0f)
              p16[cPos*2+1]=cshort(r*32767.0f)
            end if
            oPos=cPos
          end if
          nPos+=scale:cPos=int(nPos)
          ' don't write more than len(target)
          if cPos>=(nSamplesTarget-1) then exit for
        next
      end if
      close #hFile
      *lpnBytes=nBytesTarget
     deallocate(file)
      return p16
    end if ' open=0
  end if ' GetWaveInfo<>0
  return NULL
end function


you can find a demo there => http://chungswebsite.blogspot.com/search/label/midipiano_chung
Last edited by chung on Jun 01, 2011 8:38, edited 1 time in total.
chung
Posts: 547
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Postby chung » May 28, 2011 18:20

i have added the -mt (multithreading) statement to the windows gui compile
options (fbc -s gui ) -> (fbc -s gui -mt )
to avoid compilation warning(21) from fbsoundwin , and random crashes ?


is it necessary to add the -mt option ? if yes , you should notice it in the doc
Last edited by chung on May 28, 2011 18:29, edited 1 time in total.
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Postby D.J.Peters » May 28, 2011 18:29

hello chung
this is only a warning
and means FB detected the use of threads
and will link your code with the thread safe runtime lib.

your random crashes are a problem in your code
or from your WINDOWS callback's
not from FBSound or FB.

sorry if i'm wrong

Joshy
chung
Posts: 547
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Postby chung » May 29, 2011 8:05

in fact,it doesnt crash, but there is a message "no response" in the title bar
while the music keeps playing, with an attempt to draw the screen one row larger than expected.
is it because i did "locate 0:cls" just after opening the window ?
i have replaced it by "cls:locate 1" as locate is 1 based,and hope it will solve

i am running windows 7 starter

i found a bug ... an array index out of bounds ...
chung
Posts: 547
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Postby chung » Jun 06, 2011 6:05

i have written a modified version of fbs_loadMP3file that uses memory instead of a temporary wav file, reducing disk usage , if you are interested in ...
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Postby D.J.Peters » Jun 06, 2011 16:24

hello chung
i won't change to mutch inside of FBSound
but you are wellcome to post new commands for the lib.
(if you like)

Joshy

e.g:
fbs_LoadMP3_to_MemoryWAV(MP3File as sting, pWave as any ptr ptr) as FBSBOOL
fbs_LoadOGG_to_MemoryWAV(OOGFile as sting, pWave as any ptr ptr) as FBSBOOL
fbs_LoadWAV_from_Memory(pMemWAVFile as any ptr, hWave as integer ptr) as FBSBOOL
fbs_LoadMP3_from_Memory(pMemMP3File as any ptr, pWave as any ptr ptr) as FBSBOOL
fbs_LoadOOG_from_Memory(pMemOGGFile as any ptr, pWave as any ptr ptr) as FBSBOOL
...
chung
Posts: 547
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Postby chung » Jun 06, 2011 20:47

here you are, if it can help...

Code: Select all

#include once "crt/string.bi" 'for memcpy


private _
function _LoadWave_short(byval Filepcm        as ubyte ptr, _
                   byval nRateTarget     as integer , _
                   byval nBitsTarget     as integer , _
                   byval nChannelsTarget as integer , _
                   byval lpnBytes        as integer ptr) as any ptr

  dim as _PCM_FILE_HDR hdr
  dim as integer   hFile,SeekPos,nBytesTarget,nSamples,nSamplesTarget,i,oPos,cPos
  dim as single    l,r
  dim as double    Scale,nPos
  dim as ubyte     v8
  dim as short     v16
  dim as short ptr p16
  dim as ubyte ptr file
  dim as integer filepos=0

  oPos=-1
  'if GetWaveInfo(Filename,hdr,@SeekPos)=true then
  memcpy(@hdr,filepcm+8,sizeof(_PCM_FILE_HDR))
    nSamples=hdr.Chunkdatasize \ hdr.Framesize
    Scale=hdr.nRate/nRateTarget
    nSamplesTarget=nSamples*(1.0/Scale)
    nBytesTarget=nSamplesTarget*(nBitsTarget\8)*nChannelsTarget
    'hFile=Freefile()
    'if open(FileName for binary access read as #hFile)=0 then
      'seek #hFile,SeekPos
      p16=callocate(nBytesTarget)
      'file=callocate(lof(hfile)-seekpos+1)
      if p16=NULL then 'or file=NULL then
        close #hFile
        deallocate(p16)
        'deallocate(file)
        return NULL
      end if
      'get #hFile,,*file,(lof(hfile)-seekpos+1)
      file=filepcm+8+sizeof(_PCM_FILE_HDR)

      if nSamples<=nSamplesTarget then
        for i=0 to nSamplesTarget-1
          ' jump over in source
          if oPos<>cPos then
            ' read samples l,r -0.5 - 0.5
            if hdr.nBits=8 then
              'read ubyte 0<->255
              'get #hFile,,v8
              v8=file[filepos]:filepos+=1
              ' convert to -128.0 <-> +127.0
              l=csng(v8):l-=128
              ' convert to -0.5 <-> +0.5
              l*=(0.5f/128.0f)
              if hdr.nChannels=2 then
                'get #hFile,,v8
                v8=file[filepos]:filepos+=1
                r=csng(v8):r-=128
                ' convert to -0.5 <-> +0.5
                r*=(0.5f/128.0f)
              else
                r=l
              end if
            else
              'get #hFile,,v16
              v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
              l=(0.5f/32767.0f)*v16
              if hdr.nChannels=2 then
                'get #hFile,,v16
                v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
                r=(0.5f/32767.0f)*v16
              else
                r=l
              end if
            end if
            oPos=cPos
          end if
          ' write every in target
          if nChannelsTarget=1 then
            p16[i    ]=cshort(l*16383f + r*16383f)
          else
            p16[i*2  ]=cshort(l*32767.0f)
            p16[i*2+1]=cshort(r*32767.0f)
          end if
          nPos+=scale:cPos=int(nPos)
          ' don't read more than len(source)
          if cPos>=nSamples then exit for
        next
      else ' read every source Sample
        scale=(1.0/scale)
        for i=0 to nSamples-1
          ' read samples l,r -0.5 - +0.5
          if hdr.nBits=8 then
            'read ubyte 0<->255
            'get #hFile,,v8
            v8=file[filepos]:filepos+=1
            ' convert to -128.0 <-> +127.0
            l=csng(v8):l-=128
            ' convert to -0.5 <-> +0.5
            l*=(0.5f/128.0f)
            if hdr.nChannels=2 then
              'get #hFile,,v8
              v8=file[filepos]:filepos+=1
              r=csng(v8):r-=128
              ' convert to -0.5 <-> +0.5
              r*=(0.5f/128.0f)
            else
              r=l
            end if
          else
            'get #hFile,,v16
            v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
            l=(0.5f/32767.0f)*v16
            if hdr.nChannels=2 then
              'get #hFile,,v16
              v16=cshort(file[filepos]+file[filepos+1]*256):filepos+=2
              r=(0.5f/32767.0f)*v16
            else
              r=l
            end if
          end if
          ' jump over in destination
          if oPos<>cPos then
            if nChannelsTarget=1 then
              p16[cPos    ]=cshort(l*16383.5f + r*16383.5f)
            else
              p16[cPos*2  ]=cshort(l*32767.0f)
              p16[cPos*2+1]=cshort(r*32767.0f)
            end if
            oPos=cPos
          end if
          nPos+=scale:cPos=int(nPos)
          ' don't write more than len(target)
          if cPos>=(nSamplesTarget-1) then exit for
        next
      end if
      close #hFile
      *lpnBytes=nBytesTarget
      'deallocate(file)
      return p16
    'end if ' open=0
  'end if ' GetWaveInfo<>0
  return NULL
end function


public _
function FBS_Load_WAVFile_short(byval Filepcm as ubyte ptr, _
                          byval hWave    as integer ptr) as fbsboolean export
  dim as any ptr _new
  dim as integer nBytes,flag,i
  if hWave  =NULL  then return false
  if _IsInit=false then *hWave=-1:return false

  _new=_LoadWave_short(Filepcm, _
                _Plugs(_Plug).Fmt.nRate    , _
                _Plugs(_Plug).Fmt.nBits    , _
                _Plugs(_Plug).Fmt.nChannels, _
                @nBytes)

  if _new=NULL then
    *hWave=-1
    return false
  end if
  ' new sound
  if _nWaves=0 then
    redim _Waves(_nWaves)
    _Waves(_nWaves).lpStart= _new
    _Waves(_nWaves).nBytes=nBytes
    *hWave=_nWaves
    _nWaves+=1
  else
    flag=-1
    for i=0 to _nWaves-1
      if _Waves(i).lpStart=NULL then flag=i:exit for
    next

    if flag>-1 then
      _Waves(flag).lpStart= _new
      _Waves(flag).nBytes=nBytes
      *hWave=flag
    else
      redim preserve _Waves(_nWaves)
      _Waves(_nWaves).lpStart= _new
      _Waves(_nWaves).nBytes=nBytes
      *hWave=_nWaves
      _nWaves+=1
    end if
  end if
   return true
end function



private _
function outputcallback_short cdecl (byval lpData   as any ptr             , _
                          byval lpHeader as mad_header PTR, _
                          byval lpPCM    as mad_pcm    PTR) as integer
  dim as MP3_BUFFER PTR buf=cptr(MP3_BUFFER PTR,lpData)
  dim as integer i
  dim as uinteger ptr houtindex=cast(uinteger ptr,buf->hOut)
  dim as uinteger iaux

  if lpPCM->channels>1 then
      _ScaleMP3FrameStereo(buf->lpFileBuf, _
                           @lpPCM->samples(0,0), _
                           @lpPCM->samples(1,0), _, _
                           lpPCM->length)
  else
    _ScaleMP3FrameMono(buf->lpFileBuf, _
                      @lpPCM->samples(0,0), _
                       lpPCM->length)
  end if

  ' first time write wave header
  if buf->wavehdr.ChunkDataSize=0 then
    buf->wavehdr.ChunkRIFF     = _RIFF
    buf->wavehdr.ChunkRIFFSize = sizeof(_PCM_FILE_HDR)-8
    buf->wavehdr.ChunkID       = _WAVE
    buf->wavehdr.Chunkfmt      = _fmt
    buf->wavehdr.ChunkfmtSize  = 16
    buf->wavehdr.wFormatTag    = 1
    buf->wavehdr.nChannels     = _Plugs(_Plug).fmt.nChannels
    buf->wavehdr.nRate         = lpPCM->samplerate
    buf->wavehdr.nBytesPerSec  = (_Plugs(_Plug).fmt.nBits\8)*lpPCM->samplerate*_Plugs(_Plug).fmt.nChannels
    buf->wavehdr.Framesize     = (_Plugs(_Plug).fmt.nBits\8)*_Plugs(_Plug).fmt.nChannels
    buf->wavehdr.nBits         =_Plugs(_Plug).fmt.nBits
    buf->wavehdr.Chunkdata     = _data
    'put #buf->hOut,,buf->wavehdr
    memcpy(cast(ubyte ptr,buf->hOut+8),@(buf->wavehdr),sizeof(buf->wavehdr))
    houtindex[0]=buf->hout+8+sizeof(buf->wavehdr)
  end if

  'buf->wavehdr.ChunkRIFFSize+=lpPCM->length*buf->wavehdr.Framesize
  'buf->wavehdr.ChunkdataSize+=lpPCM->length*buf->wavehdr.Framesize
  'put #buf->hOut,,buf->lpFileBuf[0],lpPCM->length*buf->wavehdr.Framesize
  iaux=lpPCM->length*buf->wavehdr.Framesize
  if (houtindex[0]+iaux)<houtindex[1] then
     memcpy(cast(ubyte ptr,houtindex[0]),@(buf->lpFileBuf[0]),iaux)
     houtindex[0]+=iaux
     buf->wavehdr.ChunkRIFFSize+=iaux
     buf->wavehdr.ChunkdataSize+=iaux
  else
     houtindex[0]=houtindex[1]
  endif
return MAD_FLOW_CONTINUE
end function


private _
function _DecodeMP3_short(byval lpStart   as any ptr, _
                byval Size      as integer, _
                byval hOut      as integer) as integer

  dim as MP3_BUFFER  buf
  dim as mad_decoder decoder
  dim as integer     result

  ' initialize our private message structure
  buf.Start    = lpStart
  buf.Size     = Size
  buf.hOut     = hOut
  buf.lpFileBuf=allocate(sizeof(short)*1152*2*4)

  ' configure input, output, and error _FUs
  mad_decoder_init(@decoder        , _
                   @buf            , _
                   @inputcallback  , _
                   0               , _ ' header
                   0               , _ ' filter
                   @outputcallback_short , _
                   @errorcallback  , _
                   0)                  ' message

  ' start decoding
  result = mad_decoder_run(@decoder, MAD_DECODER_MODE_SYNC)
  'seek buf.hOut,1
  'put #buf.hOut,,buf.wavehdr
  memcpy(cast(ubyte ptr,hout+8),@(buf.wavehdr),sizeof(buf.wavehdr))
  ' release the decoder
  mad_decoder_finish(@decoder)
  if buf.lpFileBuf<>NULL then deallocate buf.lpFileBuf
  return result
end function


public _
function FBS_Load_MP3File_short(byval Filename as string , _  'for files < 60s 16bits 44.1Khz (wav<12Mo)
                          byval lphWave  as integer ptr  , _
                          byval maxsize as integer=12000000, _
                          byval debug as integer=0) as fbsboolean export
  dim as ubyte ptr file
  dim as byte ptr lpMP3
  dim as integer hFile,hOut,size,ret
  dim as string  infile ',outtmp

  if lphWave=NULL then return false
  *lphWave=-1
  if _IsInit=false then return false

  infile=FileName

  hFile=Freefile
  if open(infile for binary access read as #hFile)<>0 then return false
  size=lof(hFile)
  if size = 0 then close #hfile:return false
  lpMP3 = callocate(size)
  if lpMP3 = NULL then close #hfile:return false

  get #hFile,,*lpMP3,size

  dim as uinteger maxfilesize=maxsize
  'if maxfilesize>(size*20) then maxfilesize=size*20
  if maxfilesize>100000000 then maxfilesize=100000000 'max 100M
  if maxfilesize<100000 then maxfilesize=100000       'min 100K
  file=callocate(maxfilesize)
  '?"mp3short alloc filepcm="+str(maxfilesize)+"  "+infile

  hOut=cast(uinteger,file)
  if file=NULL then
    if (lpMP3<>NULL) then  deallocate lpMP3:lpMP3=NULL
    return false
  end if
  dim as uinteger ptr houtindex=cast(uinteger ptr,hout)
  houtindex[0]=hout+8
  houtindex[1]=hout+maxfilesize

  ret=_DecodeMP3_short(lpMP3,size,hOut)
  'close #hOut
  close #hFile
  if (lpMP3<>NULL) then deallocate lpMP3:lpMP3=NULL
  if debug<>0 then ?"mp3short wav size="+str(houtindex[0]-hout)+"  "+infile
  if houtindex[0]>=houtindex[1] then ?"warning mp3 file truncated :"+infile

  if ret=0 then
    if FBS_Load_WAVFile_short(file,lphWave)=true then
       deallocate file:file=NULL
       return true
    else
      deallocate file:file=NULL
      *lphWave=-1
      return false
    end if
  else
    deallocate file:file=NULL
    *lphWave=-1
    return false
  end if
end function


DCrawshawJr
Posts: 71
Joined: Oct 24, 2009 13:45
Contact:

Any specific version of FB I need?

Postby DCrawshawJr » Jul 01, 2011 16:12

I just downloaded the latest version of FBSound, and when running rebuildlib.bat, it won't compile the source code. The error messages I got (other than the passing scalar as pointer) were:

src/fbsound.bas(1267) : error 9: Expected expression, found: 'error'

if ( MAD_RECOVERABLE(lpStream->error) ) then

src/plug-mm.bas(130) : error 1: Argument count mismatch, found: '_Me.WriteMutex'


CondWait(_Me.WriteCondition,_Me.WriteMutex)

The FB version I'm using is 0.4.6.
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Postby D.J.Peters » Jul 01, 2011 20:18

hello DC...
"The FB version I'm using is 0.4.6."

you talk about the version of the FBIDE and not FreeBASIC

how ever it must be something wrong with your current setup

can you post the output from the build script please ?

Joshy

here are my curent output from FBSound0.12.zip

Code: Select all

D:\>cd D:\fbsound\fbsound0.12

D:\fbsound\fbsound0.12>fbc -version
FreeBASIC Compiler - Version 0.22.0 (04-30-2011) for win32 (target:win32)
Copyright (C) 2004-2010 The FreeBASIC development team.
Configured as standalone
objinfo enabled using FB BFD header version 217

D:\fbsound\fbsound0.12>dir *.bat
09.10.2010  07:39             1 667 buildalltests.bat
23.03.2011  14:41               273 rebuildlib.bat

D:\fbsound\fbsound0.12>rebuildlib
"create cpu layer"
"create fbsound"
"create plug mm"
"ready!"
Drücken Sie eine beliebige Taste . . .
D:\fbsound\fbsound0.12>buildalltests
"please wait create all 35 tests ..."

D:\fbsound\fbsound0.12>del tests\*.exe
D:\fbsound\fbsound0.12\tests\*.exe konnte nicht gefunden werden
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test01.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test02.bas
D:\fbsound\fbsound0.12>fbc -s gui -mt  -p lib -i inc tests/test02_window.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test03.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test04.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test05.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test06.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test06_b.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test06_c.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test07.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test08.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test09.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test10.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test11.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test11_b.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test12.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test12_b.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test12_c.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test13.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test14.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test14_b.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test15.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test16.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test17.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test18.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test19.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test20.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test21.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test22.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test23.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test24.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test25.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test26.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test27.bas
D:\fbsound\fbsound0.12>fbc  -mt  -p lib -i inc tests/test28.bas

D:\fbsound\fbsound0.12>cd tests
D:\fbsound\fbsound0.12\tests>dir *.exe
01.07.2011  22:14           346 112 test01.exe
01.07.2011  22:14           345 088 test02.exe
01.07.2011  22:14           418 304 test02_window.exe
01.07.2011  22:14           347 136 test03.exe
01.07.2011  22:14           346 624 test04.exe
01.07.2011  22:14           346 624 test05.exe
01.07.2011  22:14           450 560 test06.exe
01.07.2011  22:14           450 560 test06_b.exe
01.07.2011  22:14           450 560 test06_c.exe
01.07.2011  22:14           420 864 test07.exe
01.07.2011  22:14           345 600 test08.exe
01.07.2011  22:14           422 912 test09.exe
01.07.2011  22:14           422 912 test10.exe
01.07.2011  22:14           421 376 test11.exe
01.07.2011  22:14           421 376 test11_b.exe
01.07.2011  22:14           347 136 test12.exe
01.07.2011  22:14           346 624 test12_b.exe
01.07.2011  22:14           347 136 test12_c.exe
01.07.2011  22:14           345 088 test13.exe
01.07.2011  22:14           345 088 test14.exe
01.07.2011  22:14           345 088 test14_b.exe
01.07.2011  22:14           421 376 test15.exe
01.07.2011  22:14           421 376 test16.exe
01.07.2011  22:14           421 888 test17.exe
01.07.2011  22:14           420 352 test18.exe
01.07.2011  22:14           345 600 test19.exe
01.07.2011  22:14           346 112 test20.exe
01.07.2011  22:14           429 056 test21.exe
01.07.2011  22:14           429 056 test22.exe
01.07.2011  22:14           430 080 test23.exe
01.07.2011  22:14           345 088 test24.exe
01.07.2011  22:14           346 112 test25.exe
01.07.2011  22:14           345 088 test26.exe
01.07.2011  22:14           345 600 test27.exe
01.07.2011  22:14           345 088 test28.exe
"ready!"

"have fun with FreeBASIC and FBSound"

Drücken Sie eine beliebige Taste . . .
DCrawshawJr
Posts: 71
Joined: Oct 24, 2009 13:45
Contact:

Postby DCrawshawJr » Jul 03, 2011 1:18

Yeah, my fault on the version.
It's 0.15 for the actual FB.

And here's the build script output:

Code: Select all

"create cpu layer"
"create fbsound"
src/fbsound.bas(654) : warning level 0: Suspicious pointer assignment
src/fbsound.bas(656) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(659) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(660) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(661) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(662) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(663) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(673) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(681) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(689) : warning level 0: Passing pointer to scalar, at parameter
1
src/fbsound.bas(1027) : warning level 0: Passing pointer to scalar, at parameter
 1
src/fbsound.bas(1267) : error 9: Expected expression, found: 'error'

  if ( MAD_RECOVERABLE(lpStream->error) ) then
                                       ^
"create plug mm"
src/plug-mm.bas(114) : warning level 0: Passing pointer to scalar, at parameter
1
src/plug-mm.bas(129) : warning level 0: Passing pointer to scalar, at parameter
1
src/plug-mm.bas(130) : warning level 0: Passing pointer to scalar, at parameter
1
src/plug-mm.bas(130) : error 1: Argument count mismatch, found: '_Me.WriteMutex'


          CondWait(_Me.WriteCondition,_Me.WriteMutex)
                                     ^
"ready!"
Press any key to continue . . .
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Postby D.J.Peters » Jul 03, 2011 2:31

please uptdate your old version of FreeBASIC and try again ;-)

http://www.freebasic.net/forum/viewtopic.php?t=17813

Joshy
rgwan
Posts: 41
Joined: Aug 19, 2011 17:41
Contact:

Postby rgwan » Sep 07, 2011 14:33

Cool!I can use this to my synthsizer!
rgwan
Posts: 41
Joined: Aug 19, 2011 17:41
Contact:

Postby rgwan » Oct 03, 2011 12:30

rgwan@rgwan-desktop:~/software/basic-program/KHS/fbsound0.12$ ./rebuildlib.sh
build cpu layer
build fbsound
build plug alsa
src/plug-alsa.bas(215) 错误 41: 变量未声明, alsa_pcm_drain_playback 在 'alsa_pcm_drain_playback _Me.hDevice'
build plug dsp
build plug arts
ready!

have fun with FreeBASIC and FBSound

rgwan@rgwan-desktop:~/software/basic-program/KHS/fbsound0.12$ chmod +x rebuildlib.sh
rgwan@rgwan-desktop:~/software/basic-program/KHS/fbsound0.12$ tests/test02error: fbs_Init() !


rgwan@rgwan-desktop:~/software/basic-program/KHS/fbsound0.12$
darkhog
Posts: 132
Joined: Oct 05, 2011 21:19

Postby darkhog » Oct 06, 2011 22:28

For nLoops parameter of fbs_play_Wave I suggest adding 0 value which will loop it indefinitely (until program exits).

//edit: And I have problem with compiling my game. Since I don't want to clutter FB's main include and lib directories, I've copied content of inc and lib directories to my game's folder. So it content looks now like:
fbs3d.bi fbsdsp.bi fbstypes.bi plug-alsa.bi plug.bi plug-mm.bi
fbscpu.bi fbsound.bi mad.bi plug-arts.bi plug-dsp.bi vorbisfile.bi
libfbscpulin.a libmadlin.a libplug-arts.so libvorbiswin.a
libfbscpuwin.a libmadwin.a libplug-dsp.so plug-mm.dll
libfbsoundlin.a liboggwin.a libplug-mm.dll.a
libfbsoundwin.a libplug-alsa.so libvorbisfilewin.a game.bas music.ogg

The source of game looks now:

Code: Select all

'Super Uber Game
'Copyryght (c) asdfghhjhgfds games

CONST copy = "asdfghghjjhfdssdsfdfgghjjhg" ' so copyright will be in exe too ;)

#include "fbgfx.bi"
Using FB
#include "fbpng.bi"
#include "fbsound.bi"
Open Cons For Output As #44
dim shared as any ptr logo
CONST SCRN_W = 640
CONST SCRN_H = 480
CONST CLRDEPTH = 32
CONST MAXFPS = 60


When compiling I getting this error:
/home/asdfghgfds/basic_projects/superubergame/fbscpu.bi(40) error 4: Duplicated definition in '_DS Copy (_B d _AAP,_B s _AAP , _B n as integer)'

//edit #2: Solved. It turned out that commenting out this line was enough to get it working. Somebody please remove line 40 from fbscpu.bi in future releases.

And feature request. Could you make so waves can be streamed from hard drive instead of loaded all at once into memory? This will certainly help make faster game's loading when you have lot of good quality music like almost uncompressed MP3s or OGGs (wavs are too big for music).

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest