Ver #2 :Simple sound Player using BASS [Stereo & Mono Files]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4635
Joined: Sun Apr 12, 2009 6:27 am

Re: Ver #2 :Simple sound Player using BASS [Stereo & Mono Fi

Post by RASHAD »

Yes you are right
Just change wavex = 1 to wavex = 2
A lot of work needed with FFT
But remember I am not a multimedia fan. Only GUI player :P
Egypt my love
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Ver #2 :Simple sound Player using BASS [Stereo & Mono Fi

Post by infratec »

Hi,

this looks more real (quick hack)

Code: Select all

Procedure UpdateWaveImage(PBImage, *SampleData.Sample, SampleCount)
  
  Protected LastL, CurrentL, LastR, CurrentR
  
  If *SampleData And SampleCount
    StartDrawing(ImageOutput(PBImage))
    Width = OutputWidth() : Height = OutputHeight()
    If chans = 1
      VOffsetL = Height >> 1
    Else
      VOffsetL = Height >> 2 : VOffsetR = VOffsetL + Height >> 1
    EndIf   
    Mul = (VOffsetL * $19999) >> wavey
    If chans = 1
      Mul = (VOffsetL * $19999) >> wavey
    EndIf
    Box(0, 0, Width, Height, $0000FF)   
    Line(0, VOffsetL, Width, 1, wavecolor)
    If chans = 2
      Line(0, VOffsetR, Width, 1, wavecolor)
    EndIf
    SamplesPerPixel = (SampleCount + Width - 1) / Width
    MinL = $7fff : MaxL = $8000 : MinR = $7fff : MaxR = $8000
    MinL_ = $8000 : MaxL_ = $7fff : MinR_ = $8000 : MaxR_ = $7fff
    x = - 2
    While SampleCount
      If *SampleData\l < MinL
        MinL = *SampleData\l
        CurrentL = MinL
      ElseIf *SampleData\l > MaxL
        MaxL = *SampleData\l
        CurrentL = MaxL
      EndIf
      If chans = 2
        If *SampleData\r < MinR
          MinR = *SampleData\r
          CurrentR = MinR
        ElseIf *SampleData\r > MaxR
          MaxR = *SampleData\r
          CurrentR = MaxR
        EndIf
      EndIf
      *SampleData + 4
      Sample + 1 : SampleCount - 1
      If Sample = SamplesPerPixel Or SampleCount = 0
        MinL = (MinL * Mul) >> 16 : MaxL = (MaxL * Mul) >> 16
        ;LineXY(X, VOffsetL - MinL, X, VOffsetL - MaxL, wavecolor)
        
        CurrentL = (CurrentL * Mul) >> 16
        LineXY(X, VOffsetL - LastL, X, VOffsetL - CurrentL, wavecolor)
        LastL = CurrentL
        
        If chans = 2
          MinR = (MinR * Mul) >> 16 : MaxR = (MaxR * Mul) >> 16
          ;LineXY(X, VOffsetR - MinR, X, VOffsetR - MaxR, wavecolor)
          
          CurrentR = (CurrentR * Mul) >> 16
          LineXY(X, VOffsetR - LastR, X, VOffsetR - CurrentR, wavecolor)
          LastR = CurrentR
          
        EndIf
        X + wavex : Sample = 0
      EndIf
    Wend
    StopDrawing()
  EndIf
EndProcedure
More like AudaCity :mrgreen:

Bernd
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4635
Joined: Sun Apr 12, 2009 6:27 am

Re: Ver #2 :Simple sound Player using BASS [Stereo & Mono Fi

Post by RASHAD »

No way :P
Previous post updated to treat wav mono files
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4635
Joined: Sun Apr 12, 2009 6:27 am

Re: Ver #2 :Simple sound Player using BASS [Stereo & Mono Fi

Post by RASHAD »

Previous post updated
Added new feature
Improved FFT implementation by CELTIC88
Speed optimized (For now :) )
Egypt my love
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Ver #2 :Simple sound Player using BASS [Stereo & Mono Fi

Post by chris319 »

Where to find

bassflac.dll
bass_ac3.dll
basswma.dll

They are not in bass24.

13 POLINK errors.

FAIL.
ozzie
Enthusiast
Enthusiast
Posts: 429
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: Ver #2 :Simple sound Player using BASS [Stereo & Mono Fi

Post by ozzie »

chris319 wrote:Where to find

bassflac.dll
bass_ac3.dll
basswma.dll
https://www.un4seen.com/bass.html#addons
Post Reply