Author Topic: BASS for Windows Store/Phone  (Read 40193 times)

Ian @ un4seen

  • Administrator
  • Posts: 20491
Re: BASS for Windows Store/Phone
« Reply #175 on: 19 Oct '17 - 17:17 »
That depends on whether you're using the BASSHLS add-on :) ... It was updated to the latest version.

cablehead

  • Posts: 315
Re: BASS for Windows Store/Phone
« Reply #176 on: 21 Oct '17 - 14:06 »
If you need a working wavewriter - you can rip from this codeproject link. Works great:
https://www.codeproject.com/Articles/525620/Recording-audio-to-WAV-with-WASAPI-in-Windows-Stor

Ian @ un4seen

  • Administrator
  • Posts: 20491
Re: BASS for Windows Store/Phone
« Reply #177 on: 3 Jan '18 - 15:58 »
The Windows Store version of the BASS 2.4.13 release is now up in the 1st post.

fxfletch

  • Posts: 22
Re: BASS for Windows Store/Phone
« Reply #178 on: 4 Jan '18 - 22:19 »
Hi,

I am just starting a new project that is a Windows Universal App, I have downloaded all the latest stuff to use with the store and am trying a simple test:

if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                // create a stream channel from a file
                int stream = Bass.BASS_StreamCreateFile("c:\\test.wav", 0, 0, BASSFlag.BASS_DEFAULT);
                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());
                }
            }

This exceptions on the stream create file method with:
System.Runtime.InteropServices.SEHException: 'External component has thrown an exception.'

Should it work with a Universal app?
Anything stupid I am doing wrong?

Ian

Ian @ un4seen

  • Administrator
  • Posts: 20491
Re: BASS for Windows Store/Phone
« Reply #179 on: 5 Jan '18 - 17:42 »
I don't think it is allowed for Windows Store apps to access the root C:\ folder. I get a Platform::AccessDeniedException when trying that here. Try putting the WAV file in your user "Music" folder (eg. "C:\Users\<username>\Music\") and playing it from there.

fxfletch

  • Posts: 22
Re: BASS for Windows Store/Phone
« Reply #180 on: 5 Jan '18 - 20:39 »
Thanks for the reply, I think its throwing the error before it even try's to access the file because I have tried moving it to different locations and also giving it a name that doesn't exist.
I always get this exception never any of the bass errors that I would expect if the file couldn't be found.

System.Runtime.InteropServices.SEHException occurred
  HResult=0x80004005
  Message=External component has thrown an exception.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

If I modify the code as below the first stream create all works its only when I try and create from a file that this happens.

                int stream1 = Bass.BASS_StreamCreate(44100,2, BASSFlag.BASS_SAMPLE_FLOAT, new BASSStreamProc()); // WORKS OKAY
                // create a stream channel from a file
                int stream = Bass.BASS_StreamCreateFile("C:\\Users\\Ian\\Music\\test.wav", 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // EXCEPTION
                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());
                }

Ian
« Last Edit: 5 Jan '18 - 20:56 by fxfletch »

fxfletch

  • Posts: 22
Re: BASS for Windows Store/Phone
« Reply #181 on: 6 Jan '18 - 22:33 »
After hours of messing about I discovered that it works if I run it in a task, so my function to play a file and return the stream ID now looks like this:
Code: [Select]
public int PlayFile(string file)
        {
            int stream = -1;
            Task.Run(() =>
            {
                stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT);
                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();
            return stream;
        }

This works perfectly, note this is a windows universal app.

Ian @ un4seen

  • Administrator
  • Posts: 20491
Re: BASS for Windows Store/Phone
« Reply #182 on: 8 Jan '18 - 17:31 »
Oh, right. BASS_StreamCreateFile/URL calls do indeed need to be made asynchronously (not in the main thread) on Windows Store, as noted in the first post :)