Author Topic: BASS.NET API 2.4.12.7  (Read 782036 times)

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.2
« Reply #500 on: 27 Jul '08 - 21:17 »
So then it is definity not related the any GC stuff - when it also happens with the natibe BASSASIO example.
It sounds like a problem with the ASIO driver itself then...really strange.
As of today I also would have no idea what this can cause, but I'll think about it...

ken

  • Posts: 739
Re: BASS.NET API 2.4.1.2
« Reply #501 on: 27 Jul '08 - 21:28 »
My idea also not an BASS isue. I will order me a new soundcard. I was looking at this one: http://www.esi-audio.com/products/esu1808/  or maybe this: http://www.m-audio.com/products/en_us/Delta1010LT-main.html

Bernd, what ASIO card do you use, and have you the "pop" issu when open folder in windows explorer?
« Last Edit: 27 Jul '08 - 21:32 by ken »

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.2
« Reply #502 on: 28 Jul '08 - 09:41 »
No, I don't have these issue and haven't discovered them so far.
I'm using the following soundcards:
1) M-Audio Delta-1010 (excellent): http://www.m-audio.com/products/en_us/Delta1010-main.html
2) Echo Indigo (for Laptops): http://www.echoaudio.com/Products/CardBus/IndigoDJ/index.php
3) an older Soundblaster Audigy
4) different onboard soundcards

Bello

  • Posts: 30
Re: BASS.NET API 2.4.1.2
« Reply #503 on: 29 Jul '08 - 09:46 »
Bernd,

I found some information on c++ CLR assemblies on MSDN, but how to uses this in a managed c# application with a C# proxy holding function pointers (I guess) is still not clear to me.
Would you be willing to provide us with a sample application?

I'm sure I wouldn't be the only one on this forum that would find this highly educational.

Thanks,
Bello.

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.2
« Reply #504 on: 29 Jul '08 - 11:55 »
Oki here comes a little example on how to create "Mixed Mode" assemblies:

Preliminary:
To write a "Mixed Mode" assembly you need to create a Visual C++ assembly (a dynamic link libraray, dll)!
The trick is to write managed C++ code (.Net code) and unmanged C++ code (native).
The managed code can then be accessed by any other .Net language, like C# or VB.Net.

a) You create a new Visual C++ project as a new class library (dll)
    - make sure to set the "Common Language Runtime Support" (/clr) switch in the general configuration properties
    - so this will be your mixed mode assembly

b) add the BASS header file(s) to your new Visual C++ project (just drag & drop e.g. the bass.h file to the 'Header Files' section of your new project'

c) Now you create two .cpp files: e.g. "BassManagedWrapper.cpp" and "BassUnmanaged.cpp"
    - the content of these files will be shown later (see below)

d) compile everything and you are done
    - now you can use this new library as a normal assembly within your standard .Net application
    - just add it as a new reference

Now to the content of the two files mentioned:

1) BassUnmanaged.cpp
Code: [Select]
#pragma once
#include "Stdafx.h"

#pragma unmanaged
#include <math.h>
#include <malloc.h>
#include <stdio.h>
#include <process.h>
#include "bass.h"
#using <mscorlib.dll>

#ifndef UNMANAGED
#define UNMANAGED

class EasyRecord
{
private:
    HRECORD _recordHandle;
    HSTREAM _streamCopy;

    /* The actual recording callback */
    static BOOL CALLBACK RecordingCallback(HRECORD handle, const void *buffer, DWORD length, void *user)
    {
        EasyRecord* easy = (EasyRecord*)user;

        if (easy->_streamCopy != 0 && length > 0)
            BASS_StreamPutData(easy->_streamCopy, buffer, length);

        // always continue recording
        return TRUE;
    }

public:
    /* Constructor */
    EasyRecord(void)
    {
        this->_recordHandle = 0;
        this->_streamCopy = 0;
    }

    /* Gets the recording handle */
    DWORD GetRecordHandle(void)
    {
        return this->_recordHandle;
    }

    /* Gets the stream copy handle */
    DWORD GetStreamCopy(void)
    {
        return this->_streamCopy;
    }

    /* Sets the stream copy handle */
    void GetStreamCopy(HSTREAM streamCopy)
    {
        this->_streamCopy = streamCopy;
    }

    /* Clears the recording buffer */
    void ClearRecordingBuffer(void)
    {
        BASS_ChannelGetData(this->_recordHandle, NULL, BASS_ChannelGetData(this->_recordHandle, NULL, BASS_DATA_AVAILABLE));
    }

    /* Creates a recording clone */
    void CreateClone(DWORD flags)
    {
        BASS_CHANNELINFO info;
        BASS_ChannelGetInfo(this->_recordHandle, &info);
        flags |= info.flags;
        flags &= ~BASS_STREAM_AUTOFREE;

        this->_streamCopy = BASS_StreamCreate(info.freq, info.chans, flags, STREAMPROC_PUSH, 0);

        if (this->_streamCopy != 0)
        {
            BASS_ChannelPause(this->_recordHandle);
            this->ClearRecordingBuffer();
            BASS_ChannelPlay(this->_recordHandle, TRUE);
        }
    }

    /* Removes a recording clone */
    void RemoveClone()
    {
        if (this->_streamCopy != 0)
        {
            BASS_StreamFree(this->_streamCopy);
            this->_streamCopy = 0;
        }
    }

    void Start(DWORD freq, DWORD chans, DWORD flags, DWORD period, BOOL decoding)
    {
        if (period > 0)
            flags = MAKELONG(flags, period);
        if (decoding)
            this->_recordHandle = BASS_RecordStart(freq, chans, flags, NULL, this);
        else
            this->_recordHandle = BASS_RecordStart(freq, chans, flags, &EasyRecord::RecordingCallback, this);
    }

    void Stop(void)
    {
        this->RemoveClone();

        BASS_ChannelStop(this->_recordHandle);
        BASS_StreamFree(this->_recordHandle);
        this->_recordHandle = 0;
    }
};
As you can see this simple unmanaged C++ class has a static callback (to access the related instance members the 'user' param of the callback is used.
The callback itself will be used, if you call the 'Start' method of the class.
Also note the "#pragma unmanaged" line at the top of the file. This switch tells the compiler, that you are now coding in native, unmanaged code!
As this class can not directly be used by any .Net language (as it is native code), we need to write a .Net wrapper class.
This is what we do in the next file...


2) BassManagedWrapper.cpp
Code: [Select]
#include "Stdafx.h"
#include "BassUnmanaged.cpp"

#pragma managed

using namespace System;
using namespace System::Runtime::InteropServices;

namespace MyBASS
{

public ref class EasyRecording : public IDisposable
{
private:
    /* pInner is used to invoke the exposed methods in the unmanaged class. */
    EasyRecord* pInner;

public:
    // Constructor
    EasyRecording()
    {
        /* define the pInner object */
        pInner = new EasyRecord();
    }
    //destructor
    ~EasyRecording()
    {
        //call finalizer (don't wait for GC)
        this->!EasyRecording();
    }
    //finalizer
    !EasyRecording()
    {     
        delete pInner;
        pInner = NULL;
    }

    // Gets the recording handle
    property int RecordHandle
    {
        int get(void) { return pInner->GetRecordHandle(); }
    }

    // Gets a stream copy handle
    property int StreamCopy
    {
        int get(void) { return pInner->GetStreamCopy(); }
    }

    // Clears the recording buffer
    void ClearRecordingBuffer(void)
    {
        pInner->ClearRecordingBuffer();
    }

    // Creates a stream clone
    void CreateClone(int flags)
    {
        pInner->CreateClone(flags);
    }

    // Remove a stream clone
    void RemoveClone(void)
    {
        pInner->RemoveClone();
    }

    // Starts the Recording
    void Start(int freq, int chans, int flags, int period, bool decoding)
    {
        pInner->Start(freq, chans, flags, period, decoding);
    }

    // Stops the recording
    void Stop(void)
    {
        pInner->Stop();
    }
};

}
The "#pragma managed" line at the top of the file tells the compiler, that we now code in managed C++ (.Net code)!
We use a member called "pInner" which is of the type of our unmanaged class to access the native unmanaged code.
As you can see, we create an instance of it in the constructor and make sure, that we delete it in the finalizer.
This is nessesary, because any instance of an unmanaged class will not be seen by the Gargabe Collector and thus we have to make sure to free any resources here.
For the rest all is easy. We simply invoke the "pInner" members in our wrapper methods.
As a result, we can assess the managed class "EasyRecording" from any .Net language.


So if you add the finally build libraray (as shown above) to your .Net application as a new reference you can use it like this:
Code: [Select]
private MyBASS.EasyRecording _recordHandler = null;
private int _recordStream = 0;
...
Bass.BASS_RecordSetDevice(0);
for (int i = 0; Bass.BASS_RecordSetInput(i, BASSInput.BASS_INPUT_OFF, -1f); i++); // 1st disable all inputs, then...
                  Bass.BASS_RecordSetInput(0, BASSInput.BASS_INPUT_ON, -1f); // enable the selected

_recordHandler = new MyBASS.EasyRecording();
_recordHandler.Start(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT, 100, false);
_recordStream = _recordHandler.RecordHandle;
...
// from here on you use the '_recordStream' like normal
...
// to stop recording just call
_recordHandler.Stop();
_recordHandler.Dispose();
_recordHandler = null;
...

Bello

  • Posts: 30
Re: BASS.NET API 2.4.1.2
« Reply #505 on: 29 Jul '08 - 15:04 »
Thanks!
I'm going to try this right away!

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.2
« Reply #506 on: 6 Aug '08 - 10:08 »
hello radio 42

when you use bass_video 2.4.2 which convert video .

thanks .


radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.2
« Reply #507 on: 10 Aug '08 - 10:26 »
It will come in the next days (as I just returned from a short business trip)...

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.2
« Reply #508 on: 11 Aug '08 - 06:00 »
oh . you happy me . very thanks . :D :D :D :D

radio42

  • Posts: 4573
BASS.NET API 2.4.1.3 beta
« Reply #509 on: 15 Aug '08 - 10:50 »
Hi All,

a pre-version of BASS.NET v2.4.1.3 is ready to download here:
www.un4seen.com/filez/4/Bass24.Net_pre.zip

It should now be compatible with:
BASS_video v2.4.1.2
BASS_vis v2.4.1.2
BASS_FX v2.4.1.1

Please report any doggieness, if you found any stuff.

NOTE:
This version already contains support for BASS_FX v2.4.1.1 (which is not yet released).
In BASS_FX v2.4.1.1 the BFX_COMPRESSOR structure has been changed, as Ian and Jobby have implemented a brand new compressor.
So if you are using a BFX_COMPRESSOR in your tests, just let me know and I can provide you with a pre BASS_FX v2.4.1.1. version.

Many Greets
Bernd

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.2
« Reply #510 on: 16 Aug '08 - 06:09 »
Hello Radio42 , I have a emergency question , i am sorry to ask you , please help me :

i wrote a app which works with all of encoder which bass.net can support , but some of them is realized under GPL ,  if i do not include encoder( such as enc_aacplus.dll), and my app can works without this encoder(for example for convert to aacplus need that dll) , can i use my app for commercial use , which Bass.net do(Download files Separately) , i am very sorry for use this forum  :-[, please help me    :-\ :-\

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.2
« Reply #511 on: 17 Aug '08 - 11:52 »
17.08.2008: Version 2.4.1.3 is out!

BASS_FX: updated to support v2.4.2.0
BASSvis: updated to support v2.4.1.2
BassVideo: updated to support v2.4.1.2
General: Utils.GetNormalizationGain made static


BASS.NET:
Full Install:
  www.un4seen.com/filez/4/Bass24.Net.zip

Lib only:
  www.un4seen.com/filez/4/Bass24.Net_update.zip

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.3
« Reply #512 on: 17 Aug '08 - 12:16 »
@ fullmm,
yes - that's what I guess.

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #513 on: 18 Aug '08 - 06:03 »
Radio42

Very Thanks

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #514 on: 30 Aug '08 - 14:22 »
Hello Radio42 ,
is it possible for you to create wrapper for spx and ITunes encoder in misc such as lame.exe encoder ? you can download encoders from rareware.org

 

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.3
« Reply #515 on: 30 Aug '08 - 20:43 »
iTunes can encoder in AAC and MP3 and there are already 4 class to support these formats:
- EncoderLAME (MP3)
- EncoderFAAC (AAC)
- EncoderNeroAAC (AAC)
- EncoderWinampAACplus (AACplus)
What are you missing here regarding iTunes?

Regarding SPX, you might implement the Speex encoer yourself using the encoder framework.
Simply derive your own encoder class from the "BaseEncoder". See the "BaseEncoder" class in the documentation on how to create your own derived encoder class.
Alternatively you might use the generic "EncoderCMDLN" class with SPX.

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #516 on: 31 Aug '08 - 06:28 »
Thank you :-\

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #517 on: 7 Sep '08 - 13:08 »
Hello radio 42

i got have a problem about twolame.exe encoder :

i use EncoderTwolame and i got true for the encoder but file will never created .i never get any error from BassError  ! ???

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.3
« Reply #518 on: 8 Sep '08 - 09:37 »
So probably some wrong settings or twolame version?
I have no idea what you are doing exactly, and without any sample code I can't help ;-)

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #519 on: 8 Sep '08 - 11:17 »
I have downloaded twolame.exe and use this code

         
Code: [Select]
  int EncodeStream = Bass.BASS_StreamCreateFile(@"E:\music\Other Music\01_ Deldari.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE);

Un4seen.Bass.Misc.EncoderTwoLAME Twolame = new Un4seen.Bass.Misc.EncoderTwoLAME(EncodeStream);
            Twolame.InputFile = null;
            Twolame.OutputFile = "sample.mp2";
            bool ok = Twolame.Start(null, IntPtr.Zero, false);//ok return true !
            Utils.DecodeAllData(EncodeStream, true);
???
i think you have forget many source code in Bass.net API , please review again.

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.3
« Reply #520 on: 8 Sep '08 - 13:06 »
So does this happen with all source files or only with some?
It seems, that I am unable to reproduce it here - as here all is working fine.
Which version of twoLame are you using?

Quote
i think you have forget many source code in Bass.net API , please review again.
I don't think, that there is any source code missing in the BASS.NET API.
So if you have any trouble with it please be exact and precise and tell me what you actually want or what you think is missing!

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #521 on: 8 Sep '08 - 13:13 »
Quote
Which version of twoLame are you using?
i use twolame.exe encoder from www.free-codec.com.

radio42

  • Posts: 4573
Re: BASS.NET API 2.4.1.3
« Reply #522 on: 8 Sep '08 - 14:00 »
On this site I can not find any "twolame" binary!
So maybe you should use the official build from here: http://www.rarewares.org/mp3-others.php  (as noted in the docs).

This is: twoLame 0.3.12b Release

It is a custom version that does NOT use libsndfile for input. It uses its own native input routines. It will accept 8, 16, 24, 32 bit integer and float wave files as input and will also accept input from 'stdin' - which was really the point in doing it.

I guess the version you are using doesn't support input from STDIN as it will certainly be using libsndfile for input.
I personally requested the change on rerewares.org in order to be able to use twoLame with BASS!

www.fullmm.com

  • Posts: 141
Re: BASS.NET API 2.4.1.3
« Reply #523 on: 8 Sep '08 - 14:15 »
Thank You very much , Worked  :P :) :)
Sorry.

ken

  • Posts: 739
Re: BASS.NET API 2.4.1.3
« Reply #524 on: 9 Sep '08 - 15:32 »
I wave a wired BASSasio / BASSmixer problem.


** Solved...
« Last Edit: 9 Sep '08 - 15:46 by ken »