Author Topic: Use bassFx.TempoCreate in C#  (Read 2126 times)

yaniv51

  • Guest
Use bassFx.TempoCreate in C#
« on: 10 Aug '15 - 15:20 »
Hi.
I'm try to use Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_TempoCreate
for set channel attribute (for changing speed) but I get exceptoin:
"Unable to load DLL 'bass_fx.dll': The specified module could not be found."
The Bass.Net.dll and bass.dll are in the debug folder.

I'm using version 2.4.10.3.

Where can I find bass_fx.dll for C# or do I need to do somthing to load this .dll?

Thanks alot.


radio42

  • Posts: 4636
Re: Use bassFx.TempoCreate in C#
« Reply #1 on: 10 Aug '15 - 15:36 »
You can find the native bss_fx.dll as well as all other add-ons here on this page....take a look to the top right menu... "add-ons"

Just place the the native bss_fx.dll to the same Location as the bass.dll (your executable directory).
The very first call to any BASS_FX method from within Bass.Net will load it.
E.g. use "BassFx.BASS_FX_GetVersion()"

yaniv51

  • Guest
Re: Use bassFx.TempoCreate in C#
« Reply #2 on: 10 Aug '15 - 15:47 »
Hi, thanks for the fast replay.
Did you mean to download bass_fx from here:
http://www.un4seen.com/#addons
?

If yes, I tried to download:
http://uk.un4seen.com/files/z/0/bass_fx24.zip

but I get error when I try to add reference to VS( 2010 ).
Or should I put bass_fx.dll in debug folder?

yaniv51

  • Guest
Re: Use bassFx.TempoCreate in C#
« Reply #3 on: 10 Aug '15 - 17:22 »
Ok,
I put bass_fx.dll in debug folder and now there is no error.
GET_VER method works and I get a real number.

But, when I try to set up new rate for play, there is no change.

int stream = BassFx.BASS_FX_TempoCreate(_streamHandle, BASSFlag.BASS_FX_FREESOURCE);
            float newRate = ((float)rate)/1000;
            Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, newRate);

The rate is between 0.1 to 1.
The tempo_Create method return 0 ( and streamHandle is fine).
What is wrong?

Thank alot,
Yaniv.

Chris

  • Posts: 1860
Re: Use bassFx.TempoCreate in C#
« Reply #4 on: 10 Aug '15 - 20:30 »
hi
your _streamHandle must create with the BASS_STREAM_DECODE flag.

yaniv51

  • Guest
Re: Use bassFx.TempoCreate in C#
« Reply #5 on: 11 Aug '15 - 07:24 »
Hi.
Now I get good result from TEMPO_CREATE but there is no sound.

streamhandle create:
_streamHandle = Bass.BASS_StreamCreateFile(_hGCFile.AddrOfPinnedObject(), 0, (long)size, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE);

yaniv51

  • Guest
Re: Use bassFx.TempoCreate in C#
« Reply #6 on: 11 Aug '15 - 08:09 »
I can not edit,
So I found that I should use the stream from TEMPO_CREATE and now everything is work fine - but I cannot change the rate(for any rate is stay the same).

First I'm changing the rate and after play sound.

info for streamHandle:
flags = BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE

for tempoStream:
flags = BASS_SAMPLE_SOFTWARE | BASS_SAMPLE_FLOAT | BASS_SAMPLE_OVER_VOL

Chris

  • Posts: 1860
Re: Use bassFx.TempoCreate in C#
« Reply #7 on: 11 Aug '15 - 19:37 »
This are the working and alowed flags in a tempostream

 you are setting doubled the flags why ?
by the way BASS_SAMPLE_OVER_VOL is a flag for Bass_Sample and not for a stream.

so the right syntax must be

int _streamHandle = Bass.BASS_StreamCreateFile(_hGCFile.AddrOfPinnedObject(), 0, (long)size, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE);
int stream = BassFx.BASS_FX_TempoCreate(_streamHandle, BASSFlag.BASS_FX_FREESOURCE);
Bass_ChannelPlay(stream);

The Float Attributes can you set on any time while the stream is playing.

yaniv51

  • Guest
Re: Use bassFx.TempoCreate in C#
« Reply #8 on: 12 Aug '15 - 08:05 »
Hi, thanks for the answer.

My syntax is the same for what you suggest.
When I'm using:
 Bass.BASS_ChannelSetAttribute(_streamHandle, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, newRate);

the return value is false, so it is clear why changing rate is not working for me.
Before change the rate, I tried to do it when the channel is playing/stopped and for both cases there is no change.

The code is:

Code: [Select]
_streamHandle = Bass.BASS_StreamCreateFile(_hGCFile.AddrOfPinnedObject(), 0, (long)size, BASSFlag.BASS_SAMPLE_FLOAT|BASSFlag.BASS_STREAM_DECODE);

_tempoStream = BassFx.BASS_FX_TempoCreate(_streamHandle, BASSFlag.BASS_FX_FREESOURCE);

Bass.BASS_ChannelPlay(_tempoStream, false);

Bass.BASS_ChannelSetAttribute(_streamHandle, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, 0.2f);

Thanks again, Yaniv.

yaniv51

  • Guest
Re: Use bassFx.TempoCreate in C#
« Reply #9 on: 12 Aug '15 - 08:09 »
I dont know how to edit, but the line:
Bass.BASS_ChannelSetAttribute(_streamHandle, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, 0.2f);

is not good, the good one:
Bass.BASS_ChannelSetAttribute(_tempoStream, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, 0.2f);

( anyway for both, chage rate is not working)

Chris

  • Posts: 1860
Re: Use bassFx.TempoCreate in C#
« Reply #10 on: 12 Aug '15 - 08:31 »
Hi no
the right Syntax must be

Code: [Select]
_streamHandle = Bass.BASS_StreamCreateFile(_hGCFile.AddrOfPinnedObject(), 0, (long)size, BASSFlag.BASS_SAMPLE_FLOAT|BASSFlag.BASS_STREAM_DECODE);

_tempoStream = BassFx.BASS_FX_TempoCreate(_streamHandle, BASSFlag.BASS_FX_FREESOURCE);

Bass.BASS_ChannelPlay(_tempoStream, false);

Bass.BASS_ChannelSetAttribute(_tempostream, BASSAttribute.BASS_ATTRIB_TEMPO, 8.0f);
// will speedup a song to + 8%

BASS_ATTRIB_TEMPO [-95%..0..+5000%] percents // also named as TimeStretch
BASS_ATTRIB_TEMPO_PITCH  [-60....0....+60] semitones // also named as PitchShift
BASS_ATTRIB_TEMPO_FREQ  Samplerate in Hz (must be within 5% to 5000% of the original sample rate)

 if i right understand do you want to CHANGE the tempo/timestretch



« Last Edit: 12 Aug '15 - 08:38 by Chris »

yaniv51

  • Posts: 4
Re: Use bassFx.TempoCreate in C#
« Reply #11 on: 12 Aug '15 - 11:41 »
Hi,
I want to speed up / slow down the song.

I tried to use your syntax(difference only with the precent), and stell get false from method(and no change).

This is exactly like the example:
http://bass.radio42.com/help/html/90d034c4-b426-7f7c-4f32-28210a5e6bfb.htm

 ??? ??? ???


Chris

  • Posts: 1860
Re: Use bassFx.TempoCreate in C#
« Reply #12 on: 12 Aug '15 - 21:43 »
just place after every call a Bass_ErrorGetCode call to catch the error
something like
if  BASS_ErrorGetCode() > 0
  {
    Your  Errorhandling .....
  }

radio42

  • Posts: 4636
Re: Use bassFx.TempoCreate in C#
« Reply #13 on: 12 Aug '15 - 22:23 »
Quote
I'm using version 2.4.10.3.
Have you tried using the latest Bass.Net verison, which is 2.4.11.x ?!
Because else you must also use the old bass_fx.dll !

As far as I remember the BASS_FX Attributes have been added to bass v2.4.11.x
As such the documentaion (you are referring to) uses the most recent Version as well...

In v2.4.10, there had been extra BASS_FX functions to change the tempo...see the older docs for detail.

Could that be your issue?

yaniv51

  • Posts: 4
Re: Use bassFx.TempoCreate in C#
« Reply #14 on: 13 Aug '15 - 12:34 »
Fitst, thank you all for you replays.

I tried to update to lates version.
Bass.Net: 2.4.11.1
bass_fx: 2.4.11.1
bass.dll: 2.4.11.0

I get BASS_ILLPARAM, so I changed
BASS_ATTRIB_TEMPO_FREQ
to
BASS_ATTRIB_TEMPO

And now I don't have any error, but still the sound is not faster/slower.

When I try to change rate with BASS_ATTRIB_TEMPO_FREQ and negetive number, there is no error but without change.
(The oposite from what describe here: http://bass.radio42.com/help/html/90d034c4-b426-7f7c-4f32-28210a5e6bfb.htm)

should I update more files?
( bassmix, bassenc )

___


It looks like it is working now.

Bass.BASS_ChannelSetAttribute(_tempoStream, BASSAttribute.BASS_ATTRIB_TEMPO, newRate)

Thank you all for your support.
« Last Edit: 13 Aug '15 - 14:38 by yaniv51 »

NewUser

  • Posts: 2
Re: Use bassFx.TempoCreate in C#
« Reply #15 on: 6 Jul '18 - 06:55 »
Hi everybody!

Chris, What am I doing wrong?

First I open the file to make the conversion BASS_FX

Code: [Select]
int file_stream = Bass.BASS_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_STREAM_DECODE);

int tempo_stream = BassFx.BASS_FX_TempoCreate(file_stream, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_MUSIC_FX);

Bass.BASS_ChannelSetAttribute(tempo_stream, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, 5f);

After that I want to save the result to a file.

Save to the file is obtained only if you play the stream (BASS_ChannelPlay).

Code: [Select]
short[] data = new short[32768];
using (WaveWriter WW = new WaveWriter(newFilename, tempo_stream, true))
{
 Bass.BASS_ChannelPlay(tempo_stream, true);
 while (Bass.BASS_ChannelIsActive(tempo_stream) == BASSActive.BASS_ACTIVE_PLAYING)
 {
  int length = Bass.BASS_ChannelGetData(tempo_stream, data, data.Length);
  if (length > 0)
   WW.Write(data, length);
 }
}

In the file many times plays "tempo_stream"

I need to do this without BASS_ChannelPlay. Is this possible?

Chris

  • Posts: 1860
Re: Use bassFx.TempoCreate in C#
« Reply #16 on: 6 Jul '18 - 14:51 »
Hi ,
BASS_MUSIC_FX is a wrong Flag. this flag is for mod/mo3 Music/Samples and not for Streams.

I am not the Big C# Coder (coming from the Delphi World)  but i think should be something like this

Code: [Select]
int file_stream = Bass.BASS_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_STREAM_DECODE);

int tempo_stream = BassFx.BASS_FX_TempoCreate(file_stream, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_DECODE);

Bass.BASS_ChannelSetAttribute(tempo_stream, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, 5f);

Code: [Select]
short[] data = new short[32768];
using (WaveWriter WW = new WaveWriter(newFilename, tempo_stream, true))
{
 while (Bass.BASS_ChannelIsActive(tempo_stream) > 0)
 {
  int length = Bass.BASS_ChannelGetData(tempo_stream, data, data.Length);
  if (length > 0)
   WW.Write(data, length);
 }
}



NewUser

  • Posts: 2
Re: Use bassFx.TempoCreate in C#
« Reply #17 on: 28 Sep '18 - 06:19 »
Thanks Chris.