BASS for Universal Windows Platform (UWP)

Started by Ian @ un4seen,

Ian @ un4seen

Ah! I see now that BASS's MP4 tag reading hadn't been enabled in the Windows Store version :) ... An update with it enabled is now up in the 1st post.

ken

Quote from: Ian @ un4seenNote that the Windows Store APIs need to be used asynchronously, ie. not in the main/UI thread. So you will now need to call BASS_StreamCreateFile asynchronously. For example, something like this:

This update hasn't been tested much yet, so please report how you get on with it.


Just tested on the new Raspberry Pi 3 with latest build of Win 10 IoT, BASS works great. Here is working code in C# for playing a web stream. I'm using the Windows Store version of BASS.Net

Please note that the built in sound card on the Pi is very noisy.


private void PlayStream()
{
            BassNet.Registration("your_email", "_your_reg_code");  //You must have this else you get an error and it will not run!

            Bass.BASS_Init(-1, 44100, Un4seen.Bass.BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

 
            string _url = "http://stream.dbmedia.se/crr96";

            Task.Run(() =>
            {
                int handle = Bass.BASS_StreamCreateURL(_url,0, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);
                Bass.BASS_ChannelPlay(handle, false);
            });


        }

Lightning

to any Winstore/BASS developer-

I need some help with a Bass/Winstore issue.
In Debug mode, my app runs fine.  The problem is when I compile with the .net Native tool chain in Release mode all hell breaks loose
I have read every thread in help and the forum.
I think the issue is how .net tool chain is processing the bass .dlls
I am using six declarations from my program like this:
 // BASS_RecordInit
            [DllImport("bass.dll", ExactSpelling = true)]
            public static extern bool BASS_RecordInit(int device);
======================
however the compiler gives me these warnings for ALL uncalled functions:
1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x86\ilc\IlcInternals.targets(936,5): warning : ILTransform_0000:       MCG : warning MCG0006: Unresolved P/Invoke method 'BASS_SetDevice!bass.dll' in assembly 'Bass.Net.WinStore, Version=2.4.11.2, Culture=neutral, PublicKeyToken=8f2d676939c2ea9e' because it is not available in UWP applications. Please either use an another API , or use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP application APIs.
=====================
do all these need to be added as embedded resources under content?
bass.dll, bass.net.dll, bass.net.winstore.dll

Again, the baffling issue is that in Debug the App is fine.  .net tool chain compiles don't like something I did...

I appreciate JFarros explanation of how to set up an app, but if anyone else has the exact steps, perhaps I missed something...


Ian @ un4seen

Quote from: LightningI think the issue is how .net tool chain is processing the bass .dlls
I am using six declarations from my program like this:
 // BASS_RecordInit
            [DllImport("bass.dll", ExactSpelling = true)]
            public static extern bool BASS_RecordInit(int device);

Are you using "DllImport" to import BASS functions but also using BASS.Net? I don't think you need to bother with "DllImport" when using BASS.Net.

Quote from: Lightningdo all these need to be added as embedded resources under content?
bass.dll, bass.net.dll, bass.net.winstore.dll

You don't need bass.net.dll (I believe that's just for normal Windows), and I don't think the DLLs should be embedded resources. You should add a reference to bass.net.winstore.dll, and bass.dll (and any add-ons used) should be copied to the output directory, eg. like in this post:

   www.un4seen.com/forum/?topic=16665.msg119221#msg119221

I think another way to set that up is to use a "BeforeResolveReferences" target to copy the appropriate BASS DLLs for the target platform.

Jfarro

Ian, I may have a new bug...I'm trying to build in an EQ, and used the following:


 public int[] FXEQ = { 0, 0, 0 };

 private void SetBFX_EQ(int stream)
        {
            BASS_DX8_PARAMEQ eq = new BASS_DX8_PARAMEQ();
            FXEQ[0] = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0);
            FXEQ[1] = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0);
            FXEQ[2] = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0);
            eq.fBandwidth = 18f;
            eq.fCenter = 100f;
            eq.fGain = 0f;

            Bass.BASS_FXSetParameters(FXEQ[0], eq);
            eq.fCenter = 1000f;
            Bass.BASS_FXSetParameters(FXEQ[1], eq);
            eq.fCenter = 8000f;
            Bass.BASS_FXSetParameters(FXEQ[2], eq);
        }

When I call SetBFX_EQ on a valid stream, I get:

An unhandled exception of type 'System.PlatformNotSupportedException' occurred in Bass.Net.WinStore.dll

Additional information: Marshalling arbitrary types is not supported

Mod, Midi, getvalues, and other APIs work fine. I've tried this in both a Task.Run and outside of it, with no luck.  Any ideas?

Jfarro

with that build I get:

An exception of type 'System.EntryPointNotFoundException' occurred in Bass.Net.WinStore.dll but was not handled in user code

Additional information: Unable to find an entry point named 'BASS_GetCPU_' in DLL 'bass'.

I tried getting the latest Bass (24?) and updating the dlls that get copied locally with my app, but that didn't seem to help...do I need to update somewhere else that I'm missing?

radio42

I need to validate this with Ian - it looks those extra functions for the PocketPC verison are now missing within BASS?!

radio42

Sorry for the confusion, there was a bit of a misunderstandingbetween me and Ian and all his great versions ;-)

So here comes a new verison:
  www.un4seen.com/filez/4/Bass.Net.WinStore.zip

Jfarro

No worries, appreciate the quick responses.  That worked! Thanks, loving this library

Jfarro

Couple of questions for this library:

1) Is there a way to 'output' a stream to a file? I don't see BassEnc in the namespaces...wasn't sure if I'm missing the API for this, if it's possible, or if BassEnc would be needed (and if so, is that portable?)

2) I'm trying to find a way to access the instrument data for Music (mod/xm) files.  Which API should I be looking at for that?

Thanks in advance

Ian @ un4seen

Quote from: Jfarro1) Is there a way to 'output' a stream to a file? I don't see BassEnc in the namespaces...wasn't sure if I'm missing the API for this, if it's possible, or if BassEnc would be needed (and if so, is that portable?)

A Windows Store version of the BASSenc add-on isn't currently available, but the way BASSenc works is it sets a DSP function on the stream (via BASS_ChannelSetDSP) and then writes/encodes the data received by that. You could do the same sort of thing yourself, eg. open a file and write a WAV header to it, then set the DSP function on the stream to write the sample data, and finally update the length info in the header when you've finished writing. You could have a look at the WRITEWAV and RECTEST examples that are included in the Win32/Linux/OSX BASS packages as they are doing similar things.

Quote from: Jfarro2) I'm trying to find a way to access the instrument data for Music (mod/xm) files.  Which API should I be looking at for that?

By "data", do you just mean the instrument names/text? If so, that is available via the BASS_TAG_MUSIC_INST BASS_ChannelGetTags option. For example, something like this:

for (int a=0; ; a++) {
const char *inst=BASS_ChannelGetTags(handle, BASS_TAG_MUSIC_INST+a);
if (!inst) break;
printf("inst %d = %s\n", a+1, inst);
}

Jfarro

For the Mod data, what I'm looking for is what XMPlay shows when you select the "Mod Pattern Display" visualization.  This reminds me of what I used to see on Screamtracker back in the day, and is what I'm trying to replicate for my app.  I saw the instrument data come back from the APIs you mentioned...is the Mod pattern display data different?

Ian @ un4seen

Oh, right. I'm afraid BASS doesn't currently make the pattern data available. What you could do is use another library to load the pattern data, and then sync the display of that to the BASS_POS_MUSIC_ORDER position.

SFX_Bass

So if I'm right, it's not possible to use BASS_FX or BASSENC in Windows Store apps?  Recently demoed a project and a Windows Store version was requested as well, and my project relies on those two libraries as well.  I couldn't even write out a WAV file from an app in that case, right?  Is that a limitation of being an app?

Ian @ un4seen

I think the BASS_FX add-on should be fairly straightforward to port to Windows Store as it does not contain much platform-specific stuff, but the BASSenc add-on will be more complicated as a lot of it is platform-specific. If you only need BASSenc for WAV writing, then perhaps you could implement that yourself? You could set a DSP function on the source channel (via BASS_ChanelSetDSP) and then write the data to file in there. Or if the source is a "decoding channel" (using BASS_STREAM_DECODE), then you could just write the data that you receive from BASS_ChannelGetData to file.

SFX_Bass

Ah, awesome!  I could try to write the file encoding functionality myself, definitely.  Is a BASS_FX port something that is planned, then?  Or is it just something that should be simple to do?

Ian @ un4seen

I will check with the BASS_FX developer regarding a Windows Store port.

cablehead

#138
Winstore apps have several ways to record and output to almost any file type built in. Very easy.

These Windows functions do not work in a backgroundtask however. Its seems, tho that Bass is able to Init the micophone and start recording in a backgroundaudiotask. I have one working and sending bytes written to the output window, appears to be recording -  minimized/switched - but I have no way to write the .wav (yet) to prove it. And I still cannot get bass.dll onto a UWP10 phone...

(: JOBnik! :)

#139
Hi ;D

BASS_FX for Windows Store/Phone is ready:
http://www.jobnik.net/BASS_FX/bass_fx24-winstore.zip