BASS.NET API 2.4.18.2

Started by radio42,

jeroenp

Quote from: radio42So the question stays: what is the real advantage of having a lib in the GAC - since that would anyhow only have an effect to the development side of the world - but for me no real bennefit.

Less overhead, NGENable, easier to maintain.

It would be very nice if this could be an option in the installation.
I know it can be done by hand, but I prefer automatic ways.

--jeroen

ken

Recording in Mono?

What is the easyest whay to record in mono?  I got me a great USB microphone "Rode Podcaster" (http://www.rodepodcaster.com/page2.html)

It's acts as a own device but only have give me sound on one channel (L) . So how can I easy dublicate this channel  with sound (L) to stereo (L+R).

Thanks!

ken

 ??? Me not thinking... Sorry!   ::)

Well it was too easy...

Changing X from 2 to 1 solved me dilema.

Bass.BASS_RecordStart(44100, X, BASSRecord.BASS_DEFAULT, _recProc, 0);

ken

#263
I'm back...   8)

Well another question.  I try to add an BASS_FX_DSPPEAKEQ to my "recorder"

I have a simple recorder that save to MP2/MP3 "on the fly" and I want to add an EQ and a compressor that prosess the signal before file.

I use Same code for playback and EQ works there. How do I do EQ on recording channel?

Some snippets...

public void StartRecording(int soundcardIndex, string filename, int bitRate, AudioFormat audioFormat, bool recordMono)
        {
            _IsRecordingMonitor = false;

            _recordingAudioFormat = audioFormat;

            if (_IsRecording)
                StopRecording();

            if (!Bass.BASS_RecordInit(soundcardIndex))
                Console.WriteLine("Rec: Bass_RecordInit error!");

            _recProc = new RECORDPROC(RecordingHandler);

            if (recordMono)
                _recHandle2 = Bass.BASS_RecordStart(44100, 1, BASSRecord.BASS_DEFAULT, _recProc, 0);
            else
                _recHandle2 = Bass.BASS_RecordStart(44100, 2, BASSRecord.BASS_DEFAULT, _recProc, 0);


            if (_recHandle2 == Bass.FALSE)
                Console.WriteLine("Rec: BASS_RecordStart error!");


            // set up a ready-made DSP (here the PeakLevelMeter)
            _plm = new DSP_PeakLevelMeter(_recHandle2, 1);
           

            _monBuffer.Clear();

            switch (audioFormat)
            {
                case AudioFormat.MP2:
                    lameTooLame = new EncoderTooLAME(_recHandle2);
                    lameTooLame.InputFile = null;
                    lameTooLame.OutputFile = filename + ".MP2";
                    lameTooLame.TOO_Bitrate = bitRate;
                    lameTooLame.Start(null, 0);

                    _fileName = filename + ".MP2";

                    if (!lameTooLame.EncoderExists)
                    {
                        //Console.WriteLine("Rec: tooLAME.EXE can not be found...");

                    }
                    break;

......



RecHanler:
private bool RecordingHandler(int handle, IntPtr buffer, int length, int user)
        {
            // user will contain our encoding handle
            if (length > 0 && buffer != IntPtr.Zero)
            {
                if (_IsMonitorRecorder)
                {
                    _monBuffer.Write(buffer, length);
                }
            }
           
            return true;
        }

Add EQ:
public void AddEQ()
        {
            _eq1 = new BASS_FX_DSPPEAKEQ();

            BASS_FX_DSPPEAKEQ _DSPeq1 = new BASS_FX_DSPPEAKEQ(0, 125, 18, 0, 1, 0);
            BASS_FX_DSPPEAKEQ _DSPeq2 = new BASS_FX_DSPPEAKEQ(1, 1000, 18, 0, 1, 0);
            BASS_FX_DSPPEAKEQ _DSPeq3 = new BASS_FX_DSPPEAKEQ(2, 8000, 18, 0, 1, 0);

            _EqHandleL1 = Bass.BASS_ChannelSetFX(_recHandle2, BASSFXType.BASS_FX_PARAMEQ, 10);
            _EqHandleL2 = Bass.BASS_ChannelSetFX(_recHandle2, BASSFXType.BASS_FX_PARAMEQ, 10);
            _EqHandleL3 = Bass.BASS_ChannelSetFX(_recHandle2, BASSFXType.BASS_FX_PARAMEQ, 10);

            Bass.BASS_FXSetParameters(_EqHandleL1, _DSPeq1);
            Bass.BASS_FXSetParameters(_EqHandleL2, _DSPeq2);
            Bass.BASS_FXSetParameters(_EqHandleL3, _DSPeq3);
        }


Change EQ:
public void SetEQ(float lowGain, float mid, float high)
        {
         

                    BASS_FX_DSPPEAKEQ _DSPeq1 = new BASS_FX_DSPPEAKEQ(0, 125, 18, 0, 1, lowGain);
                    BASS_FX_DSPPEAKEQ _DSPeq2 = new BASS_FX_DSPPEAKEQ(1, 1000, 18, 0, 1, mid);
                    BASS_FX_DSPPEAKEQ _DSPeq3 = new BASS_FX_DSPPEAKEQ(2, 8000, 18, 0, 1, high);

                    _EqHandleL1 = Bass.BASS_ChannelSetFX(_recHandle2, BASSFXType.BASS_FX_PARAMEQ, 10);
                    _EqHandleL2 = Bass.BASS_ChannelSetFX(_recHandle2, BASSFXType.BASS_FX_PARAMEQ, 10);
                    _EqHandleL3 = Bass.BASS_ChannelSetFX(_recHandle2, BASSFXType.BASS_FX_PARAMEQ, 10);

                    Bass.BASS_FXSetParameters(_EqHandleL1, _DSPeq1);
                    Bass.BASS_FXSetParameters(_EqHandleL2, _DSPeq2);
                    Bass.BASS_FXSetParameters(_EqHandleL3, _DSPeq3);


                    _eq1.lBand = 0;
                    _eq1.fBandwidth = 18F;
                    _eq1.fGain = lowGain;
                    _eq1.fCenter = 120;
                    BassFx.BASS_FX_DSP_SetParameters(_recHandle2, _eq1);

                    _eq1.lBand = 1;
                    _eq1.fBandwidth = 18F;
                    _eq1.fGain = mid;
                    _eq1.fCenter = 1000;
                    BassFx.BASS_FX_DSP_SetParameters(_recHandle2, _eq1);

                    _eq1.lBand = 2;
                    _eq1.fBandwidth = 18F;
                    _eq1.fGain = high;
                    _eq1.fCenter = 8000;
                    BassFx.BASS_FX_DSP_SetParameters(_recHandle2, _eq1);
     

        }

radio42

Hi Ken,

what is actually not working with your code?
It looks okay so far!

Just one thing. You might want to make the "SetEQ" methof a little simpler ;-)
public void SetEQ(float lowGain, float mid, float high)
{
    BASS_FXPARAMEQ eq = new BASS_FXPARAMEQ();
    if (Bass.BASS_FXGetParameters(_EqHandleL1, eq))
    {
        eq.fGain = lowGain;
        Bass.BASS_FXSetParameters(_EqHandleL1, eq);
    }
    if (Bass.BASS_FXGetParameters(_EqHandleL2, eq))
    {
        eq.fGain = mid;
        Bass.BASS_FXSetParameters(_EqHandleL2, eq);
    }
    if (Bass.BASS_FXGetParameters(_EqHandleL3, eq))
    {
        eq.fGain = high;
        Bass.BASS_FXSetParameters(_EqHandleL3, eq);
    }
}

ken

Ok, When recording I get now effect from the EQ, the EQ is not working. So I wonder is this the correct way to add an DSP (EQ or compressor) to a recording channel?

radio42

#266
Hi Ken,

I just made a quick test and here all is working fine.
I also tested other DSP effects, like the DX8 compressor and also BASS_VST - those DSPs work fine too.

ken

Ah, so Bass.dll own FX works on recording, great. 

Bass.dll own crompessor also have more settings so I think it will do the jobb I want.

I fidle a bit with Bass (DX8) but did't get it working. Any chance you have a code snippet showing how?

radio42

#268
QuoteAh, so Bass.dll own FX works on recording, great
BASS and BASS_FX work fine on recording channels!

Here is some code on how to setup effects, like the EQ or Compressor on a recording channel:
private RECORDPROC _recordingProc = null;
private int[] _eq = new int[4]; // 4-band eq
private int _compressor = 0;
...
_recordingProc = new RECORDPROC(RecordingCallback);
Bass.BASS_RecordSetDevice(_device);
// enable the selected input
for (int i = 0; Bass.BASS_RecordSetInput(i, BASSInput.BASS_INPUT_OFF); i++); // 1st disable all inputs, then...
Bass.BASS_RecordSetInput(_config.Input, BASSInput.BASS_INPUT_ON); // enable the selected
_recordStream = Bass.BASS_RecordStart(44100, 2, BASSRecord.BASS_SAMPLE_FLOAT, _recordingProc, 0);


// setup 4 a EQ bands
BASS_FXPARAMEQ eq = new BASS_FXPARAMEQ();
_eq[0] = Bass.BASS_ChannelSetFX(_recordStream, BASSFXType.BASS_FX_PARAMEQ, 10);
_eq[1] = Bass.BASS_ChannelSetFX(_recordStream, BASSFXType.BASS_FX_PARAMEQ, 10);
_eq[2] = Bass.BASS_ChannelSetFX(_recordStream, BASSFXType.BASS_FX_PARAMEQ, 10);
_eq[3] = Bass.BASS_ChannelSetFX(_recordStream, BASSFXType.BASS_FX_PARAMEQ, 10);

eq.fGain = 0f;
eq.fBandwidth = 18f;
eq.fCenter = 100f;
Bass.BASS_FXSetParameters(_eq[0], eq);
eq.fCenter = 1000f;
Bass.BASS_FXSetParameters(_eq[1], eq);
eq.fCenter = 5000f;
Bass.BASS_FXSetParameters(_eq[2], eq);
eq.fCenter = 10000f;
Bass.BASS_FXSetParameters(_eq[3], eq);

// setup a compressor
_compressor = Bass.BASS_ChannelSetFX(_recordStream, BASSFXType.BASS_FX_COMPRESSOR, 5);

...

private bool RecordingCallback(int handle, IntPtr buffer, int length, int user)
{
    return true;
}

private void UpdateEQGain(int band, float gain)
{
    BASS_FXPARAMEQ eq = new BASS_FXPARAMEQ();
    if (Bass.BASS_FXGetParameters(_eq[band], eq))
    {
        eq.fGain = gain;
        Bass.BASS_FXSetParameters(_eq[band], eq);
    }
}

private void UpdateCOMP(float gain, float attack, float release, float threshold, float ratio, float predelay)
{
    if (_compressor == 0)
        return;

    BASS_FXCOMPRESSOR comp = new BASS_FXCOMPRESSOR();
    if (Bass.BASS_FXGetParameters(_compressor, comp))
    {
        comp1.fGain = gain;
        comp1.fAttack = attack;
        comp1.fRelease = release;
        comp1.fThreshold = threshold;
        comp1.fRatio = ratio;
        comp1.fPredelay = predelay;
        Bass.BASS_FXSetParameters(_compressor, comp);
    }
}



P.S.:
QuoteBass.dll own crompessor also have more settings so I think it will do the jobb I want
Yes, I would recommend to use the BASS DX8 compressor instead of the BASS_FX add-on compressor, since the DX8 compressor is much better!

ken

Thanks!

EQ works if I "monitor" the recorder stream, but EQ is not on the recorded file.  Hope Ian find something!

radio42

#270
How do you "monitor" the recorder stream?

Since when I am using e.g. a user DSP (with a lower prio) and create a user stream to 'clone' the recording stream and then feed this 'clone' to an output...the EQ effect is present!

ken

I think I took the "monitoring" from your examples.


_monProc = new STREAMPROC(MonitoringStream);
_monStream = Bass.BASS_StreamCreate(44100, 2, 0, _monProc, 0); // user = reader#
Bass.BASS_ChannelPlay(_monStream, false);


private int MonitoringStream(int handle, IntPtr buffer, int length, int user)
        {
            return _monBuffer.Read(buffer, length, user);
        }


private bool RecordingHandler(int handle, IntPtr buffer, int length, int user)
        {
            // user will contain our encoding handle
            if (length > 0 && buffer != IntPtr.Zero)
            {
                if (_IsMonitorRecorder)
                {
                    _monBuffer.Write(buffer, length);
                }
            }
           
            return true;
        }

radio42

#272
That's rather strange.
I mean yes, that's all correct.

But if the EQ is applied in the "monitor" (and so within the buffer of the RECORDPROC) it is even more strange, why it wouldn't be in the encoder!

radio42

Hi Ken,

I must restate my findings!!! There is actually no bug in BASS!
It was a mistake in my test app with caused the issue.
I was triying both the DSP chain as well as encoding - and the EQ is working fine in both!

So it must also be a mistake in your app. In my test app I was not updating a UI correctly resulting in the mistake, that the gain value was always 0 - so any EQ update actually was not performed as I thought.
Maybe this is also your case.

So I corrected the posts above!

ken

Parhaps a cool new feature to the waveform class?

Serato (vinyl emulation DJ software...) show waveform i different colors (for bass, mid, high) and I wonder how they do it. But I figure they make one waveform for bass, one for mid, and one for high frequecys, the just put them in "layers" on top of each other.  And you can choose to show all paralell to each other. See pic:



/Ken

radio42

Hi Ken,

just wondering, if your recording EQ issue resolved - since that was definitly not a BASS nor a BASS.NEt thing?!

Regarding the WaveForm rendering. I guess the WaveForm will for now stay as it is.
Introducing such layers would increase the complexity of the rendering and the painting a lot. And the cost of doing so would not justify it's use case. So I guess, if you need such you'll need to implement your own WaveForm class.

ken

I don't had have the time to test more ways with my "EQ thing" I try to do it soon, and get back to you.

The waveform was just an crazy idea, don't bother  :)
/Ken

Renegade

Are there any breaking changes between 2.3.1.3 and 2.3.1.8?

Just checking to make sure.

Thanks in advance.

radio42

Yes and No - it depends what you have used so far;-)

Mainly between 2.3.1.3 and 2.3.1.8 BASSAsio has been changed, since in between BASSAsio became a final release (see ASIOPROC).
Also BASSmix has slightly be changed - no real breaking changes here, but new methods have been added which are recommended to be used.
And finally there was one BASS change regarding the use of stream creation flags (before illegal flags have been ignored - in the latest BASS version they will cause an error) - this is mailnly around the use of the AUTOFREE and DECODE flags.

Here is a complete list of changes between 2.3.1.3 and 2.3.1.8:
// 2.3.1.4 - BASSmix: support for latest version added:
//           . new BASS_MIXER_PAUSE flag:
//             to be used with BASS_Mixer_StreamAddChannel(Ex) and BASS_Mixer_ChannelFlags
//           . new BASS_Mixer_ChannelSetSync and BASS_Mixer_ChannelRemoveSync
//           . new BASS_Mixer_ChannelIsActive, BASS_Mixer_ChannelPause, BASS_Mixer_ChannelPlay
// 2.3.1.5 - Upgrade supporting BASSVis v2.3.1.0
//         - WaveForm: improved rendering performance
// 2.3.1.6 - Upgrade supporting BASSVis v2.3.1.1
//         - BASS: Version 2.3.0.3 support added:
//           . FX state resetting: new BASS_FXReset method
//           . PLS/M3U playlist URL processing: new BASS_CONFIG_NET_PLAYLIST config option
//           . Internet stream connection status retrieval: new BASS_FILEPOS_CONNECTED (BASS_StreamGetFilePosition mode)
//           . Lyrics3v2 tags: new BASS_TAG_LYRICS3 (BASS_ChannelGetTags type)
//           . IT virtual channel configuration: new BASS_CONFIG_MUSIC_VIRTUAL config option
//           . Accurate speaker detection on Vista: BASS_INFO (speakers member)
//           . Device output/input rate retrieval on Vista: BASS_INFO and BASS_RECORDINFO (freq member)
//           . Syncing upon position changes BASS_SYNC_SETPOS (BASS_ChannelSetSync type)
//           . Improved stall handling: BASS_SYNC_STALL
//           . Invalid decoding channel flags produce an error instead of being ignored:
//             at BASS_StreamCreate/File/User/Url and BASS_MusicLoad
//         - Misc: new DSP_BufferStream class added (synchronized decoding channel clones)
// 2.3.1.7 - Upgrade supporting BASS v2.3.0.3
//           Upgrade supporting BASSmix v2.3.0.0
//           Upgrade supporting BASSVis v2.3.1.2
//           DSP_PeakLevelMeter: small bug fix when calculating the UpdateTime
//           BassAsioHandler: small bug fix with the Volume calculation
//           BassAsioHandler: new Notification event handler added
// 2.3.1.8 - Upgrade supporting BASS_VIS v2.3.2.1
//         - Bug-Fix in AddOn.Tags: reading non zero-terminated ID3v1 tags
//         - Upgrade in EncoderOGG: supporting new oggenc2.84 (float input)
//         - Enhancement in WaveForm: new volume curve options and WAVEFORMDRAWTYPE.HalfMono
//         - Upgrade supporting final BASSASIO v1.0.0.0
//           (ASIOPROC signature change: must now return the number of bytes written)

Renegade

Thanks Bernd. I'll watch for those.

One other thing - are the upgrades for other BASS modules necessary when moving to 2.3.1.8 or are they optional? Any breaks there?

I just want to make sure that I have a good grip on what I'll need to watch for.

Thanks in advance.