How to use the BASS audio library in UWP development

The BASS audio library is a solid library to decode and play many audio formats, supports gapless playback (using the mixer, not used in this example) and equalizer (not used in this example).

The library is available also for Windows Store development.

To reference the BASS audio library in your UWP project remember to add conditional references based on platform in the csproj file

Let’s see how we can use the library in a background audio player.

First we need the background task. Here we initialize the BASS audio library, and free it when the task ends. Since we are going to use BASS only to decode the audio we can use the “no sound” device.

Now we need to play the file when the foreground app asks for it. Communication between the foreground app and the background task is made through messages.

When the background task receives a “file” request message it opens the file using BASS (we’ll see later how) and sets the media source of the bacgkround media player.

The BassMediaSource class implements IMediaSource and is the one responsible of opening and playing the file.

The code is quite simple: we need to create the decode stream for the BASS audio library and listen to the MediaSource events (Closed, Starting, SampleRequested).

The SampleRequested event occurs when then audio player needs a decoded sample to play. Here we just need to decode the requested data and return it to the player.

The application lets you select a file from your music library (files outside of your music library won’t work because the application does not have access to external folders).

Here’s the full source code of the test program (remember to set your BASS registration info)

Download source code

Have fun! 😉

GPD Win: Fix game crash in full screen through HDMI

Life is strange crashed during startup on my GPD Win when using HDMI output (I think I read about people having the same problem with other games).

After messing with the display settings I found a working configuration that I think might fix the same issue with other games.

Open the Intel display settings window and

  • Set the mode to Extended desktop and select your external monitor as the primary display
    My GPD Win screen went to portrait mode (rotation 0) but you can restore it by setting rotation to 270.
  • Set the display resolution to 1280×720 (it was 1920×1080 by default)
  • Done, you can play Life is strange 😉

GPD Win Keepalive version 1.0.0 released

I recently received my GPD Win, but it has a problem with the SD card reader: after a short period of time the SD card goes to a “sleep” state and it takes a couple of seconds to wake up.

This really is a problem when playing games (mainly emulator’s ROMS) so, waiting for a real fix, I made a small utility that keeps alive the SD card by just writing a 0 byte file to the SD card every X seconds. By doing this the SD won’t go to sleep. 😉

scr01

The utility can be set to autostart with Windows and stays in the tray.

You can download it here.

You can download the source code here.

Have fun! 😉

Midi2MP3Gui 1.0.0 released

Do you need to convert a MIDI file to MP3?
Do you need to mute a channel or want to change channels volume or the track’s tempo?

 

Download Midi2MP3Gui, you’ll have your MP3 in seconds. 😉