Author Topic: My MP3 plays but the EFFECTS do not take. I hear the MP3 but not the effects.  (Read 1894 times)

afsanchez001

  • Posts: 108
Help!

I have an MP3 file that plays fine, but none of the effects (echo, reverb, tempo-change, rate-change, pitch-change) take effect.  

To make things more confusing, my ERROR REPORT shows no errors, all the effects report as BASS_OK.  

NOTE: the `audioFile` variable is the MP3 file, which I can hear by the way.  The MP3 plays fine, just no effects are taking hold.

Here is my CODE:

//SETUP
Code: [Select]
Bass.BASS_SetDevice(2);
streamA = Bass.BASS_StreamCreateFile(audioFile, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_DEFAULT);

//REVERSE PLAY
Code: [Select]
streamFx = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_FX_FREESOURCE);
Bass.BASS_ChannelSetAttribute(streamFx, BASSAttribute.BASS_ATTRIB_REVERSE_DIR, (float) BASSFXReverse.BASS_FX_RVS_REVERSE);

//ECHO EFFECT
Code: [Select]
BASS_DX8_ECHO echo = new BASS_DX8_ECHO();
fxEchoHandle = Bass.BASS_ChannelSetFX(streamA, BASSFXType.BASS_FX_BFX_ECHO4, 1);
echo.Preset_Long();
Bass.BASS_FXSetParameters(fxEchoHandle, echo);

//REVERB EFFECT
Code: [Select]
BASS_DX8_REVERB reverb = new BASS_DX8_REVERB();
fxReverbHandle = Bass.BASS_ChannelSetFX(streamA, BASSFXType.BASS_FX_DX8_REVERB, 1);
reverb.Preset_Default();
Bass.BASS_FXSetParameters(fxReverbHandle, reverb);

//PITCH, TEMPO, RATE
Code: [Select]
Bass.BASS_ChannelSetAttribute(tempoStream, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, pitch);
Bass.BASS_ChannelSetAttribute(tempoStream, BASSAttribute.BASS_ATTRIB_TEMPO, tempo);
Bass.BASS_ChannelSetAttribute(tempoStream, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, rate);

`pitch, tempo, rate` vars above are incoming float values

//THE LAST PIECE
Code: [Select]
Bass.BASS_ChannelPlay(streamA, false);
Bass.BASS_ChannelSetAttribute(streamA, BASSAttribute.BASS_ATTRIB_VOL, 0.7f);



MY ERROR REPORT:
(It shows everything is okay, and the MP3 file plays but I do nto hear any changes.  None of the effects seem to take.)


BASS_ATTRIB_REVERSE_DIR,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_FX_BFX_ECHO4,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_ATTRIB_TEMPO_PITCH,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_ATTRIB_TEMPO,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_ATTRIB_TEMPO_FREQ,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK


Please help.  Any ideas of what I am doing wrong?  :)

Ian @ un4seen

  • Administrator
  • Posts: 23470
The reverse and tempo effects require the source to be a decoding channel, as they decode data from it. That means using the BASS_STREAM_DECODE flag. It could look something like this:

Code: [Select]
streamA = Bass.BASS_StreamCreateFile(audioFile, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE); // create a decoding channel for the audio file
streamRev = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_DECODE); // create a reverse stream (also a decoding channel) on that
streamTempo = BassFx.BASS_FX_TempoCreate(streamRev, BASSFlag.BASS_FX_FREESOURCE); // create a tempo stream on that
// the above means that the data path is: file -> reverse processing -> tempo processing
...
Bass.BASS_ChannelPlay(streamTempo, false); // start playing the tempo stream

I would also recommend setting the ECHO/REVERB effects (and any other DSP/FX) on the final stream, ie. the stream in the BASS_ChannelPlay call, which is "streamTempo" in this case.

afsanchez001

  • Posts: 108
Thank you for your help Ian.  I will try this.  :)

afsanchez001

  • Posts: 108
Hi Ian,

When I use BASS_STREAM_DECODE no sound can be heard.  I can see my MP3 being decoded as my waveform shows activity, but no sound at all.

Did I miss something?  ???

afsanchez001

  • Posts: 108
Whoops!

My waveform was showing streamA ... not streamTempo like I thought.

Once I switched over to streamTempo under the BASS_STREAM_DECODE method, it no longer shows activity.

And still no sound.

Scratching my head...  :-\

Ian @ un4seen

  • Administrator
  • Posts: 23470
Are any of the calls reporting failure in their return values? If any is failing, you can use BASS_ErrorGetCode to get an error code, which you can then look up in the function's documentation to find out why it failed. If the BASS_ChannelPlay call is failing, make sure you're not using the BASS_STREAM_DECODE flag on the final stream, ie. the one that you call BASS_ChannelPlay on. If the problem is still a mystery, then please post what your code currently looks like, and I'll see if I can spot something wrong.

afsanchez001

  • Posts: 108
The BASS_ErrorGetCode log file I show is as follows:

BASS_StreamCreateFile,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_FX_ReverseCreate,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_FX_TempoCreate,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK
BASS_ChannelPlay,  Version: 2.4.10, BASS_GetVersion() State: BASS_OK

It could be the suggestion to not decode the final stream.  I will try that.  Also, if it fails I'll just post my code.

Thank you Ian!  :)

afsanchez001

  • Posts: 108
Hey, here is something odd (I think).

* * * * * * *

streamA = Bass.BASS_StreamCreateFile(audioFile, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
// create a decoding channel for the audio file

streamA always results in a value of '-1342177279', this becomes the int channel

streamRev = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE);
// create a reverse stream (also a decoding channel) on that

streamRev results in a value of '0', this becomes the int channel

streamTempo = BassFx.BASS_FX_TempoCreate(streamRev, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_DEFAULT);
// create a tempo stream on that

streamTempo results in a value of '0', this becomes the int channel


* * * * * * *

Is that expected?

Chris

  • Posts: 1921
Just check after every BASS*Create.... the Error with Bass_ErrorGetCode

afsanchez001

  • Posts: 108
This is the source code and the BASS_ErrorGetCode resuts:


Code: [Select]
streamA = Bass.BASS_StreamCreateFile(audioFile, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // create a decoding channel for the audio file
ErrString += "\r\n" + "BASS_StreamCreateFile, Code: " + Bass.BASS_ErrorGetCode();

streamRev = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE); // create a reverse stream (also a decoding channel) on that
ErrString += "\r\n" + "BASS_FX_ReverseCreate, Code: " + Bass.BASS_ErrorGetCode();

streamTempo = BassFx.BASS_FX_TempoCreate(streamRev, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_DEFAULT); // create a tempo stream on that
ErrString += "\r\n" + "BASS_FX_TempoCreate, Code: " + Bass.BASS_ErrorGetCode();

textBox1.Text = @"" + ErrString;


BASS_StreamCreateFile, Code: BASS_OK
BASS_FX_ReverseCreate, Code: BASS_OK
BASS_FX_TempoCreate, Code: BASS_OK


« Last Edit: 17 Nov '15 - 03:08 by afsanchez001 »

Ian @ un4seen

  • Administrator
  • Posts: 23470
Are you getting the streamRev/streamTempo=0 results with that? If so, the error codes shouldn't be BASS_OK (0). I notice in your earlier posts that you appear to be also logging the BASS version by calling BASS_GetVersion. BASS_GetVersion will reset the error code, so that could explain the BASS_OK in your logging even if the BASS_FX_ReverseCreate/TempoCreate calls failed. If you do log the version, make sure the BASS_ErrorGetCode call comes first.

afsanchez001

  • Posts: 108
Dang!!!  I did not know that.  Okay, let me remove the BASS_version from the error code.  :P

afsanchez001

  • Posts: 108
Hi Ian  

I did have the Bass.BASS_GetVersion() removed from the code later on.  Here is my exact CODE:

Oh!  I also left in my comments as to preserve the post exactly to what's in my program.  As you can see even the comments you provided me over our course of discussion, they made it in as well.

:)

Code: [Select]
       public void PlayTrackA(String audioFile)
        {
            Bass.BASS_SetDevice(2);

   streamA = Bass.BASS_StreamCreateFile(audioFile, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // create a decoding channel for the audio file
   ErrString += "\r\n" + "BASS_StreamCreateFile, Code: " + Bass.BASS_ErrorGetCode();
            
   streamRev = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE); // create a reverse stream (also a decoding channel) on that
   ErrString += "\r\n" + "BASS_FX_ReverseCreate, Code: " + Bass.BASS_ErrorGetCode();

   streamTempo = BassFx.BASS_FX_TempoCreate(streamRev, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_DEFAULT); // create a tempo stream on that
   ErrString += "\r\n" + "BASS_FX_TempoCreate, Code: " + Bass.BASS_ErrorGetCode();

   // the above means that the data path is: file -> reverse processing -> tempo processing

            Bass.BASS_ChannelSetAttribute(streamTempo, BASSAttribute.BASS_ATTRIB_REVERSE_DIR, (float)BASSFXReverse.BASS_FX_RVS_REVERSE); // play the channel reverse

   Bass.BASS_ChannelSetAttribute(streamTempo, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, iValA_pitch); // <-- incoming value (float)
   Bass.BASS_ChannelSetAttribute(streamTempo, BASSAttribute.BASS_ATTRIB_TEMPO, iValA_tempo); // <-- incoming value (float)
   Bass.BASS_ChannelSetAttribute(streamTempo, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, iValA_rate); // <-- incoming value (float)
            
   /*
   BASS_ATTRIB_TEMPO_PITCH     [-60....0....+60] semitones // also named as PitchShift
   BASS_ATTRIB_TEMPO_FREQ      [ 5%..0..+5000%] Samplerate in Hz (must be within 5% to 5000% of the original sample rate)
   BASS_ATTRIB_TEMPO           [-95%..0..+5000%] percents // also named as TimeStretch
   */

            int fxEchoHandle = 0;
            int fxReverbHandle = 0;

            //ECHO
            BASS_DX8_ECHO echo = new BASS_DX8_ECHO();
            fxEchoHandle = Bass.BASS_ChannelSetFX(streamTempo, BASSFXType.BASS_FX_BFX_ECHO4, 1);
            echo.Preset_Long();
            Bass.BASS_FXSetParameters(fxEchoHandle, echo);

            //REVERB
            BASS_DX8_REVERB reverb = new BASS_DX8_REVERB();
            fxReverbHandle = Bass.BASS_ChannelSetFX(streamTempo, BASSFXType.BASS_FX_DX8_REVERB, 1);
            reverb.Preset_Default();
            Bass.BASS_FXSetParameters(fxReverbHandle, reverb);

            Bass.BASS_ChannelSetAttribute(streamTempo, BASSAttribute.BASS_ATTRIB_VOL, 0.7f);

   textBox1.Text = @"" + ErrString;

   timerPlayerA_Start(); // <-- my waveform timer uses (Bass.Misc.Visuals --> Spectrum2.CreateSpectrumWave)

   Bass.BASS_ChannelPlay(streamTempo, false);
        }

That is my code exactly.  The error log results are:

BASS_StreamCreateFile, Code: BASS_OK
BASS_FX_ReverseCreate, Code: BASS_OK
BASS_FX_TempoCreate, Code: BASS_OK


 ???

A step-through analysis, going line by line shows me:

streamA = -1342177279
streamRev = 0
streamTempo = 0


So as streamTempo carries a '0' value the rest of the way, we get no sound, no waveform.

And finally, I ran code to get the version I am running if this helps:

Code: [Select]
            Bass.BASS_SetDevice(2);

    streamA = Bass.BASS_StreamCreateFile(audioFile, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // create a decoding channel for the audio file

            ErrString += "\r\n" + "BASS_StreamCreateFile, Code: " + Bass.BASS_ErrorGetCode();
            ErrString += "\r\n" + "Major: " + Bass.BASS_GetVersion(1);
            ErrString += "\r\n" + "Minor: " + Bass.BASS_GetVersion(2);
            ErrString += "\r\n" + "Build: " + Bass.BASS_GetVersion(3);
            ErrString += "\r\n" + "Revision: " + Bass.BASS_GetVersion(4);

            textBox1.Text = @"" + ErrString;



BASS_StreamCreateFile, Code: BASS_OK
Major: 2.0
Minor: 2.4
Build: 2.4.10
Revision: 2.4.10.0
« Last Edit: 17 Nov '15 - 16:20 by afsanchez001 »

Ian @ un4seen

  • Administrator
  • Posts: 23470
That is my code exactly.  The error log results are:

BASS_StreamCreateFile, Code: BASS_OK
BASS_FX_ReverseCreate, Code: BASS_OK
BASS_FX_TempoCreate, Code: BASS_OK


 ???

A step-through analysis, going line by line shows me:

streamA = -1342177279
streamRev = 0
streamTempo = 0


That's very strange. Please try logging the return values at the same time as the error codes, something like this:

Code: [Select]
    streamA = Bass.BASS_StreamCreateFile(audioFile, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // create a decoding channel for the audio file
    ErrString += "\r\n" + "BASS_StreamCreateFile = " + streamA + ", Code: " + Bass.BASS_ErrorGetCode();
           
    streamRev = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE); // create a reverse stream (also a decoding channel) on that
    ErrString += "\r\n" + "BASS_FX_ReverseCreate = " + streamRev + ", Code: " + Bass.BASS_ErrorGetCode();

    streamTempo = BassFx.BASS_FX_TempoCreate(streamRev, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_AUTOFREE); // create a tempo stream on that
    ErrString += "\r\n" + "BASS_FX_TempoCreate = " + streamTempo + ", Code: " + Bass.BASS_ErrorGetCode();

afsanchez001

  • Posts: 108
Thanks Ian,

I commented out my code and placed yours in, here are the results:

Code: [Select]
            streamA = Bass.BASS_StreamCreateFile(audioFile, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // create a decoding channel for the audio file
            ErrString += "\r\n" + "BASS_StreamCreateFile = " + streamA + ", Code: " + Bass.BASS_ErrorGetCode();

            streamRev = BassFx.BASS_FX_ReverseCreate(streamA, 2f, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE); // create a reverse stream (also a decoding channel) on that
            ErrString += "\r\n" + "BASS_FX_ReverseCreate = " + streamRev + ", Code: " + Bass.BASS_ErrorGetCode();

            streamTempo = BassFx.BASS_FX_TempoCreate(streamRev, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_AUTOFREE); // create a tempo stream on that
            ErrString += "\r\n" + "BASS_FX_TempoCreate = " + streamTempo + ", Code: " + Bass.BASS_ErrorGetCode();

BASS_StreamCreateFile = -1342177279, Code: BASS_OK
BASS_FX_ReverseCreate = 0, Code: BASS_OK
BASS_FX_TempoCreate = 0, Code: BASS_OK


 :-\

Ian @ un4seen

  • Administrator
  • Posts: 23470
Very strange, I'm not sure how that could be happening. What type do the streamRev/Tempo variables have, ie. are they "int"? For comparison, what values do you see if you do this?

Code: [Select]
            int res = Bass.BASS_ChannelStop(-1);
            int ec = Bass.BASS_ErrorGetCode();

Chris

  • Posts: 1921
By the way you working with BASS_FX do you make a
BASS_FX_GetVersion Call ?? (Should be after the BASS_GetVersion Call)

afsanchez001

  • Posts: 108
Thanks Chris!  I will be sure to do that. ;)

Ian, I seem to have solved the problem with your suggestions and some tinkering.  ;D

1. removing BASSFlag.BASS_STREAM_AUTOFREE from streamA
2. adding BASSFlag.BASS_STREAM_DECODE to streamA as you suggested
3. replacing BASSFlag.BASS_STREAM_DECODE with BASSFlag.BASS_STREAM_AUTOFREE in streamTempo

That did the trick!  Reverb, Echo, Reverse are working great!

HOWEVER...  ::)  For some reason the PITCH, TEMPO and RATE seem to fail but I think it is because I do not know how to pass in the correct values (yet).  No worries I will work on that now that the rest are operational.

Thank you!

Genesio

  • Guest
hello,
i have same problem, loaded the MP3 stream  playing ok but no pitch changing. I load the MP3 with :
dim  streamPlayer as integer = Bass.BASS_StreamCreateFile(mp3FileName, 0, 0, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MUSIC_FLOAT)

and try to apply pitch with :
 Bass.BASS_ChannelSetAttribute(streamPlayer, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, pitchValue)

whats wrong ? It doesnt works, the MP3 plays normally but without pitch shifting
Thank you guys

Ian @ un4seen

  • Administrator
  • Posts: 23470
The BASS_FX add-on is required for the BASS_ATTRIB_TEMPO_PITCH option, specifically the BASS_FX_TempoCreate function. You could do something like this:

Code: [Select]
dim  streamPlayer as integer = Bass.BASS_StreamCreateFile(mp3FileName, 0, 0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)
streamPlayer = BassFx.BASS_FX_TempoCreate(streamPlayer, BASSFlag.BASS_FX_FREESOURCE)

Bass.BASS_ChannelSetAttribute(streamPlayer, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, pitchValue)

Please see the BASS_FX_TempoCreate documentation for details.

genex1000

  • Posts: 2
It works !!!
Thank you so much.
I was missing a passage  to "reuse" the handler streamPlayer to create tempo where change pitch on.
When finished and if it can be useful to someone, i can give full source code of free Karaoke app for Windows.
In the meantime, thank you so much again
Genesio