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

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #700 on: 3 Jan '10 - 12:45 »
Hi Bernd, and Happy New Year!

Some ASIO stuff,

#1.

I have some in and out devices, and want to "route" input audio to an out channel (and use volume on the input, maybe some DSP)
I add my input like this:
Code: [Select]
_asioIn[InputIndex] = new BassAsioHandler(true, ASIOdev, ASIOchannel * 2, 2, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT, 44100); //Use 16 BIT otherwise the compressor don't work!
 _asioIn[InputIndex].Start(0);

And I can encode to MP3 with using the "_asioIn[InputIndex].InputChannel".  But I cant add  "_asioIn[InputIndex].InputChannel" to a BassMixer, to play it "out", just get noice.  How do I solv that?

Sure I can use:
Code: [Select]
_asioIn[InputIndex].SetFullDuplex(0, BASSFlag.BASS_STREAM_DECODE, true);  and add "_asioIn[InputIndex].OutputChannel;" to the mixer. 

But that will make me set ASIO buffer higher, else I get crackle sound, and my CPU load 10% (othervise 1-2%) AND the inputaddio is deleyed 5-10 seconds befor I hear it on output.



#2.
I have notised if I have BASSFlag.BASS_STREAM_AUTOFREE in BASS_Mixer_StreamAddChannel, I get an "poping" sound in the playbak when the sound I play is ended.

Now I use and it sound ok, just want to make sure it ok code:
Code: [Select]
BassMix.BASS_Mixer_ChannelRemove(_channel1);
BassMix.BASS_Mixer_StreamAddChannel(_Mixer, _channel1, BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_MIXER_BUFFER)
« Last Edit: 3 Jan '10 - 19:49 by ken »

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.0
« Reply #701 on: 4 Jan '10 - 08:29 »
Yes, you can not use the "BassAsioHandler.InputChannel" as a source to a mixer channel, as this is an internal dummy stream.

So you should/must actually call "BassAsioHandler.SetFullDuplex" and then use the "BassAsioHandler.OutputChannel" to add that to the mixer channel.
Note, that you should only set the 'buffered' parameter of the SetFullDuplex function to true, if your mixer channel is played out via BASS/DirectSound.
If your mixer is also a decoding channel being played via ASIO, then you should set the 'buffered' parameter to false - this wouldn't add any latency then.

The popping sound at the end when adding the AUTOFREE parameter sounds strange and doesn't seem to be related to the BassAsioHandler.
I am not sure what might cause this - but may be it is related to the MIXER_BUFFER flag?

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #702 on: 4 Jan '10 - 10:08 »
Thanks Bernd,

My problem with the 5-10 second delay, was that I did not add channel to mixer at the same time as I create the asioIn Handler and SetFullDuplex.  I simply solved that with:
Code: [Select]
BassMix.BASS_Mixer_ChannelSetPosition(_inputChannel, 0);
Another question, I want to fade out a channel the remove it from the mixer. I can du it like this but it's not a pretty solution, do you have any other suggestions?
Code: [Select]
  Bass.BASS_ChannelSlideAttribute(_inputChannel, BASSAttribute.BASS_ATTRIB_VOL, 0, 1000);
  Thread.Sleep(1000);
  BassMix.BASS_Mixer_ChannelRemove(_inputChannel);

/Ken

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.0
« Reply #703 on: 7 Jan '10 - 23:30 »
You might use -1 as the fading param in BASS_ChannelSlideAttribute - this will stop the channel when fading is done automatically - when the AUTOFREE flag was given when adding it to the mixer it will automatically be removed from the mixer.

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #704 on: 13 Jan '10 - 09:09 »

The popping sound at the end when adding the AUTOFREE parameter sounds strange and doesn't seem to be related to the BassAsioHandler.
I am not sure what might cause this - but may be it is related to the MIXER_BUFFER flag?

Bernd, I stil have a serious problem geting a "poping" sound when the mixer is removed (by autofree or by my code at sync event)

This is how I play the audio:

1. Create sound and add to mixer. The sound is paused to get better starttimes when playing over network.

Code: [Select]
BassMix.BASS_Mixer_ChannelRemove(_channel1);
// + some BASS_Mixer_ChannelRemoveSync
Bass.BASS_StreamFree(_channel1);

 _channel1 = Bass.BASS_StreamCreateFile(songcard.Filename, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
BassMix.BASS_Mixer_StreamAddChannel(_Mixer1, _channel1, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_STREAM_AUTOFREE);

2. Start play (release pause)

Code: [Select]
Bass.BASS_ChannelSetAttribute(_channel1, BASSAttribute.BASS_ATTRIB_VOL, _VolumeP1);
BassMix.BASS_Mixer_ChannelFlags(_channel1, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_MIXER_PAUSE);
Bass.BASS_ChannelSetPosition(_channel1, StartPos);

And when I have tree "channels" that I alter, each load and starts like above.


If I remove BASS_STREAM_AUTOFREE, the "poping" is gone, but then I can use "BassMix.BASS_Mixer_ChannelIsActive"  to get status...


Mixer created like this
Code: [Select]
_mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_MIXER_NONSTOP);


U use ASIO, and if I set buffesize to max (4096) then the "popping" is gone even with "AutoFree", but I want low latency (256-512) for input latency reasons.

/Ken

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.0
« Reply #705 on: 14 Jan '10 - 15:32 »
That really sounds strange to me as I cannot reproduce the issue you are heaving
have you tried if the problem is due to the NONSTOP mixer flag?

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #706 on: 14 Jan '10 - 16:26 »
That really sounds strange to me as I cannot reproduce the issue you are heaving
have you tried if the problem is due to the NONSTOP mixer flag?

My app does other things at the same time as I get "sync" from a stream that ends, but that is done in separate threads, and there is no poping when not relaseing a mixerchannel (manual or by autofree).

I get less "poping" if I don't use BASS_MIXER_NONSTOP.  I use BASS_MIXER_NONSTOP so the mixer don't stop woring, sice I add and remove streams and sometimes don't have any stream for the moment. Maybe I don't need that?

Is there any whay to set a higher buffer on a "streamchannel" without seting higher buffer on BassAsioHandler?

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #707 on: 14 Jan '10 - 16:44 »
Bernd,

I start playback like this today:
Code: [Select]
Bass.BASS_ChannelSetAttribute(_channel1, BASSAttribute.BASS_ATTRIB_VOL, _VolumeP1);
BassMix.BASS_Mixer_ChannelFlags(_channel1, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_MIXER_PAUSE);
Bass.BASS_ChannelSetPosition(_channel1, startCue.TotalSeconds);

But If U use only this, I get no popoing even at 128 in ASIO buffer
Code: [Select]
BassMix.BASS_Mixer_ChannelFlags(_channel1, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_MIXER_PAUSE);

But I need to set start position and volume, and some times I need fade in. Then I do like this:
Code: [Select]
Bass.BASS_ChannelSetAttribute(_channel1, BASSAttribute.BASS_ATTRIB_VOL, 0);
BassMix.BASS_Mixer_ChannelFlags(_channel1, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_MIXER_PAUSE);
Bass.BASS_ChannelSlideAttribute(_channel1, BASSAttribute.BASS_ATTRIB_VOL, _VolumeP1, (int)fadeInDuration.TotalMilliseconds);
Bass.BASS_ChannelSetPosition(_channel1, startCue.TotalSeconds);

leo2010

  • Posts: 21
Re: BASS.NET API 2.4.6.0
« Reply #708 on: 26 Jan '10 - 22:30 »
I am trying to use bass_dshow plugin from bass.net API. I could not understand why Bass.BASS_StreamCreateFile  gives me an invalid handle with error code BASS_ERROR_HANDLE.  Whenever  I use .AVI file I get invalid handle, when i use other audio only formats, I get a valid handle. It works in VB6 envrionment even with .avi files.

I am using BASS.NET API and I am loading the bass_dshow plugin. I am passing the name of the file to the Bass.BASS_StreamCreateFile function. Any ideas on what am i Missing ?

here is the code I am using could you let me know if  i am missing something

if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle))
            {
                MessageBox.Show(this, "Bass_Init error!");
                this.Close();
                return;
            }
           int status= Bass.BASS_PluginLoad("BASS_DSHOW.dll");
int stream= Bass.BASS_StreamCreateFile(filename, 0, 0, 0);

The stream returns 0 and the error code is BASS_ERROR_HANDLE. However i get valid stream if I use audio files.  Is this the right way to load a bass_dshow plugin   int status= Bass.BASS_PluginLoad("BASS_DSHOW.dll");


How come Bass.BASS_StreamCreateFile works fine in VB6 environment, but fails in .net environment when i load .avi files ?

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.0
« Reply #709 on: 27 Jan '10 - 08:33 »
See your other post: BASS_DSHOW isn't a real BASS plugin at the moment.
And such BASS_PluginLoad("BASS_DSHOW.dll") might actually fail.

Also note, that BASS.NET currently doesn't offer an API for DSHOW, as the state of the add-on is still pretty unstable and the API is changing very often.
But I guess it will be added very soon, whenever DSHOW becomes more mature.

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #710 on: 3 Feb '10 - 21:37 »
Bernd,

Can I with "BassTags.BASS_TAG_GetFromURL"  get if the internetradio is AAC+ or AAC ?  Now I get "BASS_CTYPE_STREAM_AAC" for both types of internetradio.

Here is some AAC+ stations http://dir.xiph.org/by_format/AAC+/
and here AAC  http://dir.xiph.org/by_format/AAC/

/Ken

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.0
« Reply #711 on: 3 Feb '10 - 22:22 »
As far as I can see, today it is not possible to differentiate between AAC and AAC+.

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.0
« Reply #712 on: 3 Feb '10 - 22:27 »
As far as I can see, today it is not possible to differentiate between AAC and AAC+.

Yes I see that now on my IceCast server.  "Content Type: audio/aacp"  no + ...

Thanks!

renzska

  • Posts: 22
Re: BASS.NET API 2.4.5.0
« Reply #713 on: 5 Feb '10 - 22:42 »
I noticed that Winamp v5.571 has a new version of the enc_aacplus.dll.  This does not seem to work with the current version of BASS.

I also noticed that the aacPlusCLI codeplex project has a new version: http://aacpluscli.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37963 which states the following:

Quote
Just a new build recompiled to match libraries included in Winamp 5.571.

Any chance we can get an updated enc_aacPlus.zip that works with this new version?

Thanks,

John

17.08.2009: Version 2.4.5.0 is out!

BASSenc: added support for v2.4.4.2
BASS_APE: added support for v2.4.0.4
BASS_MPC: added support for v2.4.1.0
BASSFLAC: added support for v2.4.0.3
BASS_AC3: added support for v2.4.0.2
BASS_ALAC: added support for v2.4.0.5
General:
  - some smaller Bug-Fixes
  - WaveWriter: new WriteNoConvert method added
  - WaveForm: some internal optimizations
  - Utils: DetectNextLevel method added and DetectCuePoints optimized
Breaking Changes:
  - EncoderWinampAACplus changed to support Winamp 5.33 or above enc_aacPlus.dll!
    Note: The AACPlus_* properties have been changed and you MUST use it with the latest Winamp enc_aacPlus.dll!


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

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

If you are using EncoderWinampAACplus make sure to also update:
  www.un4seen.com/filez/4/enc_aacPlus.zip



radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.0
« Reply #714 on: 6 Feb '10 - 10:18 »
Here is a new version which should incorporate all the latest changes_
- using the latest Winamp 5.57 "enc_aacPlus.dll" and "nscrt.dll"
- using libmp4v2.dll [from Winamp folder] for mp4/m4a writing instead of mp4box

Get it here:
  www.un4seen.com/filez/4/enc_aacPlus.zip

Let me know, if you fing anything

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.2
« Reply #715 on: 9 Feb '10 - 13:39 »
09.02.2010: Version 2.4.6.2 is out!

BASS: added support for v2.4.5.11
BASSmidi: added support for v2.4.5.0
BASSenc: added support for v2.4.6.2
BASSmix: added support for v2.4.3.2
General:
  - AddOn.Tags: bug-fix when reading ID3v2 unsychronization flags
  - Misc.BaseEncoder: new 'NoLimit' flag added

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

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


Also note, that a new version of enc_aacPlus.exe is available:
- using the latest Winamp 5.57 "enc_aacPlus.dll" and "nscrt.dll"
- using libmp4v2.dll [from Winamp folder] for mp4/m4a writing instead of mp4box

Get it here:
  www.un4seen.com/filez/4/enc_aacPlus.zip


ken

  • Posts: 739
Re: BASS.NET API 2.4.6.2
« Reply #716 on: 18 Feb '10 - 09:23 »
How should I set EncoderWinampAACplus for best sound on low bitrate.

I do like this now (have latest version of all DLL, and winamp dlls)

Code: [Select]

 EncoderWinampAACplus aac = new EncoderWinampAACplus(_audioChannel);
 aac.InputFile = null;
 aac.OutputFile = null;
 aac.AACPlus_Bitrate = 32;
 aac.AACPlus_High = false;
 aac.AACPlus_HE = true;
 aac.AACPlus_EnableParametricStereo = true;
               
               
 if (aac.EncoderExists)
 {
     _encoder = aac;
   
     ICEcast icecast = new ICEcast(_encoder, true);
     ...
     ...



 }


It sound good in WinAmp, but I can't play the stream in iPhone (type url in web browser that launch mediaplayer)

Now here is a stream in AAC 32k that sound even better in WinAmp, and that I can play in iPhone:  http://vis.media-ice.musicradio.com/CapitalV1.m3u

This stream also use IceCast, same cersion as I.

Any ideas?
 

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.2
« Reply #717 on: 18 Feb '10 - 09:36 »
I can't give you any special advices, but I guess you might also try the AACPlus_High setting and just play with the different settings until you find your best option.

ken

  • Posts: 739
Re: BASS.NET API 2.4.6.2
« Reply #718 on: 18 Feb '10 - 12:16 »
I can't give you any special advices, but I guess you might also try the AACPlus_High setting and just play with the different settings until you find your best option.

I have tried most combinations and those settings sounds best in WinAmp.

Do you know any other ACC+ encoder (lik stand alone software) that I can test, just for see where in the chain the problem is.

/Ken

inagy

  • Posts: 14
Re: BASS.NET API 2.4.6.2
« Reply #719 on: 18 Feb '10 - 12:22 »
Hi!

I have some Linux+Mono specific questions, but looks like there's noone in the Linux version's topic who can answer me. So i though about copying it here too. I hope it's not a problem.

Quote
I've started testing BASS on Linux using Mono and the BASS.NET assembly. Reading through the topic i could manage to play a simple mp3 file. Now trying to use bassenc to stream something to my IceCast server. I've tried the native cast example, everything was okay with it. From my project i try to feed the LAME encoder from a simple mp3 stream channel. Everything works fine, until i try to call the CastInit method. I get this error:
Code: [Select]
Unhandled Exception: System.DllNotFoundException: bassenc.so
  at (wrapper managed-to-native) Un4seen.Bass.AddOn.Enc.BassEnc:BASS_Encode_CastInit (int,string,string,string,string,string,string,string,string,int,bool)
  at testbass.MainClass.Main (System.String[] args) [0x00000]
As you can see, i've mapped the bassenc.dll to bassenc.so in the config file of Bass.Net.dll, the same way as i did with bass.so. I'm using the 64bit version of Ubuntu 9.10, i've placed the libraries into the lib64 folder, and after it didn't solve my problem, i've placed it near my mono exe file and launched mono with the LD_LIBRARY_PATH=".\" export. That also not worked.

I've seen that someone here managed to use bassenc on Linux. Could you help me what did i do wrong? Or is it a bug with the Bass.Net and x64 combination of bassenc? :-\

Thanks!

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.2
« Reply #720 on: 18 Feb '10 - 15:30 »
I am not aware of any bugs with Bass.Net nor with the x64 versions of BASSenc.
It simply looks like the bassenc.so can not be found. Is it in the same directory as the bass.so?
However, I am not using Linux myself, so maybe someone else might jump in...

inagy

  • Posts: 14
Re: BASS.NET API 2.4.6.2
« Reply #721 on: 18 Feb '10 - 19:45 »
Here's what i did.
I'm using MonoDevelop for coding, i have the latest BASS.NET dll (2.4.62) and Bass24-linux.zip packages. Unpacked libbass.so and libbassenc.so from the x64 folder into my /lib64 folder on my Ubuntu.
In the project i have added the reference to the BASS.NET assembly. Also created a Bass.Net.dll.config file near the assembly with the following content:
Code: [Select]
<configuration>
    <dllmap dll="bass.dll" target="bass.so" />
    <dllmap dll="bassenc.dll" target="bassenc.so" />
 </configuration>

Here's my code i like to test:
Code: [Select]
using System;
using Un4seen.Bass;
using Un4seen.Bass.AddOn.Enc;

namespace testbass
{
class MainClass
{
public static void Main(string[] args)
{
if (!Bass.BASS_Init(-1,44100,BASSInit.BASS_DEVICE_DEFAULT,IntPtr.Zero)) {
Console.WriteLine("OMG! Bass can't be inited.");
return;
}
Console.WriteLine("OK, bass inited!");

int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0,
                  BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
if (stream != 0 )
{
string com = "lame -r -s 44100 -b 128 -";
int encoder = BassEnc.BASS_Encode_Start(stream,com,BASSEncode.BASS_ENCODE_NOHEAD|BASSEncode.BASS_ENCODE_AUTOFREE,null,IntPtr.Zero);
if (encoder!=0) {
if (!BassEnc.BASS_Encode_CastInit(encoder,"localhost:8000/bass","hackme",BassEnc.BASS_ENCODE_TYPE_MP3,"","","","",null,128,false)) {
BASSError error = Bass.BASS_ErrorGetCode();
Console.WriteLine("Can't start streaming to IceCast server. Errocode: "+error);
}
} else {
Console.WriteLine("Failed to start encoder.");
}

Console.ReadLine();

if (encoder!=0) {
BassEnc.BASS_Encode_Stop(encoder);
}
}

Bass.BASS_Free();
}
}
}

Maybe BASSFlag.BASS_SAMPLE_FLOAT will be not okay for the encoder, but it should still start stream something, noise or so :)
I've also tried this:
- copy libbass.so and libbassenc.so to the same folder my builded .NET binaries are
- use this bash script to launch my program:
Code: [Select]
#!/bin/bash

export LD_LIBRARY_PATH="./"
mono testbass.exe

It works because it finds the main library, but not libbassenc.so.
I've tried also to change the map in the config file for libbassenc.so but i guess Mono automatically adds lib before the filename, else the mapping for libbass.so couldn't work.

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.6.2
« Reply #722 on: 18 Feb '10 - 22:55 »
As said, I am not using Linux myself, so i can not test, but I know that a couple of other Linux users BASS.NET and so far reported no problems.

inagy

  • Posts: 14
Re: BASS.NET API 2.4.6.2
« Reply #723 on: 19 Feb '10 - 12:30 »
No problem. ;) Hopefully some else has experience on how to setup Mono and Bass.NET correctly in details.

inagy

  • Posts: 14
Re: BASS.NET API 2.4.6.2
« Reply #724 on: 20 Feb '10 - 16:41 »
Today i had some time to try Bass again from scratch. This time worked with a GTK# project in MonoDevelop, tested the Compressor and DAMP effects what bassmix provides. I've read somewhere on the forums, that to ensure loading of extensions it's better call BassFx.LoadMe() or BassFx.BASS_FX_GetVersion() before doing anything else. From these calls the first one drops an exception on Mono: System.EntryPointNotFoundException: LoadLibrary, but if i preload the library with the second call, everything works as it expected.

I though about that i should try this with the streaming project i had problems before, but it didn't solve my problem.
For one more testing i've copied all the encoder related code into my GTK# project, and suprise, it worked. :o As far as i can tell there's no differences in the way i'm using Bass in those two projects, but very pleased that it finally works and streams as i wan't it to :)

Maybe later i can find out what made these differences.