Author Topic: BASSZXTUNE - chiptune support for BASS  (Read 16572 times)

ZXED

  • Posts: 38
BASSZXTUNE - chiptune support for BASS
« on: 15 Apr '14 - 15:18 »
Hello!

I want to introduce a new add-on to BASS audio library: BASSZXTUNE. This add-on adds a support for several chiptune/tracker module formats (including but not limited to ZX Spectrum AY/YM modules, Amiga/Atari/PC Engine tracker modules, SID, SAA1099, POKEY modules, NES, SNES, Game Boy, TurboGrafX music formats). The project is located at:

https://sourceforge.net/projects/basszxtune/

The add-on is based on ZXTune project (https://zxtune.bitbucket.io/). All the hard work (decoding functionality) is done by the author of ZXTune. BASSZXTUNE is basically just an interface to ZXTune core.

BASSZXTUNE supports the following extensions: $b, $m, ahx, as0, asc, ay, ayc, bin, cc3, chi, cop, d, dmm, dsq, dst, esv, fdi, ftc, gam, gamplus, gbs, gsf, gtr, gym, hes, hrm, hrp, hvl, lzs, m, msp, mtc, nsf, nsfe, p, pcd, psc, psf, psf2, psg, psm, pt1, pt2, pt3, s, sap, scl, sid, spc, sqd, sqt, st1, st3, stc, stp, str, szx, td0, tf0, tfc, tfd, tfe, tlz, tlzp, trd, trs, ts, usf, vgm, vtx, ym.

Limitations:
    - "Supported extensions" doesn't mean "supported formats". Some files with the above mentioned extensions may not be supported by BASSZXTUNE.
    - Buffered streams (STREAMFILE_BUFFER, STREAMFILE_BUFFERPUSH, etc) are not supported.
    - Streaming in blocks (BASS_STREAM_BLOCK) are not supported.
    - Internet streams (BASS_StreamCreateURL) are not supported.
    - Only mono and stereo output, no access to separate module channels.
    - The add-on supports only single-file formats. To play multi-file formats (e.g. *.minipsf + *.psflib) you may archive all files into any supported archive (zip, 7z, tar, gz, rar) optionally changing the extension of the archive to a supported extension (e.g. *.psf).

Supported platforms:
    - MS Windows i686 & x86_64 (tested on MS Windows 10 64-bit)
    - Linux i686 & x86_64 (tested on Kubuntu 16.10 Yakkety Yak 64/32-bit)
    - OSX x86_64 (tested on OSX 10.12 Sierra)
    - Android arm_v7a 4.0.3 and later (tested on Nexus 7 [2012] with Android 5.1.1 Lollipop & LG G2 with Android 4.4.4 KitKat)
    - Android i686 4.0.3 and later (tested on emulator)

Android support is only for native code, I mean I didn't test whether the library can be loaded from Java code or not.

You may find the latest version for your platform and the full changelog here:
https://sourceforge.net/projects/basszxtune/files/basszxtune/

The source code:
https://bitbucket.org/z80maniac/zxtune

Build instructions:
https://bitbucket.org/z80maniac/zxtune/src/master/apps/plugins/BUILD.TXT

I know, the file size of the library is ridiculously huge compared to the official add-ons, but I think it's worth it.

You may also be interested in a similar plugin for XMPlay:
http://www.un4seen.com/forum/?topic=16496.0
« Last Edit: 15 Jul '17 - 20:08 by ZXED »

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASSZXTUNE - chiptune support for BASS
« Reply #1 on: 16 Apr '14 - 17:19 »
Looks like some nice work :)

I'll add a link to your add-on on the BASS webpage.

Btw, if URLs aren't supported, then I think it would be best to omit the BASS_ZXTUNE_StreamCreateURL function to avoid any confusion about that.

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #2 on: 17 Apr '14 - 06:40 »
Thanks for adding the link to the add-ons page!

I'll try to implement BASS_ZXTUNE_StreamCreateURL in a next version.

Oleg N

  • Posts: 78
Re: BASSZXTUNE - chiptune support for BASS
« Reply #3 on: 3 Jul '14 - 12:33 »
Thanks for interesting add-on, will it support .SAP (Atari) files?

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #4 on: 4 Jul '14 - 15:25 »
As I stated before, BASSZXTUNE is just a wrapper. The actual sound library is libzxtune. You should ask the developer of ZXTune about new formats support.
You may try your luck posting your request here: https://bitbucket.org/zxtune/zxtune/issues?status=new&status=open

haspor

  • Posts: 19
Re: BASSZXTUNE - chiptune support for BASS
« Reply #5 on: 4 Jul '14 - 22:54 »
Hello,

excellent add-on, could you show an example how to use this on Android by using method
1) Use BASS_PluginLoad (recommended). I mean not only load the lib but also play a song.


Should it work so that after loading the plugin with BASS_PluginLoad and then using BASS_StreamCreateFile() it should recognize the new formats? I tried that and BASS_StreamCreateFile fails, even tho pluginload was success.

« Last Edit: 5 Jul '14 - 08:50 by haspor »

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #6 on: 5 Jul '14 - 09:15 »
Should it work so that after loading the plugin with BASS_PluginLoad and then using BASS_StreamCreateFile() it should recognize the new formats?

Yes it should, but I only tested it with C++. I didn't specifically target any other language (even Java). I attached a source file that I use to test the add-on. It's in C++ and using some Qt, but I hope it still may help.

I tried that and BASS_StreamCreateFile fails, even tho pluginload was success.

Can you provide more details? Source code, any error output / error codes, or at least the music file you try to open. Also note, that some formats cannot be opened even if their extensions are listed as supported. See the first post for details. The attached archive also contains a sample music file, try this one.

haspor

  • Posts: 19
Re: BASSZXTUNE - chiptune support for BASS
« Reply #7 on: 5 Jul '14 - 10:19 »
Hello,

Thanks for the code. I tried first with the sample file and it worked with my current code, the .cop file i tried to play was bad, actually, all the .cop files from Modland refused to play.

EDIT: just tested those .cop songs with zxtune itself and it can play them, maybe a small bug in this add-on, check it out. It's the Sam Coupé (COP) format.

EDIT: correction, BASS_ZXTUNE do play Sam Coupé files that contain the eTracker code at the beginning of the file, but the ones that doesn't have it, it refuse to play. Some lib have the eTracker binary included for cases like this . Would it be possible to get this fixed?
« Last Edit: 5 Jul '14 - 12:02 by haspor »

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #8 on: 5 Jul '14 - 12:26 »
I tried some *.cop files from ModLand. And it seems like even ZXTune can't handle some of them.

So I guess this case should be propagated to ZXTune project itself. There's not much I can do here.

You may file a bug report on ZXTune project site. I can do it by myself, but you probably can explain this problem better than me.

haspor

  • Posts: 19
Re: BASSZXTUNE - chiptune support for BASS
« Reply #9 on: 22 Aug '14 - 06:59 »
Hello,

would it be possible to get Android x86 build of this library?


ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #10 on: 23 Aug '14 - 13:52 »
Android i686 test build: http://sourceforge.net/projects/basszxtune/files/test/libbasszxtune-android-i686-20140823.7z/download

The library works fine on emulator. I'd appreciate if anyone could test this on a real device.

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #11 on: 29 Mar '15 - 09:14 »
The new version (v2.4.2) of BASSZXTUNE is out!

Major improvements: support for archived and packed formats, support for tags.

Downloads, details & full changelog:
https://sourceforge.net/projects/basszxtune/files/basszxtune/v2.4.2/

I'll try to implement BASS_ZXTUNE_StreamCreateURL in a next version.
I failed to implement it gracefully after all... BASS_ZXTUNE_StreamCreateURL is removed.

shakydd

  • Posts: 36
Re: BASSZXTUNE - chiptune support for BASS
« Reply #12 on: 30 Mar '15 - 14:33 »
Very nice, I got a simple sample working with VB.NET so thanks for this. Maybe the wrong place to ask this question - but I don't suppose anyone knows how to break down an .AY file in code (VB.NET), firstly to get the info out of it and also to break down any multiple 'tracks' contained within (as ZXTune does)?

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #13 on: 31 Mar '15 - 18:47 »
Currently, you can't do that with this add-on. In the next version I'll try to implement something that will let a user to retrieve the number of subtunes as well as their respective tags and lengths.

jbb666

  • Posts: 7
Re: BASSZXTUNE - chiptune support for BASS
« Reply #14 on: 1 Apr '15 - 07:19 »
Sorry for asking such a noob question, but is it possible to create an xmplay input plugin using basszxtune?

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #15 on: 2 Apr '15 - 08:01 »
It seems more appropriate to create a separate plugin for XMPlay using libzxtune. I'll see what I can do here.

UPDATE:
Plugin for XMPlay: http://www.un4seen.com/forum/?topic=16496.0
« Last Edit: 19 Apr '15 - 08:31 by ZXED »

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #16 on: 2 May '15 - 07:42 »
The new version (v2.4.3) of BASSZXTUNE is out!

Major improvement: you can now retrieve the info about a particular subtune inside a module (see "Archived formats and subtunes" section in README file for details).

Downloads, details & full changelog:
https://sourceforge.net/projects/basszxtune/files/basszxtune/v2.4.3/

shakydd

  • Posts: 36
Re: BASSZXTUNE - chiptune support for BASS
« Reply #17 on: 5 May '15 - 15:26 »
Fabulous, I'm excited about this. Probably a bit of a dumb question but any idea how I actually use the BASS_POS_ZXTUNE_SUB_COUNT or do I have to wait for this to be included in BASSMode?

haspor

  • Posts: 19
Re: BASSZXTUNE - chiptune support for BASS
« Reply #18 on: 5 May '15 - 15:59 »
excellent work,could you also make x86 build, thanks :)

EDIT: Android x86 that is.
« Last Edit: 5 May '15 - 16:02 by haspor »

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #19 on: 5 May '15 - 19:03 »
how I actually use the BASS_POS_ZXTUNE_SUB_COUNT
You should use it like this:
Code: [Select]
BASS_ChannelGetLength(<handle>, BASS_POS_ZXTUNE_SUB_COUNT) Of course, if you don't use provided *.h file you should declare BASS_POS_ZXTUNE_SUB_COUNT and other constants first. Look into the bottom of that *.h file for details. For example, BASS_POS_ZXTUNE_SUB_COUNT is 101 in hex (257 in dec).

could you also make x86 build
Unfortunately I can't make it to work yet. It builds correctly but when I use it, it crashes the application spontaneously upon starting a playback, and I can't figure out what's causing it. I'll investigate it more in the future, but currently there's no working android-i686 build.

shakydd

  • Posts: 36
Re: BASSZXTUNE - chiptune support for BASS
« Reply #20 on: 6 May '15 - 07:44 »
Got it, thanks a lot. I used BassMode.BASS_POS_OGG and BASSTag.BASS_TAG_OGG which seemed to do the same thing. Thanks again.
One thing I would say - can't seem to get the tags working from a subtune? Using Dim tag as IntPtr = Bass.BASS_ChannelGetTags(stream, BASS_TAG_ZXTUNE_SUB_OGG) gets the first tags fine. But using the MakeLong method and then using (say) Bass.BASS_ChannelGetTags(stream, MakeLong(BASS_TAG_ZXTUNE_SUB_OGG,1 (where 1 is the subtune) doesn't return anything?
« Last Edit: 6 May '15 - 08:19 by shakydd »

montoner0

  • Posts: 2
Re: BASSZXTUNE - chiptune support for BASS
« Reply #21 on: 28 Jul '15 - 01:53 »
Is there a way to disable some formats? I would like to use standard BASS capabilities for some file formats, like .xm, .it and such.

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASSZXTUNE - chiptune support for BASS
« Reply #22 on: 28 Jul '15 - 14:10 »
Do you want BASS to handle all MOD formats that it supports? If so, you can achieve that by trying BASS_MusicLoad first, something like this:

Code: [Select]
handle=BASS_MusicLoad(FALSE, filename, 0, 0, flags, 1);
if (!handle) {
handle=BASS_StreamCreateFile(FALSE, filename, 0, 0, flags);
if (!handle) ... // fail
}

montoner0

  • Posts: 2
Re: BASSZXTUNE - chiptune support for BASS
« Reply #23 on: 28 Jul '15 - 14:30 »
That's exactly how I'm using it. But the problem was when I've used code like this:
Code: [Select]
   if ((chan=BASS_StreamCreateFile(FALSE,(char*)fileurl,0,0,BASS_UNICODE)) ) {
     ...
   } else {
      if (!(chan=BASS_MusicLoad(FALSE,(char*)fileurl,0,0,BASS_MUSIC_STOPBACK|BASS_MUSIC_POSRESETEX|BASS_MUSIC_RAMPS|BASS_MUSIC_PRESCAN|_BASS_UNICODE,0)))
     ...
   }
ZXTUNE open files as streams and therefore override default BASS formats. For now I've just swapped StreamCreate and MusicLoad like you did.
But I want to know if there is more proper way.
« Last Edit: 28 Jul '15 - 14:36 by montoner0 »

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #24 on: 30 Jul '15 - 22:01 »
can't seem to get the tags working from a subtune?
Can you give me a link to the file?

Is there a way to disable some formats?
No. I think that trying BASS_MusicLoad before BASS_StreamCreateFile is the only appropriate way at this moment. In the next version I'll probably try to disable the support for the formats that overlap with BASS-native formats. However, I'm not sure if it's 100% possible.


ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #25 on: 15 Nov '15 - 09:53 »
The new version (v2.4.4) of BASSZXTUNE is out!

Major improvements:
    - new formats: NSF, NSFE, GBS, SAP, HES, VGM, GYM, AHX
    - seek speed was increased dramatically for some formats
    - Android i686 build

Downloads, details & full changelog:
https://sourceforge.net/projects/basszxtune/files/basszxtune/v2.4.4/

In the next version I'll probably try to disable the support for the formats that overlap with BASS-native formats.
This is not implemented yet.

Dhry

  • Posts: 64
Re: BASSZXTUNE - chiptune support for BASS
« Reply #26 on: 11 Dec '15 - 23:13 »
Is there a way to make this work with the 1by1 player? I extracted basszxtune.dll and basszxtune.lib into the 1by1 folder but it just crashes the player. Usually you can just extract a BASS extension into the folder and it will work fine by extending bass.dll automatically.

Cheers
DRS

haspor

  • Posts: 19
Re: BASSZXTUNE - chiptune support for BASS
« Reply #27 on: 15 Dec '15 - 09:18 »
The new version (v2.4.4) of BASSZXTUNE is out!

Major improvements:
    - new formats: NSF, NSFE, GBS, SAP, HES, VGM, GYM, AHX
    - seek speed was increased dramatically for some formats
    - Android i686 build

Downloads, details & full changelog:
https://sourceforge.net/projects/basszxtune/files/basszxtune/v2.4.4/

In the next version I'll probably try to disable the support for the formats that overlap with BASS-native formats.
This is not implemented yet.


outstanding job :)

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #28 on: 20 Dec '15 - 14:25 »
I extracted basszxtune.dll and basszxtune.lib into the 1by1 folder but it just crashes the player.

Weird. Judging by the debug output, the crash happens outside of the plugin, before the plugin is even loaded. It seems like 1by1 can't load the plugin because of some binary incompatibility or something like that. Also, 1by1 provides no logs nor error messages, so I can't effectively locate the source of the problem. I tested the plugin with another music player - AIMP, and they work fine together. Currently, I have no idea why the plugin doesn't work with 1by1.

BTW, *.lib files are only needed for development, you don't have to copy these files alongside *.dll.

Jfarro

  • Posts: 33
Re: BASSZXTUNE - chiptune support for BASS
« Reply #29 on: 5 Jan '16 - 09:46 »
I'm working on a Windows UWP app using Bass, and was looking at adding .nsf and SID support.  This library looks like a much better avenue than my other plan (trying to shim in FMod somehow and then programmatically alter).

How tough would it be to have this work with a windows UWP app? I'm willing to help where I can.

Dhry

  • Posts: 64
Re: BASSZXTUNE - chiptune support for BASS
« Reply #30 on: 5 Jan '16 - 16:37 »
Weird. Judging by the debug output, the crash happens outside of the plugin, before the plugin is even loaded. It seems like 1by1 can't load the plugin because of some binary incompatibility or something like that. Also, 1by1 provides no logs nor error messages, so I can't effectively locate the source of the problem. I tested the plugin with another music player - AIMP, and they work fine together. Currently, I have no idea why the plugin doesn't work with 1by1.

No worries ZXED, thanks for looking at it. I might post on the 1by1 forum and see what they say about it.

Cheers
DRS

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #31 on: 5 Jan '16 - 17:23 »
How tough would it be to have this work with a windows UWP app?

I'll look into it and contact you via PM when I have any ideas. Also, do you have a fully working UWP example (project source code) that uses some other BASS add-on? That could be a great help for me since I have no experience with UWP projects.

Jfarro

  • Posts: 33
Re: BASSZXTUNE - chiptune support for BASS
« Reply #32 on: 10 Jan '16 - 21:23 »
I do have Bass for Windows phone working, along with Midi support.  There were some changes Ian I believe had to do to Bass to use the Storage API's for file loading..and when I consumed them I had to use Task.Run to do loads on a background thread. Other than that I have the Midi addon working quite well with soundfont support and such.

Jfarro

  • Posts: 33
Re: BASSZXTUNE - chiptune support for BASS
« Reply #33 on: 20 Jan '16 - 11:52 »
(PLEASE SEE EDIT BELOW)
ZXED followed up with me and let me know that he tested it...and this just worked! I wanted to share this with any other fellow UWP windows developers.  I've also verified it in my app..the integration was really smooth.  This is for x64/x86...I'll work to compile it for Arm and see if I can get that working as well.

Thanks a ton ZXED for sharing this with the community...tonight I got to hear some of my favorite c64 tunes (Legacy of the ancients and the Koronis Rift theme) in an app that I'd put together with help from your library!

EDIT: While this did indeed compile and run, it does not currently pass store certification.  There are a number of MSVCRT api's which are called which the store does not allow. I'll see if I can help ZXED out and if we can get this working.
« Last Edit: 20 Jan '16 - 22:50 by Jfarro »

ZXED

  • Posts: 38

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #35 on: 30 Oct '16 - 09:04 »
The new version (v2.4.5) of BASSZXTUNE is out!

This version has undergone a huge rewrite and all constants BASS_POS_ZXTUNE_*, BASS_TAG_ZXTUNE_* and other constants and their usage have been changed! See README file for more details if you use any of these constants. Hopefully, there will be no such major changes from now on.

Major improvements:
    - new info can be retreived via tags: number of frames, loop frame, additional module strings (e.g. samples/instruments names) and more;
    - ability to set maximum allowed file size (can be somewhat useful on mobile devices with limited processing power), current max file size has been changed to 2 MiB;
    - fixed some crashes on Android.

Downloads, details & full changelog:
https://sourceforge.net/projects/basszxtune/files/basszxtune/v2.4.5/

The project source code has been moved to:
https://bitbucket.org/z80maniac/zxtune

Previously the source code was split between SourceForge and Bitbucket. Now all the source code is on Bitbucket. Also, now you can find clear instructions on how to build the add-on yourself:
https://bitbucket.org/z80maniac/zxtune/src/master/apps/plugins/BUILD.TXT
https://bitbucket.org/z80maniac/zxtune/src/master/apps/plugins/bass/BUILD.TXT

There will be no UWP version for now. May be in the next release. Also, there will be no corresponding XMplay plugin release because there were almost no changes in it since the last release.

ZXED

  • Posts: 38
Re: BASSZXTUNE - chiptune support for BASS
« Reply #36 on: 15 Jul '17 - 20:07 »
The new version (v2.4.6) of BASSZXTUNE is out!

Major changes:
    - default maximum file size is now 256 MiB

New supported formats:
    - PlayStation 1&2 Sound Format (PSF,PSF2)
    - Nintendo Ultra64 Sound Format (USF)
    - GameBoy Advance Sound Format (GSF)
    - HivelyTracker (HVL)

Known bugs:
    - Crash when opening compressed USF files on 64-bit Windows

Additional notes:
    - This release added support to PSF-like formats. These formats are usually multi-file, i.e. they need several files at once for a single tune (e.g. *.minipsf + *.psflib). BASSZXTUNE supports only single-file formats, but it supports archived modules. So, to play multi-file formats you may archive all needed files into any supported archive (zip, 7z, tar, gz, rar) optionally changing the extension of the archive to a supported extension (e.g. *.psf).
    - *.lib files for MSVC are no longer shipped inside the release archives. You can still use *.lib files from the previous versions or create them yourself.

Downloads, details & full changelog:
https://sourceforge.net/projects/basszxtune/files/basszxtune/v2.4.6/


Is there a way to disable some formats? I would like to use standard BASS capabilities for some file formats, like .xm, .it and such.
It turned out to be harder than I thought, so disabling formats will not be implemented. Instead you may use some hack to achieve the similar result. The add-on will not open any file if its filesize is bigger than the allowed filesize (BASS_CONFIG_ZXTUNE_MAXFILESIZE setting). So you may try the following:
Code: [Select]
DWORD oldVal = BASS_GetConfig(BASS_CONFIG_ZXTUNE_MAXFILESIZE);
BASS_SetConfig(BASS_CONFIG_ZXTUNE_MAXFILESIZE, 0);
BASS_StreamCreateFile(...);
BASS_SetConfig(BASS_CONFIG_ZXTUNE_MAXFILESIZE, oldVal);

Of course, to only disable BASS-supported formats, it's still easier to just call BASS_MusicLoad before BASS_StreamCreateFile.

There will be no UWP version for now. May be in the next release.
I decided to completely drop UWP version for the time being due to much complicated build and test processes. However, the project is open source, so anyone willing to try to make UWP version can fork the project here:
https://bitbucket.org/z80maniac/zxtune