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

ken

  • Posts: 739
Re: BASS.NET API 2.4.9.0
« Reply #1100 on: 30 Jul '12 - 16:37 »
A Metro style app must use references to another .NETCore or Portable Library binary only...it can NOT reference a full .NET 4.0

Thanks Bernd,

I try to build my own DllImport wrapper. Init returns true, but I get Error 20 on CreateStreamURL. This is how I did, and I need your expert advice...

Code: [Select]

[DllImport("bass.dll", CharSet = CharSet.Unicode)]
public static extern bool BASS_Init(int device, int freq, int flags, int win, [MarshalAs(UnmanagedType.AsAny)] object clsid);

[DllImport("bass.dll", CharSet = CharSet.Unicode)]
private static extern int BASS_StreamCreateURL(string url, int offset, int flags, [MarshalAs(UnmanagedType.AsAny)] object prog, int user);


Code: [Select]

   bool _ret = BASS_Init(-1, 44100, 0, 0, null);

    _stream = BASS_StreamCreateURL(url, 0, 0, null, 0);

    int _err = BASS_ErrorGetCode();

    BASS_ChannelPlay(_stream, false);





radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1101 on: 30 Jul '12 - 23:09 »
Have you tried using the BASS_UNICODE flag with your BASS_StreamCreateURL call?
Like this:
Code: [Select]
_stream = BASS_StreamCreateURL(url, 0, -2147483648, null, 0);

ken

  • Posts: 739
Re: BASS.NET API 2.4.9.0
« Reply #1102 on: 1 Aug '12 - 08:04 »
Have you tried using the BASS_UNICODE flag with your BASS_StreamCreateURL call?
Like this:
Code: [Select]
_stream = BASS_StreamCreateURL(url, 0, -2147483648, null, 0);

Thanks that works. I did some experiment and I can actually use Bass.Net.compact but I must use my own BASS_Init call...

Now the biggest problem with Windows 8 Metro is that when my app loses focus the sound is faded down by the OS, so I can't run it in background.  I haven't fond any docs on this yet.

LowEstring

  • Posts: 2
Re: BASS.NET API 2.4.9.0
« Reply #1103 on: 2 Aug '12 - 01:25 »
I was reading through the Bass.NET help page "Interoperating with Unmanaged Code", and the section on Callbacks and Delegates and there is this piece of information:

"A delegate is a class that can hold a reference to a method. But as a delegate is a class the same rules for garbage collection applies as for any other object - meaning delegates might a) be disposed (collected) or b) be re-located by the garbage collector!"

But in the example following that of how to use delegates the RIGHT way, point b) might still occur because the callback isn't pinned using GCHandle.Alloc as described earlier. Is this wrong?

I ask because I'm using callbacks in my app and wonder if I need to pin them so they aren't moved!

Thanks  :)


radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1104 on: 2 Aug '12 - 11:22 »
No, the internal (Bass).Net marshaling already handles that for you when dealing with callback delegates (pointers to methods).
So you don't have to pin those yourself.

It is enough/sufficient to keep a local reference to such callback delegate (e.g. within a regular member, as shown in the samples).

ken

  • Posts: 739
Re: BASS.NET API 2.4.9.0
« Reply #1105 on: 2 Aug '12 - 14:15 »
No, the internal (Bass).Net marshaling already handles that for you when dealing with callback delegates (pointers to methods).
So you don't have to pin those yourself.

It is enough/sufficient to keep a local reference to such callback delegate (e.g. within a regular member, as shown in the samples).

It could not be the garbage collector, when the my apps get focus again the playback continues. Windows 8 just fade down then playing audio when app is not showed and fades up the audio when I switch back to my app.  Note this is a "Windows Metro Style App" (C#), I have not tested a "normal" WinForm or WPF app.
« Last Edit: 2 Aug '12 - 14:19 by ken »

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1106 on: 2 Aug '12 - 14:33 »
I guess, that is a general Metro Style behaviour - which might be changed somewhere in the session settings.
Sounds pretty much like the iPhone bahaviour - to avoid, that multiple 'parked' apps are all playing together.

ken

  • Posts: 739
Re: BASS.NET API 2.4.9.0
« Reply #1107 on: 2 Aug '12 - 15:10 »
I guess, that is a general Metro Style behaviour - which might be changed somewhere in the session settings.
Sounds pretty much like the iPhone bahaviour - to avoid, that multiple 'parked' apps are all playing together.

Yes gues that to.  I found interface "IBackgroundTask", added that to my "AudioEngine" class, it worked once in background...  I Think I have to Google some more.


Kmaa

  • Posts: 21
Re: BASS.NET API 2.4.9.0
« Reply #1108 on: 3 Aug '12 - 22:15 »
Hello

I have a little error with this command

Code: [Select]
var libPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "binaries", Utils.Is64Bit ? "x64" : "x86");
LogFile.logMessage("Load Bass.Dll - " + libPath);

if (!Bass.LoadMe(libPath))
           LogFile.logMessage("--" + Bass.BASS_ErrorGetCode());
if (!BassAsio.LoadMe(libPath))
           LogFile.logMessage("--" + BassAsio.BASS_ASIO_ErrorGetCode());



In x86 the Command "BassAsio.LoadMe(libPath)" equal "BassAsio.LoadMe()" and dont load the bassasio.dll
In x64 application, i havent this problem, and he load the good directory.


Best Regard
Kmaa

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1109 on: 6 Aug '12 - 09:29 »
Please check the content of your "libPath". It should contain the fully qualified path (absolute) and not a relative one.
E.g. try, if this works out:
Code: [Select]
var libPath = Path.Combine(Application.ExecutablePath, "binaries", Utils.Is64Bit ? "x64" : "x86");

luke

  • Posts: 19
Re: BASS.NET API 2.4.9.0
« Reply #1110 on: 6 Aug '12 - 17:37 »
A Metro style app must use references to another .NETCore or Portable Library binary only...it can NOT reference a full .NET 4.0 library because the Metro profile is not that large (and would fail store certification).
Bass.Net however needs to use the full .Net Framework for its internal C++/CLI marshaling.
As such Bass.Net can currently not be used to build Metro style apps.

Looking at the Marshal class, to me it seems that it is almost completely available in portable librarys:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal%28v=vs.110%29.aspx

Using unsafe code is also allowed, so I do not see a reason why it should not be possible to create a Bass.NET PortableLibrary that will run on both "normal" .NET 4.0 (or 4.5) and on Metro apps. Is there any specific stuff that is missing? Be sure to uncheck windows phone / xbox and other stuff, and just select normal .NET and .NET for Metro apps when creating the portable library project in VS2012 RC.

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1111 on: 6 Aug '12 - 21:49 »
In general that might be possible, but I tend to first wait on the official release before I release yet another build (a Bass.Net version compiled against the new PortableLibrary mode).

However, the real issue with Metro-Style apps is a bit more complex.
See here: https://www.un4seen.com/forum/?topic=13135
and here: https://www.un4seen.com/forum/?topic=13753

Basically a metro-style app should use the new WinRT API - and as such every Win32 method should be replaced by a WinRT method.
This means bass.dll must be changed as well - so this is not only a pure Bass.Net task.

luke

  • Posts: 19
Re: BASS.NET API 2.4.9.0
« Reply #1112 on: 6 Aug '12 - 23:58 »
Right, bass.dll would probably need quite some changes to be WinRT compliant. File and stream access will need to be changed to new IO functions. Only WASAPI playback is allowed in WinRT, "normal" playback would need to be disabled on WinRT builds. Addons that use deprecated APIs such as the DirectSound effects, DirectShow, ASIO cannot be used by a certified application...

LowEstring

  • Posts: 2
Re: BASS.NET API 2.4.9.0
« Reply #1113 on: 23 Aug '12 - 02:56 »
This could well just be a .NET question, rather than bass specific...

I'm using Bass.NET to retrieve an image for the spectrum/visualizer every 25ms (I haven't got my code in front of me so I can't remember which method exactly) and I've noticed that my programs memory usage goes up very fast, to around 1GB then drops down again, repeat cycle about every 5 seconds. I've changed the code slightly to dispose of the old image immediately after setting the new one, and it solves the memory problem :), but I'd just like to understand the behaviour

Is the reason for the build up and drop off because the Garbage Collector hasn't done a sweep? While disposing it straight away causes it to be freed? Thanks!

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1114 on: 24 Aug '12 - 23:06 »
Yes, more or less.
An image within .Net is a kind of unmanaged resource and as such needs to be disposed explicitly.
As such it can be garbage collected much quicker.

HarryHar

  • Posts: 147
Re: BASS.NET API 2.4.9.0
« Reply #1115 on: 19 Sep '12 - 20:00 »
Hi,

Can anybody tell me why the resulting MP3 is completly silent. If I use the FlacEncoder all works well.

Code: [Select]
int channel = BassCd.BASS_CD_StreamCreate(driveNum, cddbTrack.TrackNumber-1, Un4seen.Bass.BASSFlag.BASS_STREAM_DECODE);

lameEncoder = new EncoderLAME(channel);
lameEncoder.InputFile = null; //STDIN
lameEncoder.OutputFile = "C:\\test.mp3";
lameEncoder.LAME_Bitrate = 320;
lameEncoder.LAME_Mode = EncoderLAME.LAMEMode.Default;
lameEncoder.LAME_TargetSampleRate = (int)EncoderLAME.SAMPLERATE.Hz_44100;
lameEncoder.LAME_Quality = EncoderLAME.LAMEQuality.Q0;
lameEncoder.Start(null, IntPtr.Zero, false);

while (Bass.BASS_ChannelIsActive(channel) != BASSActive.BASS_ACTIVE_STOPPED && !abort)
{
totalBytes += Bass.BASS_ChannelGetData(channel, buffer, dwBytes);
progressHandler(((float)totalBytes / (float)length), ref abort);
}

HarryHar

  • Posts: 147
Re: BASS.NET API 2.4.9.0
« Reply #1116 on: 19 Sep '12 - 22:08 »
When is a New version of Bass.NET planned? At the moment it is not working with the new BassFX dll (BPM functions)

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.0
« Reply #1117 on: 20 Sep '12 - 09:22 »
a) Sounds strange a quick test here revealed no problems.
What verison of Lame.exe are you using?

b) Next release is planned for tomorrow!

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.1
« Reply #1118 on: 20 Sep '12 - 17:18 »
Or today ;-)

20.09.2012: Version 2.4.9.1 is out!

BASS: added support for v2.4.9.6
BASS_FX: added support for v2.4.8.0
BASSMIDI: added support for v2.4.7.0
BASSOPUS: added support for v2.4.0.0
BASS_SPX: added support for v2.4.1.1
General:
  - Utils: Opus support added
  - Broadcast: new EncoderOPUS added
  - Broadcast: server ICEcast Opus support added
  - WaveForm: (De)Serialization bug-fix
Note:
  - the v4.0 version also supports the v4.5 .Net Framework

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

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


HarryHar

  • Posts: 147
Re: BASS.NET API 2.4.9.1
« Reply #1119 on: 20 Sep '12 - 20:02 »
I was using Lame v3.96.1, after I upgraded to a more recent version all is working perfect now.

Also thank you for the quick release of Bass.NET  :)

jdg2011

  • Posts: 18
Re: BASS.NET API 2.4.9.1
« Reply #1120 on: 21 Sep '12 - 01:04 »
@HarryHar LAME has the latest version of 3.99.2.5 and soon to release 3.100
http://lame.cvs.sourceforge.net/viewvc/lame/lame/doc/html/history.html?revision=HEAD

@Radio42, Excellent job on the spectrum FIX, Thank you very much :)

Thanks!

ViRUS2012

  • Posts: 21
Re: BASS.NET API 2.4.9.1
« Reply #1121 on: 21 Sep '12 - 04:19 »
The new update made wonders with the visualisation. I had to poke around with the Boost and Scaling factors to get them to my liking but they seem much more responsive now, and most important, the low frequencies reach the top!  ;D

PapaBearPW

  • Posts: 50
Re: BASS.NET API 2.4.9.1
« Reply #1122 on: 3 Oct '12 - 20:05 »
radio42,

Thanks for the new bass.net version!

I have a question. How can I set the samplerate for OPUS streams? For ogg I can use OGG_TargetSampleRate... but that option doesn't seem to exist for OPUS?

Actually, the same holds true for AAC, FLAC and WMA. None of them seem to have the TargetSampleRate option.

So, basically, I am just looking for the best way to set the samplerates for the various encoders which I am using to stream to shoutcast, icecast etc.

Thanks for any help.

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.9.1
« Reply #1123 on: 4 Oct '12 - 08:58 »
OPUS always uses 48kHz as the traget sample rate and performs resampling internally if necessary - so for OPUS this option doesn't exist.

The other encoders you mentioned also doesn't support any internal sample rate conversion (resampling).
Which means the encoders can only use the sample rate as the provided stream is having.
If you want to (re)encode an existing stream to a different sample rate, you must provide the encoder with resampled data yourself.

Doing so is easy, as you can use the BASSmixx add-on.
Create a mixer stream with the desired target sample rate and add your original stream as a decoding one to that mixer stream (as a source).
Then use the mixer stream for decoding.
BASSmix in that case performs the resampling for you.

The OGG encoder is the only encoder which natively supports resampling internally, that's why this encoder offers such option itself.

HarryHar

  • Posts: 147
Re: BASS.NET API 2.4.9.1
« Reply #1124 on: 4 Oct '12 - 09:00 »
Hi,

I just found out that the flag WaveForm.MARKERDRAWTYPE.NamePositionAlternate fails to work when you have 2 markers at the same position. Instead of drawinf the text at alternating positions, they are drawn at the same position. If I change the position of either one of the markers, they are drawn at alternating positions.

Is there a workaround for this problem?