BASS for Universal Windows Platform (UWP)

Started by Ian @ un4seen, 30 Jul '15 - 16:42

Ian @ un4seen

The WinStore version of the BASSHLS 2.4.2 release is up now in the 1st post.

Pavan Tiwari

Hi Ian,

Un4seen.Bass.AddOn.HLS namespace is not available in WinStore library (Bass.Net.WinStore.dll)

Ian @ un4seen

The issue is (or at least was last I heard) that Microsoft require all libraries that are referenced to be included in a submitted app, even if the libraries aren't actually used. So the WinStore BASS.Net version doesn't reference any add-on that can be used via the plugin system (BASS_PluginLoad), which includes the BASSHLS add-on. BASS.Net does still include those add-ons' flag/tag/etc definitions, just not the functions.

Karl Lai

Hi, recently we have found a file that we cannot play with our app, which uses Bass.Net.WinStore.dll. The audio is an aac file. Questions:
1. Does BASS support aac on Windows 10?
2. If it does, can you help us figure out why we cannot play the file? The file is from an Alexa skill from Yahoo weather news, and I put it on my one drive:
https://1drv.ms/u/s!AnZQvguMsHKMjW7_U4NlGFq6NBTu

Thank you very much!

Ian @ un4seen

BASS can make use of the AAC decoder that comes with Windows 10, so your example file should be playable. Are you having the problem with only that AAC file or all AAC files? Are other file formats (eg. WAV or MP3) playing OK?

Karl Lai

It's just this file from Yahoo, but the same file can be played by other software like browser or windows media player. Our app can play other type without issue, so we are wondering if there is some special setting for this file that BASS cannot accept. We also tried to play it from the original URL and it's the same result.

Ian @ un4seen

Are you only having the problem with WinStore BASS version? If you haven't already done so, please try the Win32 version too (eg. one of the pre-compiled examples in the C\BIN folder) and see if that works.

laishiekai

#232
Thanks for the quick reply. This is Karl Lai and I registered an account to continue this discussion.

I tired the win32 sample project and it works for my file. I will look into the example codes to see what we are missing. In our code, we use BASS_StreamCreateFileUser for this file because we stream it from the service, maybe this is the root cause? Maybe I should use BASS_StreamCreateFile?

Update: I found that we can read other aac file with BASS_StreamCreateFileUser. And I also found that the bad file somehow doesn't hit end of stream. This might be why BASS return BASS_ERROR_FORMAT as error. But why BASS_StreamCreateFile (from the win32 example) can play it without issue?

laishiekai

This is the length that passed into the PROC function for the bad file:
512, 1536, 2048, 2048, 2048, 8192, 49152, 196608, 262144, 524288
Comparing to the working one, the first few chunks seems to be the metadata or header. But then after that it looks like the PROC function stopped before loading the full length. I am not familiar how AAC format manage the chunks, does it really have a bad format, or it's just we are not using the right flags for this format?

Our call is like this: (works for most of the file except the one above)
Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_BUFFER, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_STREAM_BLOCK, STREAM_CALLBACKS, initializeStreamReadDataCallbackPointer);

Ian @ un4seen

I see what the problem is now. The file is actually an MP4 file and its "mdat" atom comes before its "moov" atom (basically the audio data comes before the description of it), which means it isn't streamable. It will be playable with BASS_StreamCreateFile or BASS_StreamCreateFileUser with system=STREAMFILE_NOBUFFER, but not BASS_StreamCreateURL or BASS_StreamCreateFileUser with system=STREAMFILE_BUFFER.

If you need to be able to stream that particular file, you can use MP4Box to fix it, like this: mp4box -isma <filename>

laishiekai

Quote from: Ian @ un4seen on 31 Oct '19 - 16:28I see what the problem is now. The file is actually an MP4 file and its "mdat" atom comes before its "moov" atom (basically the audio data comes before the description of it), which means it isn't streamable. It will be playable with BASS_StreamCreateFile or BASS_StreamCreateFileUser with system=STREAMFILE_NOBUFFER, but not BASS_StreamCreateURL or BASS_StreamCreateFileUser with system=STREAMFILE_BUFFER.

If you need to be able to stream that particular file, you can use MP4Box to fix it, like this: mp4box -isma <filename>

Thank you very much for looking into this!!

Ian @ un4seen

The WinStore version of the BASS 2.4.15 release is up now in the 1st post. Note support for Windows Phone 8 has been removed (it was dropped by Microsoft a while ago).

Ian @ un4seen

The WinStore version of the BASSmix 2.4.10 release is up now in the 1st post.

Ian @ un4seen

The UWP version of the BASSMIDI 2.4.13 release is up now in the 1st post.

Note that Windows 8 support has now been dropped. Only UWP is supported and the packages have been renamed accordingly, eg. from "bass-winstore" to "bass-uwp".

MARCOVLESMES

Hi, I'm try to play a Midi File in a UWP app without success. I'm getting a BASS_ERROR_FILEFORM error with all the Midi files I have try... I try to load an MP3 file (with BASS_StreamCreateFile function) and it play without problem. My code is:
Task.Run(() =>
{
                stream = BassMidi.BASS_MIDI_StreamCreateFile(file, 0, 1, BASSFlag.BASS_DEFAULT, 0);
                // stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT); // Commented MP3 test
                if (stream != 0)
                {
                    // play the stream channel
                    Bass.BASS_ChannelPlay(stream, false);
                }
                else
                {
                    // error creating the stream
                    Debug.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode());
                }
            }).Wait();

The files are in the same location, my Music folder. Appreciate your help

Ian @ un4seen

It looks like the problem there is the "length" parameter of the BASS_MIDI_StreamCreateFile call, which is set to 1. That should usually be set to 0 (like in the BASS_StreamCreateFile call). Perhaps you meant to put that 1 in the "freq" parameter?

MARCO LESMES

Thank for your reply Ian, now is working and loading the midi file but I'm getting an error with the BassMidi.BASS_MIDI_FontInit function, I'm getting an BASS_ERROR_FILEOPEN:
bool init = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

string file = "C:\\Users\\Marco\\Music\\test.sf2";

BASS_MIDI_FONT[] newfonts = new BASS_MIDI_FONT[1];
Task.Run(() =>
{
    int font = BassMidi.BASS_MIDI_FontInit(file);
    if (font != 0)
    {
         newfonts[0] = new BASS_MIDI_FONT(font, 0, 0);
    }
    else
    {
        // error creating the font
        Debug.WriteLine("Font error: {0}", Bass.BASS_ErrorGetCode());
    }
}).Wait();

I'm can't see what I'm missing here...  ???

Ian @ un4seen

If the file definitely exists then perhaps it's a permission issue, ie. your app isn't allowed to access the file. Is your app able to open the file using normal file methods, eg. StorageFile.OpenAsync?

MARCOVLESMES

Hi Ian, I test to open the file without problem with the OpenAsync function:

string path = "C:\\Users\\Marco\\Music\\test.sf2";
var file = await StorageFile.GetFileFromPathAsync(path);
var fileStream = await file.OpenAsync(FileAccessMode.Read);
Debug.WriteLine(fileStream.CanRead); // Returns True
           
BASS_MIDI_FONT[] newfonts = new BASS_MIDI_FONT[1];
Task.Run(() =>
{
     int font = BassMidi.BASS_MIDI_FontInit(path);
     if (font != 0)
     {
          newfonts[0] = new BASS_MIDI_FONT(font, 0, 0);
     }
     else
     {
          // error creating the font
          Debug.WriteLine("Font error: {0}", Bass.BASS_ErrorGetCode()); // Return BASS_ERROR_FILEOPEN
     }
}).Wait();
Can be some thing else?

Ian @ un4seen

Ah, I think I know what it is now. StorageFile.OpenAsync is used to read the file but the latest BASSMIDI also has a soundfont timestamp check that's using normal C APIs. Here's an update for you to try with that timestamp check skipped (it assumes the file is unchanged):

   www.un4seen.com/stuff/bassmidi-uwp.zip

Let me know if the problem still happens with that.

MARCOVLESMES

Hi Ian, is everything working now with the updated version. Thank you for your assistance!  ;D

Ian @ un4seen

Great! The BASSMIDI update is now included in the package in the 1st post.

BassPassion

I am having some problems streaming AAC stream, such as
http://ic7.101.ru:8000/p450978
http://ic4.101.ru:8000/stream/pro/aac/64/23


I have tried with the supplied Netradio UWP example, it's also having problems playing these.
HTTP/1.0 200 OK is all that is reported , but then it seems to hang.

VLC plays them without problems.

Any ideas?



Ian @ un4seen

That problem was introduced in the Windows 20H1 update (see this thread). A fix has been added for the next BASS release, which should be coming in early 2021. In the meantime, here's the latest build for you to try:

   www.un4seen.com/stuff/bass-uwp.zip

Please let me know if you see the problem still happening with that.

BassPassion

Quote from: Ian @ un4seen on 28 Dec '20 - 17:54That problem was introduced in the Windows 20H1 update (see this thread). A fix has been added for the next BASS release, which should be coming in early 2021. In the meantime, here's the latest build for you to try:

   www.un4seen.com/stuff/bass-uwp.zip

Please let me know if you see the problem still happening with that.

Yes, this seems to work much better. Thank you very much.