Author Topic: BASS_FX 2.4.12.1  (Read 841629 times)

Alex

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #25 on: 23 Jan '04 - 00:11 »
Hi, i found the following DSP code for c from a link in this thread and i want to use it in delphi.
I know that there is a similar function in bass_fx20alpha but i want to try it

The C code was
Code: [Select]
Here's a simple dynamic amplification DSP...
#define amptarget 30000 // target level
#define ampquiet 800 // quiet level
#define amprate 0.02f // amp adjustment rate

typedef struct {
     float gain; // amplification level
     int delay; // delay before increasing level
     int count; // count of sequential samples below target level
     int high; // the highest in that period
     int quiet; // count of sequential samples below quiet level
} AUTOAMPSTUFF;

void CALLBACK autoamp(HDSP handle, DWORD channel, void *buffer, DWORD length, AUTOAMPSTUFF *amp)
{
     short *data=(short*)buffer;
     DWORD c;
     for (c=0;c<length/2;c++) {
           int s=(int)(data[c]*amp->gain); // amplify sample
           int sa=abs(s);
           if (abs(data[c])<ampquiet)
                 amp->quiet++; // sample is below quiet level
           else
                 amp->quiet=0;
           if (sa<amptarget) { // amplified level is below target
                 if (sa>amp->high) amp->high=sa;
                 amp->count++;
                 if (amp->count==amp->delay) { // been below target for a while
                       if (amp->quiet>amp->delay)
                             // it's quiet, go back towards normal level
                             amp->gain+=10*amprate*(1-amp->gain);
                       else
                             amp->gain+=amprate*amptarget/amp->high; // increase amp
                       amp->high=amp->count=0; // reset counts
                 }
           } else { // amplified level is above target
                 if (s<-32768) s=-32768;
                 else if (s>32767) s=32767;
                 amp->gain-=2*amprate*sa/amptarget; // decrease amp
                 amp->high=amp->count=0;
           }
           data[c]=(short)s; // replace original sample with amplified version
     }
}

...

AUTOAMPSTUFF amp;

amp.gain=1;
amp.delay=BASS_ChannelSeconds2Bytes(handle,1)/2;
amp.count=amp.high=amp.quiet=0;
BASS_ChannelSetDSP(handle,(DSPPROC*)&autoamp,&amp);


I managed to go this far because of some knowladge in PHP but i don't know what to use instead of data[c] to read the samples

Code: [Select]
type
  TAUTOAMPSTUFF = record
    gain: float; // amplification level
    delay: Integer; // delay before increasing level
    count: Integer; // count of sequential samples below target level
    high: Integer; // the highest in that period
    quiet: Integer; // count of sequential samples below quiet level
  end;
.....
implementation
var
 amp:TAUTOAMPSTUFF;

const
  amptarget = 30000; // target level
  ampquiet = 800; // quiet level
  amprate = 0.02; // amp adjustment rate


  procedure DynamicAmp(handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: DWORD); stdcall;
var
  c: DWORD;
  data: PSingle;
  S,sa: Integer;
begin
  data := buffer;
  c := 0;
  for c := 0 to (length div 2) do
  begin
    s := data[c] * (amp.gain)); // amplify sample
    sa := abs(s);
    if ((abs(data[c])) < (ampquiet)) then inc(amp.quiet) // sample is below quiet level
    else amp.quiet := 0;

    if (sa < amptarget) then // amplified level is below target
    begin
      if (sa > amp.high) then amp.high := sa;
      inc(amp.count);
      if (amp.count = amp.delay) then // been below target for a while
      begin
        if (amp.quiet > amp.delay) then // it's quiet, go back towards normal level
          amp.gain := amp.gain + (10 * amprate * (1 - amp.gain))
        else amp.gain := amp.gain + (amprate * amptarget / amp.High); // increase amp
        amp.high := 0; // reset counts
        amp.count := 0;
      end;
    end
    else // amplified level is above target
    begin
      if s > 32767 then s := 32767
      else if s > 32767 then s := 32767;
      amp.gain := amp.gain - (2 * amprate * sa / amptarget); // decrease amp
      amp.high := 0;
      amp.count := 0;
    end;
      data[c]=s; // replace original sample with amplified version
  end;

end;

Thank you
Alex

3delite

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #26 on: 14 Feb '04 - 21:48 »
Hi!

I was looking for a dsp equalizer for my app, when I came across BASS_FX and found out it's exactly what I needed!!! Please add support for 32bit floating point dsp data soon!!! When will the final be ready!???
You may want to check out, bass_fx will be a plugin for MP3 Stream Editor 1.3 hopefully in full 32bit fp! 8)
http://3delite.fly.to

Cheers!

3delite

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #27 on: 15 Feb '04 - 19:35 »
Working on the plugin, I wonder am I doing it right? ???
My code looks like, setup:

    BASS_ChannelGetAttributes(Stream.Channel, freq, vol, pan);
    for i := 0 to 8 do begin
        Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
        case i of
            0: Bands.fCenter := 100;
            1: Bands.fCenter := 250;
            2: Bands.fCenter := 500;
            3: Bands.fCenter := 1000;
            4: Bands.fCenter := 3000;
            5: Bands.fCenter := 5000;
            6: Bands.fCenter := 8000;
            7: Bands.fCenter := 11000;
            8: Bands.fCenter := 14000;
        end;
        Bands.lBand := i;
        Bands.fBandwidth := (FormConfig.TrackBarBandWith.Position / 10);
        Bands.FQ := 0;
        Bands.fGain := - FormConfig.Tag2Bar(i).Position;
        Bands.lFreq := freq;
        BASS_FX_DSP_SetParameters(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, @Bands);
    end;


And the params changing code:

        if FormConfig.NeedUpdate then begin
            FormConfig.NeedUpdate := False;
            for i := 0 to 8 do begin
                Band.lBand := i;
                BASS_FX_DSP_GetParameters(Channel, BASS_FX_DSPFX_PEAKEQ, @Band);
                Band.fGain := - FormConfig.Tag2Bar(i).Position;
                BASS_FX_DSP_SetParameters(Channel, BASS_FX_DSPFX_PEAKEQ, @Band);
            end;
        end;


When I change the lower freqs it doesn't seem to work. The higher freqs work ok.
Any ideas?


(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #28 on: 20 Feb '04 - 20:33 »
Hi ;D

* Sorry, but the 32-bit version of BASS_FX is not ready yet.

Have fun!

8) JOBnik! 8)
« Last Edit: 20 Feb '04 - 20:36 by (: JOBnik! :) »

3delite

  • Posts: 935
Re:BASS_FX 2.0 "alpha"
« Reply #29 on: 23 Feb '04 - 05:24 »
 
Tryed to follow the example code logic like this:

Code: [Select]
   BASS_ChannelGetAttributes(Stream.Channel, freq, vol, pan);

    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
    Result := BASS_FX_DSP_Set(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, DSPPriority);
   
    for i := 0 to 8 do begin
        case i of
            0: Bands.fCenter := 100;
            1: Bands.fCenter := 250;
            2: Bands.fCenter := 500;
            3: Bands.fCenter := 1000;
            4: Bands.fCenter := 3000;
            5: Bands.fCenter := 5000;
            6: Bands.fCenter := 8000;
            7: Bands.fCenter := 11000;
            8: Bands.fCenter := 14000;
        end;
        Bands.lBand := i;
        Bands.fBandwidth := (FormConfig.TrackBarBandWith.Position / 10);
        Bands.FQ := 0;
        Bands.fGain := - FormConfig.Tag2Bar(i).Position;
        Bands.lFreq := freq;
        BASS_FX_DSP_SetParameters(Stream.Channel, BASS_FX_DSPFX_PEAKEQ, @Bands);
    end;

And it's working! I think...  :-\
Well anyway full source code for all the plugins is here: http://web.axelero.hu/csanadim/MP3SE/download/mp3se_plugin_sdk.zip
Docs (under construction): http://web.axelero.hu/csanadim/MP3SE/developer.html
Can't wait for the final!!! :-*
 


3delite

  • Posts: 935
Re:BASS_FX 2.0 "alpha"
« Reply #30 on: 21 Mar '04 - 16:29 »
Quote
* VERSION 2.0 (not "alpha") will support:
  * 32-bit floating-point including in: DSP, Tempo, BPM & Reverse.
  * Multi Channel in some DSPs.
  * Planning to release till the end of this month/year :)

 ::)

(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #31 on: 21 Mar '04 - 19:26 »
Hi ;D

Sooooooooooo.... SORRY  :-[

I just don't have so much time lately, I got a new job and all the time
I'm just working... and working... and... ;)

* It will be updated ;)

Have fun!

8) JOBnik! 8)

3delite

  • Posts: 935
Re:BASS_FX 2.0 "alpha"
« Reply #32 on: 10 Apr '04 - 19:54 »
mmmokay...  ::)

One more question, I have here. Does it work undex win98?
I am having some problems, when loading the plugins, which use bass_fx.dll, LoadLibrary() fails...  ???
No problems on XP.

(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #33 on: 11 Apr '04 - 16:57 »
Hi ;D

One more question, I have here. Does it work undex win98?
I am having some problems, when loading the plugins, which use bass_fx.dll, LoadLibrary() fails...  ???
No problems on XP.

I've tested BASS_FX with WinME and it's works perfectly :)

* Please write some more info about errors that you get.

Have fun!

8) JOBnik! 8)

3delite

  • Posts: 935
Re:BASS_FX 2.0 "alpha"
« Reply #34 on: 13 Apr '04 - 02:54 »
I'm afraid I can't tell you much more. I write the plugins in Delphi, simple DLLs, and then load them with SafeLoadLibrary(). It works perfectly on XP, but on my Win98, for some strange reason SafeLoadLibrary() or LoadLibrary() (tryed both) returns 0 handle, but only for those plugins which use bass_fx.dll.  :( Other plugins, like bass_wa.dll user, load ok on both systems. Tryed to copy bass_fx.dll to the plugins folder, which doesn't make much sense since the other plugins don't need this, but that wouldn't help either. Ian pointed out this bug, I'm only running on XP here...
None of my code runs, as the plugin won't even load, so I really don't have any more ideas...  ???

(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #35 on: 18 Apr '04 - 10:49 »
Hi ;D

I've checked your software with WinXP and WinME and it works perfectly with BASS_FX ;)

Have fun!

8) JOBnik! 8)

3delite

  • Posts: 935
Re:BASS_FX 2.0 "alpha"
« Reply #36 on: 18 Apr '04 - 16:28 »
 8)

Must be that Win98/Win98SE difference...  ???
I'll test it on SE, for sure!  :)

Chief Sunet

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #37 on: 19 Apr '04 - 20:34 »
My app needs an "A/B" function, where the user clicks a button when he hears where he wants to start a loop. He then clicks the button again where he wants the loop to end.

The function BASS_FX_TempoGetApproxSeconds returns an approximation of the position being heard after applying a tempo change. That and  an approximation of the new length using the same function would be enough to calculate where in the original file the user's loop starts so that I can loop what the user wants looped.

The problem is that although BASS_FX_TempoGetApproxSeconds returns a Float. It's only accurate out to the second. That's just not good enough for a loop.

Is it possible that you could get BASS_FX_TempoGetApproxSeconds to return a position approximation that is accurate at least out to the hundredth place in the next version?

Do you know of an option other than BASS_FX_TempoGetApproxSeconds?


(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #38 on: 24 Apr '04 - 21:14 »
Hi ;D

I'm checking it out :)

Meanwhile I'm about to add a new Example to BASS_FX "package" showing how to
make it able to use Sync and BASS_FX's Tempo ;)

Have fun!

8) JOBnik! 8)

MindWorkSoft

  • Posts: 13
Re:BASS_FX 2.0 "alpha"
« Reply #39 on: 26 Apr '04 - 01:05 »
Hi JOBnik,

I am now reprogramming again my Whoosh Mp3 to make compatible with your latest version of BASS_FX and BASS.

The latest vesion is so nice specially the BPM/Tempo, I wish you can add another function that I really need and that is the Real time Beat Tap, so that aside from Auto BPM detection, user can also define thier BPM value for the song, or I you could share a little code for Beat Tap.

Thanks
Dards

Chief Sunset

  • Posts: 6
Re:BASS_FX 2.0 "alpha"
« Reply #40 on: 4 May '04 - 15:19 »
Hi ;D

I'm checking it out :)

Meanwhile I'm about to add a new Example to BASS_FX "package" showing how to
make it able to use Sync and BASS_FX's Tempo ;)

Have fun!

8) JOBnik! 8)


Did you already add the example?  ::)

(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #41 on: 7 May '04 - 17:24 »
Hi ;D

Nope, coz Delphi example isn't ready yet :)

Have fun!

8) JOBnik! 8)

marjolein

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #42 on: 24 May '04 - 16:28 »
Hi ;D

BASS_FX 2.0 "alpha" is here!

* "alpha" - Because it's just compatible with BASS 2.0!
* The not "alpha" will support:
32-bit floating-point  in all DSPs and multi channel  in some DSPs :)

Have fun!

8) JOBnik! 8)

martin verlaan

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #43 on: 14 Jun '04 - 13:15 »
Does the functions below work correct in Visual Basic?

 BASS_FX_BPM_Frequency2BPM
 BASS_FX_BPM_2Frequency

Because each time when I call them, I get -1 (=error) as value  ??? :'(

Also I'm looking for some documentation (helpfile) of BASS_FX. Is this available somewhere?

Greetings,

Martin

(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #44 on: 15 Jun '04 - 20:00 »
Hi ;D

Quote
Does the functions below work correct in Visual Basic?

 BASS_FX_BPM_Frequency2BPM
 BASS_FX_BPM_2Frequency

Because each time when I call them, I get -1 (=error) as value  ??? :'(

* Yep, these functions are working perfectly with all the APIs, please post some code of yours to check where the error could come from :)

* Please check the error code that returned by BASS_FX_ErrorGetCode for more info about the error. (i.e. write this function right after BASS_FX_BPM_Frequency2BPM or any other function that return an error value)

Quote
Also I'm looking for some documentation (helpfile) of BASS_FX. Is this available somewhere?

* In all APIs header file [BASS_FX.H/PAS/BAS] there's an explanations about all the parameters and functions that in BASS_FX :)

* There's currently no any .CHM or .PDF documentation.

Have fun!

8) JOBnik! 8)
« Last Edit: 15 Jun '04 - 22:35 by (: JOBnik! :) »

Martin

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #45 on: 18 Jun '04 - 14:30 »
Thanks a lot for your reply Jobnik. I will check the errorcode to find out what's going wrong.

In the meantime a have one more question, if you don't mind  :-[

I have a problem and I tried to find the solution on this great messageboard, but I can't exactly find it.

I'm witing a Visual Basic program that can mix 2 mp3s together at the same bpm.
Everything works fine, except the most important thing.

Example:

Song 1 is playing
Song 2 must start playing at 0'30"234 (because the first beat start here) as soon the position of song 1 is 4'35"010

Sometimes this work perfect and sometimes it don't:
Song 2 starts up with a little delay or it starts at the wrong time-position. I tried to do this with a timer and also with this:

Call BASS_ChannelSetSync(BASS_FX_TempoGetResampledHandle(chan), BASS_SYNC_POS Or BASS_SYNC_MIXTIME, BASS_ChannelSeconds2Bytes(chan, Time2Sec(Break(nr))), AddressOf SYNCPROC, Player)

But it just don't work everytime. What I am I doing wrong? Is there a way to solve this?

Here is how I created the streams:

chan = BASS_StreamCreateFile(BASSFALSE, Filename1, 0, 0, BASS_MP3_SETPOS Or BASS_STREAM_DECODE)

chan1 = BASS_StreamCreateFile(BASSFALSE, Filename2, 0, 0, BASS_MP3_SETPOS Or BASS_STREAM_DECODE)

I also tried to solve this problem with a function that synchronizes the songs by changing the position of song 2. I call the BASS_ChannelSetPosition to do this, but again, sometimes it works and sometimes there's a delay :-(((( It drives me crazy!! I just want to mix 2 songs at a customized time. It most be possible, isn't it??

PLEASE HELP!!!

Thanks in advance!  ;D


Martin


martin

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #46 on: 21 Jun '04 - 09:11 »
 :'(

(: JOBnik! :)

  • Posts: 1080
Re:BASS_FX 2.0 "alpha"
« Reply #47 on: 21 Jun '04 - 16:56 »
Hi ;D

The problem is, that you can't use SYNC with Tempo. I've already made an example that shows how to use SYNC with Tempo, but didn't yet include it with BASS_FX "package" :)

* I'll send you a VB example today a bit later :)

Have fun!

8) JOBnik! 8)

Chris

  • Posts: 2217
Re:BASS_FX 2.0 "alpha"
« Reply #48 on: 21 Jun '04 - 20:30 »
Hi
A (Pos) Syncs (BASS_SYNC_POS, BASS_SYNC_END) its better to use the orginal Decoded_Stream
 (Attribute)Syncs (Vol,Freq,vol,pan) will working with BASS_FX_TempoGetResampledHandle fine
Greets Chris

martin

  • Guest
Re:BASS_FX 2.0 "alpha"
« Reply #49 on: 21 Jun '04 - 22:54 »
Hi Chris and Jobnik!

You guys brought me to the solution. I'm so happy now  ;D ;D ;D

I deleted BASS_STREAM_DECODE from BASS_StreamCreateFile
and I deleted BASS_FX_TempoGetResampledHandle from BASS_ChannelSetSync.
It seems it works perfect now!

I also opened another stream with the stream_decode-flag to calculate the bpm.
Everything works fine now...thank you so much both of you.

Martin