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

Ian @ un4seen

  • Administrator
  • Posts: 21024
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: 21024
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: 26
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: 21024
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: 26
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: 26
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: 21024
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 :)

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #183 on: 12 Feb '18 - 16:42 »
The Windows Store versions of the BASS 2.4.13.8 and BASSHLS 2.4.1.1 releases are now up in the 1st post.

fxfletch

  • Posts: 26
Re: BASS for Windows Store/Phone
« Reply #184 on: 13 Feb '18 - 22:18 »
Hi,

Am I correct in thinking that ASIO is not available on a Windows Store app yet I am using bass.net and can't see any of the namespaces?

Ian

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #185 on: 14 Feb '18 - 15:55 »
Yes, that is correct. I'm not sure it's possible to access ASIO drivers in Windows Store apps. Have you seen any Windows Store apps using ASIO?

fxfletch

  • Posts: 26
Re: BASS for Windows Store/Phone
« Reply #186 on: 14 Feb '18 - 16:02 »
I have seen at least one https://www.microsoft.com/store/productId/9NV01LCVXF1B

Claims to do ASIO

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #187 on: 15 Feb '18 - 18:05 »
I believe that app is actually using BASSASIO, and is using normal Windows APIs (Win32) rather than Windows Store APIs (Universal Windows Platform).

fxfletch

  • Posts: 26
Re: BASS for Windows Store/Phone
« Reply #188 on: 15 Feb '18 - 18:41 »
Ah so I might be misunderstanding something about the windows store version of the APIs. I thought I had to use those in order to be able to submit an app to the store. But that's obviously not the case.

Is this more about the fact that I am developing a UWP app? I thought I had no choice if I wanted to submit to the store, but perhaps I need to do a bit more research.

Ian

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #189 on: 16 Feb '18 - 15:48 »
Yeah, with all the different names/changes, it's a bit confusing. I think what was once called a "Windows Store app" is now a "Universal Windows Platform app". But then there are Windows 8 and Windows Phone 8 apps, which aren't UWP, so who knows :)

Anyway, Win32 apps can now be packaged in a way for Windows Store, using this:

   https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-run-desktop-app-converter

fxfletch

  • Posts: 26
Re: BASS for Windows Store/Phone
« Reply #190 on: 17 Feb '18 - 11:59 »
Thanks,

Yes I was looking at that but unfortunately I am taking advantage of some of the UWP features that wouldn't be available if I did that. Basically the only reason I wanted to use ASIO is to access the additional output channels available on professional sound cards. I think I will have to recommend that any customers that want to do that use an external driver that can expose a multi channel ASIO device as virtual sound cards.

Ian


Ehsan

  • Guest
Re: BASS for Windows Store/Phone
« Reply #191 on: 18 Jun '18 - 09:10 »
Hello.

I'm using BASS in a Windows Phone 8.1 project in a background task.

BASS Initialization:
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

Stream creation:
_bassHandle = Bass.BASS_StreamCreateFile(_filePath, 0, (long)_fileSize,  BASSFlag.BASS_STREAM_DECODE);
(also tried with BASSFlag.BASS_STREAM_8BITS)


Media Source creation:

...
_info = Bass.BASS_ChannelGetInfo(_bassHandle);
unit bits  = 16;
If (_info.Is32bit){ bits = 32;} else If (_info.Is8bit) { bits = 8;}

AudioEncodingProperties pcmprops  = AudioEncodingProperties.CreatePcm((uint)_info.freq, (uint)_info.chans, bits)
_source = new MediaStreamSource(new AudioStreamDescriptor(pcmprops));


Creating samples:

byte[] buf = new byte[4096];
int decoded  = Bass.BASS_ChannelGetData(_bassHandle, buf, buf.Length);
double secs = Bass.BASS_ChannelBytes2Seconds(m_BassHandle, decoded);
MediaStreamSample sample = MediaStreamSample.CreateFromBuffer(buf.AsBuffer(), TimeSpan.FromSeconds(_currentPosition));
...



The problem is that sound quality is noticeably worse compared to Windows Phone's own MediaPlayer object. There is a noticeable wheezing sound around singer's voice in multiple mp3 files I listened to, and that's just what I can hear.

Is there a catch here? What am I missing?

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #192 on: 18 Jun '18 - 13:22 »
From the use of the BASS_STREAM_DECODE flag, it looks like you are only using BASS for decoding of the MP3 file, not playback of it. Is that correct? If so, do you hear the same problem if you try having BASS handle playback too, by removing the BASS_STREAM_DECODE flag and calling BASS_ChannelPlay? Please also confirm what BASS version is being used by calling BASS_GetVersion.

Ehsan

  • Guest
Re: BASS for Windows Store/Phone
« Reply #193 on: 18 Jun '18 - 21:06 »
Yes, I am decoding the file and supplying it to WinRT through MediaStreamSource.SampleRequested() event handler, invoked when the framework requires a sample, which is the mechanism compatible with WinRT's BackgroundMediaPlayer.

So as you suggested I used:
_bassHandle = Bass.BASS_StreamCreateFile(_filePath, 0, (long)_fileSize, BASSFlag.BASS_DEFAULT);

And then called:
Bass.BASS_ChannelPlay(_bassHandle, false);

To play the channel, same result: the song is played, but there is a wheezing noise around relatively high human voices.

BASS_GetVersion returns 33819916.

Ehsan

  • Guest
Re: BASS for Windows Store/Phone
« Reply #194 on: 18 Jun '18 - 21:26 »
I may be able to help detect the issue if needed, I can create a Windows Phone sample project using both the built in player and BASS, with a sample mp3 so you can hear the difference if you need.
I'll be glad to help debug the problem if it solves the issue as my project depends on this library now. Let me know.

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #195 on: 19 Jun '18 - 15:00 »
The problem you're having sounds a lot like the one reported in this thread:

   www.un4seen.com/forum/?topic=18044

If so, the BASS 2.4.13.13 update in the first post should fix it. You're currently using 2.4.13.12. Please re-download to get the latest version and see if you still have the problem then.

Ehsan

  • Guest
Re: BASS for Windows Store/Phone
« Reply #196 on: 19 Jun '18 - 18:28 »
Hey Ian

Yes, that thread describes my problem perfectly.

I just checked, and I was using the latest version. I downloaded the library for the first time a few days ago, so it is unlikely I was using an outdated version.
Still, I downloaded the library again and referenced it, checked the bass.dll file's version (through the Windows properties dialog) and it indeed says 2.4.13.13. The problem still exists.

To be clear, I'm using the Windows Phone version and not the Windows 10 version of the library because my app is WinRT (targeting Windows Phone 8.1 and up) and not UWP. Are you sure the problem described in that thread was also fixed for the Windows Phone version of the bass.dll?

Ian @ un4seen

  • Administrator
  • Posts: 21024
Re: BASS for Windows Store/Phone
« Reply #197 on: 20 Jun '18 - 13:50 »
No, I didn't check the fix on Windows Phone. I will do that later today. The fix just involved a compiler update (no code changes), and I assumed it would fix the problem on all of the Windows Store platforms, but perhaps it didn't. In the meantime, can you try to reproduce the problem with the Windows 8 build (or Windows 10) too, to confirm whether the problem is only affecting the Windows Phone platform for you?

Ehsan

  • Guest
Re: BASS for Windows Store/Phone
« Reply #198 on: 20 Jun '18 - 17:07 »
Sure thing, I'll test the Windows 8 and 10 versions to see if the issue is still there. Will be back in a bit.

Ehsan

  • Guest
Re: BASS for Windows Store/Phone
« Reply #199 on: 20 Jun '18 - 22:35 »
I couldn't test the Windows 8 version because I was met with "could not find DLL 'bass': module not found" exception no matter what I did, but I can confirm the Windows 10 version plays smoothly on my laptop in a UWP app using BASS_PlayChannel, no problems there.

Hopefully you'll catch what it is that's affecting the Windows Phone version.