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

ZXED

  • Posts: 61
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, Game Boy, TurboGrafX, Sega, Nintendo 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 and the authors of numerous 3rd party libraries. BASSZXTUNE is basically just an interface to ZXTune core.

BASSZXTUNE supports the following extensions: $b, $m, 2sf, ahx, as0, asc, ay, ayc, bin, cc3, chi, cop, d, dmm, dsf, dsq, dst, esv, fdi, ftc, gam, gamplus, gbs, gsf, gtr, gym, hes, hrm, hrp, hvl, kss, lzs, m, mod, msp, mtc, nsf, nsfe, p, pcd, psc, psf, psf2, psg, psm, pt1, pt2, pt3, rmt, rsn, s, s98, sap, scl, sid, spc, sqd, sqt, ssf, st1, st3, stc, stp, str, szx, td0, tf0, tfc, tfd, tfe, tlz, tlzp, trd, trs, ts, usf, v2m, vgm, vgz, 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 v1909 64-bit)
    - Linux i686 & x86_64 (tested on Debian 10 Buster)
    - OSX x86_64 (tested on OSX 10.15 Catalina)
    - Android arm_v7a 4.1 and later (tested on LG G2 with LineageOS 17.1 [Android 10] armeabi-v7a)
    - Android i686 4.1 and later (tested on Android 10 emulator)
    - Android x86_64 5.0 and later (tested on Android 10 emulator)
    - Android arm64_v8a 5.0 and later (not tested)

Platform notes:
    - Android libs require dynamic linking to libc++ runtime (libc++_shared.so).
    - If you use a shared MSYS2 runtime in your project then you need to use "shared_runtime" library version from the distribution archive.

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:
https://www.un4seen.com/forum/?topic=16496.0
« Last Edit: 23 Aug '20 - 18:54 by ZXED »

Ian @ un4seen

  • Administrator
  • Posts: 26177
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: 61
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 the soundman

  • Posts: 97
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: 61
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: 61
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: 61
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: 61
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: 61
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: 61
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: 61
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: https://www.un4seen.com/forum/?topic=16496.0
« Last Edit: 19 Apr '15 - 08:31 by ZXED »

ZXED

  • Posts: 61
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: 61
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: 26177
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: 61
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.