Author Topic: BASS for Universal Windows Platform (UWP)  (Read 173487 times)

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #50 on: 6 Oct '15 - 17:41 »
Oh yes, you're right, the sound does indeed stop when not running under the debugger. If I keep the example's existing playback and add BASS on top of it (ie. add to rather than replace MyBackgroundAudioTask.StartPlayback), then the BASS playback does also continue in the background, so I guess there's something somewhere in the example's code that's enabling the background sound. I'll try to find out what that is. Let me know if you find it in the meantime.

mcooper

  • Posts: 53
Re: BASS for Windows Store/Phone
« Reply #51 on: 7 Oct '15 - 10:19 »
Oh yes, you're right, the sound does indeed stop when not running under the debugger. If I keep the example's existing playback and add BASS on top of it (ie. add to rather than replace MyBackgroundAudioTask.StartPlayback), then the BASS playback does also continue in the background, so I guess there's something somewhere in the example's code that's enabling the background sound. I'll try to find out what that is. Let me know if you find it in the meantime.

Its the use of the BackgroundMediaPlayer class in the background task that enables the audio to continue in the background.  I assume you're using some other audio playback api from BASS?

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #52 on: 7 Oct '15 - 17:10 »
BASS uses WASAPI. The fact that the BASS playback does continue in the background if the example's playback code is retained alongside it seems to suggest that it's not the output system that's important. Perhaps BackgroundMediaPlayer is internally activating something to enable background playback, in which case perhaps it is also possible to activate that directly outside of BackgroundMediaPlayer?

Microsoft's documentation states that SystemMediaTransportControls is needed for background audio. I tried adding that to a little test app, but it didn't seem to enable background playback, so I guess there is more too it than that.

mcooper

  • Posts: 53
Re: BASS for Windows Store/Phone
« Reply #53 on: 8 Oct '15 - 11:43 »
BASS uses WASAPI. The fact that the BASS playback does continue in the background if the example's playback code is retained alongside it seems to suggest that it's not the output system that's important. Perhaps BackgroundMediaPlayer is internally activating something to enable background playback, in which case perhaps it is also possible to activate that directly outside of BackgroundMediaPlayer?

Microsoft's documentation states that SystemMediaTransportControls is needed for background audio. I tried adding that to a little test app, but it didn't seem to enable background playback, so I guess there is more too it than that.

You also need a background task with audio capabilities (as documented in that sample), but I left all that code in and it still didn't seem to work.

LeTonton

  • Posts: 3
Re: BASS for Windows Store/Phone
« Reply #54 on: 16 Oct '15 - 16:23 »
Hi mcooper and Ian @ un4seen, I search to adapt BackgroundMediaPlayer sample with BASS and i look this topic when i see that you search the same  :D But me for the moment I just try to run BASS in this progamm (just run, not necessarily in Background). It's possible to look your source code?

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #55 on: 16 Oct '15 - 17:34 »
There aren't any examples for Windows Store/Phone yet, but the BASS API (eg. BASS.H) is the same on all platforms, so you could have a look at the examples included in the Win32/Linux/OSX packages for some ideas. Probably the trickiest part for Windows Store/Phone is setting up the project, eg. to use the correct BASS.DLL version for each of the X86/X64/ARM architectures in a universal app. The best way I've found for that so far is to manually edit the project file in a text editor. For example, a "Universal Windows" app could have this in the project's VCPROJ file:

Code: [Select]
  <ItemGroup Condition="'$(Platform)' == 'x86'">
    <Content Include="<basspath>\Windows 8\x86\bass.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(Platform)' == 'x64'">
    <Content Include="<basspath>\Windows 8\x64\bass.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(Platform)' == 'ARM'">
    <Content Include="<basspath>\Windows 10\arm\bass.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

Replace "<basspath>" with the location of the BASS files. If you use any add-ons, you would add "Content" elements for them too. You may also need to add references to the Visual C++ runtimes as described in the 1st post, and BASS.Net if you're using that. In the case of a "Universal Windows 8.1" app, the modification could be made in the project's SHARED.PROJITEMS file instead, and "Windows 10" in the ARM platform's "Content" element should be replaced with "Windows Phone".

If you do use BASS.Net, be sure to call the BassNet.Registration function before you make any BASS function calls. You can get a "freeware" registration key for that from the BASS.Net website.

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #56 on: 29 Oct '15 - 17:56 »
A Windows Store version of the NETRADIO example has been added to the package in the 1st post. An updated BASS version is also up, which fixes a bug that would sometimes cause a crash when freeing an internet stream. This update also slightly changes the behaviour of the BASS_CONFIG_NET_AGENT/PROXY config options to support both ANSI and Unicode settings (see the 1st post for details).

Unknown

  • Guest
Re: BASS for Windows Store/Phone
« Reply #57 on: 1 Dec '15 - 00:52 »
Code: [Select]
  <ItemGroup Condition="'$(Platform)' == 'x86'">
    <Content Include="<basspath>\Windows 8\x86\bass.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(Platform)' == 'x64'">
    <Content Include="<basspath>\Windows 8\x64\bass.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(Platform)' == 'ARM'">
    <Content Include="<basspath>\Windows 10\arm\bass.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
I did it this way, but it doesn't work for me. Even a direct copy of bass.dll to the associated App directory is ignored. I always get this error:

Ausnahme ausgelöst: "System.DllNotFoundException" in Bass.Net.WinStore.dll
Ausnahme ausgelöst: "System.Exception" in Bass.Net.WinStore.dll
Ausnahme ausgelöst: "System.TypeInitializationException" in Bass.Net.WinStore.dll
The type initializer for 'Un4seen.Bass.Bass' threw an exception.

Any idea?

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #58 on: 1 Dec '15 - 15:26 »
Is your project for a "Universal Windows" app or a "Universal Windows 8.1" app? The project needs to be setup a bit differently in each case. The quoted block is for a "Universal Windows" app. If that is what you're creating, then first check that you have correctly replaced "<basspath>" with the full path of where you've extracted the BASS files. Also check that you have added a reference to the "Microsoft Visual C++ 2013 Runtime Package for Windows Universal" package.

Unknown

  • Guest
Re: BASS for Windows Store/Phone
« Reply #59 on: 1 Dec '15 - 15:46 »
Yes, it's an Universal App. The libs are in the Assets folder, so my project file looks like:
Code: [Select]
 <ItemGroup Condition="'$(Platform)' == 'x86'">
    <Content Include="Assets\libs\x86\bass.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Assets\libs\x86\Bass.Net.WinStore.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Assets\libs\x86\bassmidi.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Assets\libs\x86\bassmix.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
I also have added a reference to Microsoft Visual c++ 2015 Runtime for Universal Windows Platform Apps (i'm on Windows 10). A Replacement with the "full" path also doesn't have any effect.

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #60 on: 1 Dec '15 - 17:25 »
The x86/x64 BASS.DLLs use the VC++ 2013 runtime (they can be used on both Windows 8 and 10), so you will need to add a reference to that.

If shouldn't be necesary to add a "Content" element for the Bass.Net.WinStore.dll file; adding a reference to it (via the "Browse" option) should suffice.

Unknown

  • Guest
Re: BASS for Windows Store/Phone
« Reply #61 on: 2 Dec '15 - 01:10 »
Ok,

that solved the dll not found problem. But this one still remains:

Ausnahme ausgelöst: "System.Exception" in Bass.Net.WinStore.dll
Ausnahme ausgelöst: "System.TypeInitializationException" in Bass.Net.WinStore.dll
The type initializer for 'Un4seen.Bass.Bass' threw an exception.

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #62 on: 2 Dec '15 - 17:32 »
Are you calling the BassNet.Registration function before you make any BASS function calls? If not, please try that.

Unknown

  • Guest
Re: BASS for Windows Store/Phone
« Reply #63 on: 2 Dec '15 - 18:05 »
Ouh, so i need to register BassNet first!?

radio42

  • Posts: 4840
Re: BASS for Windows Store/Phone
« Reply #64 on: 3 Dec '15 - 09:05 »
I am not sure, if the "TypeInitializationException" is caused by not calling the registration...
Normally this exception is thrown in a 64-bit application when trying to load a 32-bit bass.dll.
So could this here be a similar issue? i.e. that you are using the 'wrong' bass.dll ?

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #65 on: 3 Dec '15 - 14:07 »
Ouh, so i need to register BassNet first!?

You can get a "freeware" registration key from the BASS.Net website for testing purposes.

LeTonton

  • Posts: 3
Re: BASS for Windows Store/Phone
« Reply #66 on: 7 Dec '15 - 13:42 »
Hi,
I'm totally lost.

I want use Bass.net.WinStore.

So i include my  reference Bass.Net.WinStore
I add this item on my file .csproj
<ItemGroup Condition="'$(Platform)' == 'x86'">
        <Content Include="Assets\libs\x86\Bass.Net.WinStore.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Assets\libs\x86\bassmidi.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
   
  </ItemGroup>

And in my program is write
using Un4seen.Bass;

And in my code

 BassNet.Registration(my email, my code);
            Bass.BASS_Start();
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 1); // enable playlist processing
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PREBUF, 0); // minimize automatic pre-buffering, so we can do it (and display it) instead
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_READTIMEOUT, 30000); // 30" stream timeout
            Bass.BASS_SetConfigPtr(BASSConfig.BASS_CONFIG_NET_AGENT, IntPtr.Zero);
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 5000); // 5 seconds buffer
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_BUFFER, 10000); // 10 seconds buffer

But i have exeption at the line Bass.BASS_Start(); because ddl is not found
'System.DllNotFoundException
Unable to load DLL 'bass.dll':

What should I do ?

radio42

  • Posts: 4840
Re: BASS for Windows Store/Phone
« Reply #67 on: 7 Dec '15 - 15:49 »
You always need the native libs as well - as such and the exception suggests, just place your bass.bll file into your binary output folder...

LeTonton

  • Posts: 3
Re: BASS for Windows Store/Phone
« Reply #68 on: 7 Dec '15 - 16:13 »
I place my bass.dll in all folder where bass.net.winstore.dll is present, but no result.

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #69 on: 7 Dec '15 - 17:50 »
So i include my  reference Bass.Net.WinStore
I add this item on my file .csproj
<ItemGroup Condition="'$(Platform)' == 'x86'">
        <Content Include="Assets\libs\x86\Bass.Net.WinStore.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Assets\libs\x86\bassmidi.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
   
  </ItemGroup>

Do you have a "Content" element for "bass.dll" too? If not, you need to add that. You don't need to have a "Content" element for "Bass.Net.WinStore.dll" though; you can just add a reference to it in your project instead.

Jfarro

  • Posts: 33
Re: BASS for Windows Store/Phone
« Reply #70 on: 9 Dec '15 - 09:53 »
Thanks for this library! I'm just getting up and running with it, and the documentation has been amazing.

Some quick notes for others that use this for windows store (It's in the thread, I just missed it)
1) If you're making a Universal Windows App, add the Bass.net.winstore in references
2) Then add the appropriate bass.net.dll....you should do this in your project file.  If you're testing and getting up and running...you can just add the dll to the project as 'content' and ensure it is set to 'copy if newer'
3) If you use Windows phone, add the win10 arm reference and the VS2015 reference. Otherwise add the win8 reference and appropriate architecture bass.net reference
4) If you get a badimageformat exception...then you mixed an x86 build with an x64 build...redo step 3
5) If you get a 'bass.net' can't be found error...check your output / debug folders and look for it..if it's there...ensure you've add the vs 2013/2015 reference
6) If you crash right away, ensure you're calling: Un4seen.Bass.BassNet.Registration with your email and registration info.  The help says it'll throw a splashscreen, but if you don't have that line you'll get a Typeinitialization exception.

With all of that done, I was on my way fairly quickly using the offline help and tutorials

Jfarro

  • Posts: 33
Re: BASS for Windows Store/Phone
« Reply #71 on: 9 Dec '15 - 10:00 »
Two questions as I work through this:

1) I'm not seeing the Bass.Misc namespace for windows store...I was hoping to play with the Visual object and such...any chance we could get that? or is it there and I'm missing it?

2) I'm having problems getting midis to play on win10 with Bass. I loaded up xmplayer and also didn't have audio till I loaded a soundfont.  So I went back into Bass, loaded the midi plugin, initialized a soundfont, and set the font. Below should be most of the relevant code (In mine I have a bunch that checks return values...everything is coming back with a valid handle, and the soundfont part returns 'true' for loading the font...

                Bass.BASS_PluginLoad("bassmidi.dll");
                Bass.BASS_Init(-1, 441000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
                int stream = BassMidi.BASS_MIDI_StreamCreateFile(@"Track3.mid", 0, 0, BASSFlag.BASS_DEFAULT, 0);
               // Setup sound fonts
                int soundFont = BassMidi.BASS_MIDI_FontInit("Setzer's_SPC_Soundfont.sf2");
                BASS_MIDI_FONT[] newfonts = new BASS_MIDI_FONT[1];
                newfonts[0] = new BASS_MIDI_FONT(soundFont, -1, -1);
                if (soundFont == 0)
                {
                    DebugOutput.Text += "Error loading soundfont!";
                }
                bool FontValue = BassMidi.BASS_MIDI_StreamSetFonts(stream, newfonts, 1);
                Bass.BASS_ChannelPlay(stream, false);

ChannelPlay returns true. SoundFont gets a handle of 1.  Yet I hear no audio. If I play it in xmplay...same midi, same soundfont, things work.  The soundfont and midi are renames of ones taken from this site.  Any ideas on what I'm missing?

radio42

  • Posts: 4840
Re: BASS for Windows Store/Phone
« Reply #72 on: 9 Dec '15 - 11:26 »
regarding 1) No, the Bass.Misc namespace is not included, as especially the visual stuff contained in it is not supported under WindowsStore. This is a Microsoft limitation they again added to their .Net implementation for Windows universal - so I guess you need blame MS for that ;-)

regarding 2) Looks okay for me, may be Ian knows more...?

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS for Windows Store/Phone
« Reply #73 on: 9 Dec '15 - 13:06 »
                newfonts[0] = new BASS_MIDI_FONT(soundFont, -1, -1);

When using all presets from a soundfont (preset=-1), the BASS_MIDI_FONT "bank" member is a base number that's added to the soundfont's bank numbers. So bank=-1 means that the soundfont's bank numbers are lowered by 1, eg. when a MIDI file requests bank 0, it will use bank 1 from the soundfont. You will probably want to do this instead:

Code: [Select]
                newfonts[0] = new BASS_MIDI_FONT(soundFont, -1, 0);

Jfarro

  • Posts: 33
Re: BASS for Windows Store/Phone
« Reply #74 on: 10 Dec '15 - 04:17 »
Thankyou!!  That fixed it.  Appreciate the quick and accurate reply.  And now I'm stoked to have it working :)

It's a shame the store apps don't support the stuff required for the Visuals namespace. I'll see what I can roll on my own using what's there.