Author Topic: BASS for iOS (iPhone/iPad)  (Read 436432 times)

Ian @ un4seen

  • Administrator
  • Posts: 19987
BASS for iOS (iPhone/iPad)
« on: 16 Feb '10 - 16:32 »
iOS versions of BASS and the BASSDSD/FLAC/MIDI/OPUS/WV/mix add-ons are available here:

   www.un4seen.com/stuff/bass24-ios.zip (updated: 16 May '17)

The BASSenc and BASSenc_OGG/OPUS add-ons are available here:

   www.un4seen.com/stuff/bassenc24-ios.zip (updated: 26 Jan '17)

The headers and documentation can be taken from the packages on the BASS page. The examples haven't been ported yet, but the BASS calls will be the same as on other platforms. If anyone would like to port any of the examples, that would be very welcome :)

These add-ons are also available:

   www.un4seen.com/stuff/bass_ape-ios.zip
   www.un4seen.com/stuff/bass_mpc-ios.zip
   www.un4seen.com/stuff/bass_tta-ios.zip
   www.un4seen.com/stuff/tags-ios.zip
   www.un4seen.com/files/z/0/bass_fx24-ios.zip

Note that BASS and the add-ons are provided as static libraries, because dynamic libraries aren't allowed on the iPhone. Both "device" (armv6/armv7/armv7s/arm64) and "simulator" (i386/x86_64) builds are supported (the linker will extract the appropriate code from the libraries). To include BASS in your project, the LIBBASS.A file should be added to the "Link Binary With Libraries" branch. You will also need to add the following frameworks to the project: AudioToolbox, SystemConfiguration, CFNetwork, Accelerate, CoreMIDI (if using BASSMIDI). The "Other Linker Flags" setting should also include "-lstdc++" when using BASS_FX or BASS_APE.

An "mp3-free" version (using the OS's MP3 decoder) is also included. Note that requires iOS 3 or above; it will run on earlier versions but MP3 support won't be available.

The plugin system is supported, but a little differently due to the lack of dynamic libraries. For example, if you want to load BASSFLAC and BASSWV as plugins, you can do so like this (after adding LIBBASSFLAC.A and LIBBASSWV.A to your project)...

Code: [Select]
extern void BASSFLACplugin, BASSWVplugin;
BASS_PluginLoad(&BASSFLACplugin, 0);
BASS_PluginLoad(&BASSWVplugin, 0);

There are also a few iOS-specific "audio session" BASS_SetConfig/Ptr options...

BASS_CONFIG_IOS_MIXAUDIO can be set to a combination of the following flags/bits: 1 = allow other audio to mix with the app's audio (enables kAudioSessionProperty_OverrideCategoryMixWithOthers), 2 = also "duck" the other audio (enables kAudioSessionProperty_OtherMixableAudioShouldDuck), 4 = use the "ambient" category (enables kAudioSessionCategory_SoloAmbientSound/AmbientSound instead of kAudioSessionCategory_MediaPlayback). The default setting is 1.

BASS_CONFIG_IOS_SPEAKER, when set to 1, sends the output to the speaker instead of the receiver (enables kAudioSessionProperty_OverrideCategoryDefaultToSpeaker). The default setting is 0 (off).

BASS_CONFIG_IOS_NOCATEGORY, when set to 1, disables BASS's audio session category management so that the app can handle that itself. The BASS_CONFIG_IOS_MIXAUDIO/SPEAKER and BASS_CONFIG_DEV_BUFFER settings will have no effect in that case.

BASS_CONFIG_IOS_NOTIFY can be used to set a callback function (IOSNOTIFYPROC) to receive interruption notifications from BASS's AudioSessionInterruptionListener.

When using AAC encoding (via BASS_Encode_StartCA), BASS_CONFIG_IOS_MIXAUDIO needs to be set to 0.

Support for use with .Net is included in the BASS.Net package.

Note: The output volume level was 6dB lower than on other platforms prior to version 2.4.8.10. If upgrading from an older version and you find that the level is now higher than wanted, the BASS_CONFIG_GVOL config options can be used to compensate.
« Last Edit: 23 May '17 - 14:49 by Ian @ un4seen »

ken

  • Posts: 733
Re: BASS for iPhoneOS
« Reply #1 on: 16 Feb '10 - 18:01 »
In there is any C# coders that use MonoTouch framework for developing iPhone apps, I'm happy to tell you that BASS for IPhone works with MonoTouch (yes you can link static libraries in MonoTouch). I can make a simple MonoTouch example if needed.

/Ken

ReymonARG

  • Posts: 41
Re: BASS for iPhoneOS
« Reply #2 on: 16 Feb '10 - 19:03 »
Nice Job, Next for BlackberryOS  ;)

ken

  • Posts: 733
Re: BASS for iPhoneOS
« Reply #3 on: 16 Feb '10 - 20:15 »
Nice Job, Next for BlackberryOS  ;)

Don't forget Android...

radio42

  • Posts: 4532
Re: BASS for iPhoneOS
« Reply #4 on: 16 Feb '10 - 20:20 »
A Bass.Net version for iPhone is comming soon...

StuC

  • Guest
Re: BASS for iPhoneOS
« Reply #5 on: 17 Feb '10 - 15:51 »

What the Licensing/Cost  of the iPhone version ?



Ian @ un4seen

  • Administrator
  • Posts: 19987
Re: BASS for iPhoneOS
« Reply #6 on: 17 Feb '10 - 16:59 »
Licensing is the same on all of the supported platforms. In the case of the Shareware licence, an amendment has been made primarily with the iPhone App Store in mind, whereby the product doesn't actually have to be shareware (eg. "try before you buy") but the price limit is lowered to 10 Euros then.

NeoStrider

  • Posts: 3
Re: BASS for iPhoneOS
« Reply #7 on: 23 Mar '10 - 22:00 »
I'm having a few issues with a adaptation of the net-radio example.
I`ve successfully adapted it to iPhone and it works fine on the simulator, but I cant seem to build it for the devices. Here is my error log:

Code: [Select]
ld: warning: in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/CFNetwork, missing required architecture arm in file
Undefined symbols:
  "_kCFStreamPropertyFTPFileTransferOffset", referenced from:
      _kCFStreamPropertyFTPFileTransferOffset$non_lazy_ptr in libbass.a(bass.o)
  "_kCFStreamPropertyHTTPShouldAutoredirect", referenced from:
      _kCFStreamPropertyHTTPShouldAutoredirect$non_lazy_ptr in libbass.a(bass.o)
  "_CFHTTPMessageAddAuthentication", referenced from:
      _BASS_RecordGetInputName in libbass.a(bass.o)
      _BASS_RecordGetInputName in libbass.a(bass.o)
  "_CFHTTPMessageCreateRequest", referenced from:
      _BASS_RecordGetInputName in libbass.a(bass.o)
  "_kCFStreamPropertyFTPFetchResourceInfo", referenced from:
      _kCFStreamPropertyFTPFetchResourceInfo$non_lazy_ptr in libbass.a(bass.o)
  "_kCFStreamPropertyFTPResourceSize", referenced from:
      _kCFStreamPropertyFTPResourceSize$non_lazy_ptr in libbass.a(bass.o)
  "_CFReadStreamCreateWithFTPURL", referenced from:
      _BASS_RecordGetInputName in libbass.a(bass.o)
  "_kCFStreamPropertyHTTPResponseHeader", referenced from:
      _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr in libbass.a(bass.o)
  "_kCFHTTPAuthenticationSchemeBasic", referenced from:
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in libbass.a(bass.o)
  "_kCFStreamPropertyFTPUsePassiveMode", referenced from:
      _kCFStreamPropertyFTPUsePassiveMode$non_lazy_ptr in libbass.a(bass.o)
  "_CFHTTPMessageCopySerializedMessage", referenced from:
      _BASS_RecordGetInputName in libbass.a(bass.o)
  "_kCFHTTPVersion1_1", referenced from:
      _kCFHTTPVersion1_1$non_lazy_ptr in libbass.a(bass.o)
  "_CFReadStreamCreateForHTTPRequest", referenced from:
      _BASS_RecordGetInputName in libbass.a(bass.o)
  "_kCFStreamPropertyFTPProxy", referenced from:
      _kCFStreamPropertyFTPProxy$non_lazy_ptr in libbass.a(bass.o)
  "_kCFStreamPropertyHTTPProxy", referenced from:
      _kCFStreamPropertyHTTPProxy$non_lazy_ptr in libbass.a(bass.o)
  "_CFHTTPMessageSetHeaderFieldValue", referenced from:
      _BASS_RecordGetInputName in libbass.a(bass.o)
      _BASS_RecordGetInputName in libbass.a(bass.o)
      _BASS_RecordGetInputName in libbass.a(bass.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

I really need this working ASAP, for a commercial project, please. BASS looks impressive and solved in hours what days of OGG ramblings couldn't help.
Have you guys used stuff only available in CoreServices?

Ian @ un4seen

  • Administrator
  • Posts: 19987
Re: BASS for iPhoneOS
« Reply #8 on: 24 Mar '10 - 16:17 »
That looks like it is linking with the wrong library version, eg. the "simulator" BASS when you're building a "device" application. I think the simplest way to avoid that problem is to just add both BASS library versions to the project.

edit: Actually, looking at it again (more closely this time!), that looks like it is linking with the wrong CFNetwork framework version, ie. the OSX version rather than the iPhone version? You could try removing that from the project, and then adding it again, eg. right-click on the project, select "Get Info", click the "+" button below the "Linked Libraries" list, and select "CFNetwork" from the list of frameworks.
« Last Edit: 24 Mar '10 - 17:43 by Ian @ un4seen »

NeoStrider

  • Posts: 3
Re: BASS for iPhoneOS
« Reply #9 on: 24 Mar '10 - 18:07 »
Nevermind...it was XCode fault...again...
Got everything working very well here.
Now is time to evaluate the licenses...
Thanks!

Bert

  • Posts: 176
Re: BASS for iPhoneOS
« Reply #10 on: 26 Mar '10 - 16:32 »
Do you want to share your working example with us?

Would be very nice!

NeoStrider

  • Posts: 3
Re: BASS for iPhoneOS
« Reply #11 on: 26 Mar '10 - 16:35 »
Its surprisingly the same as the macosx radio player. The only problem was removing the callbacks and handlers from Carbon Stuff. I still need to write a proper buffer manager, and then I promisse to give back to you something...

rdalton

  • Posts: 5
Re: BASS for iPhoneOS
« Reply #12 on: 6 Apr '10 - 04:45 »
Hi Ian,

The iPhone port is much appreciated.  Nice work!  I was just wondering if you are using the Tremor decoder (fixed-point Ogg decoder)?  If not, are there any plans to incorporate it sometime soon?

Thanks.

Robert

atatum1

  • Guest
Re: BASS for iPhoneOS
« Reply #13 on: 6 Apr '10 - 11:50 »
Is there a blackberry version as well please?

hippocoder

  • Posts: 14
Re: BASS for iPhoneOS
« Reply #14 on: 6 Apr '10 - 14:30 »
Does this work with the iPad?
« Last Edit: 6 Apr '10 - 15:16 by hippocoder »

Bert

  • Posts: 176
Re: BASS for iPhoneOS
« Reply #15 on: 6 Apr '10 - 15:37 »
Yes, i think it's working on the ipad.

hippocoder

  • Posts: 14
Re: BASS for iPhoneOS
« Reply #16 on: 6 Apr '10 - 15:38 »
Brilliant!

I want to deploy to windows, mac, iphone and ipad. I do have plans to use android and windows mobile but I think I will just have to recode those bits (bite the bullet) so to speak.

Ian @ un4seen

  • Administrator
  • Posts: 19987
Re: BASS for iPhoneOS
« Reply #17 on: 6 Apr '10 - 15:51 »
I was just wondering if you are using the Tremor decoder (fixed-point Ogg decoder)?  If not, are there any plans to incorporate it sometime soon?

The fixed-point OGG decoder is used in the WinCE version of BASS, but not the iPhone version, as the iPhone does have an FPU. I don't remember the numbers now, but I seem to recall finding that the fixed-point decoder wasn't faster on the iPhone.

Is there a blackberry version as well please?

I'm afraid there aren't any plans for that at the moment, but who knows in the future :)

sui

  • Guest
Re: BASS for iPhoneOS
« Reply #18 on: 22 Apr '10 - 14:19 »
Hi everybody,

I tried BASS for my iPhone application. It works very well but I have a problem...
When my iPhone locks screen, there is no more sound. I read Apple documentation, it seems that I should setup Audio sessions and set the AVAudioSessionCategoryPlayback category. But it has no effect.

Has anyone got this issue ?

Thanks a lot !

ken

  • Posts: 733
Re: BASS for iPhoneOS
« Reply #19 on: 22 Apr '10 - 17:40 »
Hi everybody,

I tried BASS for my iPhone application. It works very well but I have a problem...
When my iPhone locks screen, there is no more sound. I read Apple documentation, it seems that I should setup Audio sessions and set the AVAudioSessionCategoryPlayback category. But it has no effect.

Has anyone got this issue ?

Thanks a lot !

Try this code:

Code: [Select]
AudioSession.Category = AudioSessionCategory.MediaPlayback

sui

  • Guest
Re: BASS for iPhoneOS
« Reply #20 on: 23 Apr '10 - 08:17 »
I tried two things :

Code: [Select]
[[AVAudioSession sharedInstance] setDelegate: self];
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
NSError *activationError = nil; [[AVAudioSession sharedInstance] setActive: YES error: &activationError];

and
Code: [Select]
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,  sizeof (sessionCategory), &sessionCategory);

It works with AVAudioPlayer but not with BASS...

I tried your code but I can't compile it (is it Obj C code ?).

Thanks a lot !


sui

  • Guest
Re: BASS for iPhoneOS
« Reply #21 on: 23 Apr '10 - 10:08 »
Ok, I just fixed it...

Call

Code: [Select]
BASS_Init(-1,44100,0,NULL,NULL);

BEFORE

Code: [Select]
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,  sizeof (sessionCategory), &sessionCategory);

And not after... It's better !

Thanks :)

ken

  • Posts: 733
Re: BASS for iPhoneOS
« Reply #22 on: 23 Apr '10 - 11:49 »
Ok, I just fixed it...

Thanks :)


Good to hear, I don't code in Obj-C, I use Monotouch and code in C#, thats why my call didn't work right of.


Ian @ un4seen

  • Administrator
  • Posts: 19987
Re: BASS for iPhoneOS
« Reply #23 on: 23 Apr '10 - 16:55 »
BASS_Init sets the "audio session category" itself, so that will be why you are having to apply your settings after the BASS_Init call, rather than before it.

BASS currently uses the kAudioSessionCategory_AmbientSound setting, as that allows the system audio to continue in the background, eg. if the user wants to listen to their music while playing a BASS-based game. But it looks like that is now (since iPhoneOS 3.0) possible with the kAudioSessionCategory_MediaPlayback setting too, so an updated build that uses that setting is now in the iPhone package (see the 1st post).

sui

  • Guest
Re: BASS for iPhoneOS
« Reply #24 on: 27 Apr '10 - 08:59 »
BASS_Init sets the "audio session category" itself, so that will be why you are having to apply your settings after the BASS_Init call, rather than before it.

BASS currently uses the kAudioSessionCategory_AmbientSound setting, as that allows the system audio to continue in the background, eg. if the user wants to listen to their music while playing a BASS-based game. But it looks like that is now (since iPhoneOS 3.0) possible with the kAudioSessionCategory_MediaPlayback setting too, so an updated build that uses that setting is now in the iPhone package (see the 1st post).

Ok, thanks Ian, I understood why it did not work.