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

MikaelS

  • Posts: 198
Re: BASS for iOS (iPhone/iPad)
« Reply #100 on: 2 Dec '10 - 13:38 »
Thanks for the quick fix Ian! It seems to work fine (I have only been able to test it in the simulator so far, more tests will follow).
If some problem remains, I will report it here.


Thanks once again!

hudbrog

  • Posts: 3
Re: BASS for iOS (iPhone/iPad)
« Reply #101 on: 26 Dec '10 - 20:14 »
Hi! I'm kinda new to the whole BASS thing. Just wrote a sample application for iphone, which records sound from mic, applies some effects and plays it back. Now I'm wondering, is there a simple way to save my stream to file? To some format known to iOS, like caf or something?

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #102 on: 27 Dec '10 - 15:53 »
The next BASSenc release will include support for CoreAudio codecs on OSX and iOS. If you would like to try it now, the current build has been added to the iOS package (see 1st post). An updated BASSENC.H header is provided, which includes a BASS_Encode_StartCAFile function that accepts a file type (kAudioFileXXX), audio type (kAudioFormatXXX), and output filename. It also accepts a bitrate (bits per second), but that only applies to lossy formats like AAC (use "0" for the default bitrate).

For example, to create an ALAC M4A file, you could do this...

Code: [Select]
BASS_Encode_StartCAFile(handle, 'm4af', 'alac', 0, 0, filename);

Or for an IMA4/ADPCM CAF file...

Code: [Select]
BASS_Encode_StartCAFile(handle, 'caff', 'ima4', 0, 0, filename);

The "flags" parameter accepts BASS_ENCODE_FP_xxx, BASS_ENCODE_PAUSE, BASS_ENCODE_AUTOFREE, BASS_UNICODE, and a new BASS_ENCODE_MONO flag to convert the source data to mono (if it isn't already). Use BASS_Encode_Stop to close the encoder/file.

ken

  • Posts: 739
Re: BASS for iOS (iPhone/iPad)
« Reply #103 on: 27 Dec '10 - 16:42 »
The next BASSenc release will include support for CoreAudio codecs on OSX and iOS.

Now that is a welcomed feature. Ian, will it possible to encode to a IceCastServer ?

/Ken

hudbrog

  • Posts: 3
Re: BASS for iOS (iPhone/iPad)
« Reply #104 on: 27 Dec '10 - 20:36 »
Thanks Ian, worked like a charm.
Now I have another problem. When I tested a sample I mentioned before on simulator - everything worked great. But after I've installed it on iphone - volume of the sound is really low.
I've tried setting BASS_ChannelSetAttribute(chan, BASS_ATTRIB_VOL, 1.0f); and just BASS_SetVolume(1.0f); but nothing changed. Is there any way I could increase volume?

After some investigation - that only applies when I record something in the same time.
I.e. right now i have a recording channel, and a push stream, to which I push loud enough data. When I play data directly from that stream while still recording - volume is low.
If I just create a stream from the recording I've encoded with bassenc before(case #1 above) and play- volume is ok.

hudbrog

  • Posts: 3
Re: BASS for iOS (iPhone/iPad)
« Reply #105 on: 28 Dec '10 - 17:44 »
Just as an addition. This behavior is actually reproduced with native iPhone SDK, to get rid of it you just need to fire something like:
   UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
   AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,
                      sizeof(audioRouteOverride),&audioRouteOverride);
You get some artefacts when using headphones thou...

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #106 on: 30 Dec '10 - 16:15 »
Now that is a welcomed feature. Ian, will it possible to encode to a IceCastServer ?

That isn't possible with the current build, but it is something that I will be looking into.

keyClipse

  • Posts: 4
Re: BASS for iOS (iPhone/iPad)
« Reply #107 on: 5 Jan '11 - 19:58 »
Hi everyone,

 I have a problem in adding the plugin BASSMIX for iphone this is the error that I have got

Code: [Select]
  "_BASSMIXplugin", referenced from:
      _BASSMIXplugin$non_lazy_ptr in testBASSViewController.o
     (maybe you meant: _BASSMIXplugin$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

I have followed the first post instruction so I am wondering where I have gone wrong...



Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #108 on: 6 Jan '11 - 17:22 »
BASSmix isn't a plugin in the sense that BASSFLAC/etc is, ie. it can't be loaded via BASS_PluginLoad as it doesn't add support for additional file formats. To use the BASSmix functions in your app you just need to add the LIBBASSMIX.A file to your project.

DrummerB

  • Posts: 19
Re: BASS for iOS (iPhone/iPad)
« Reply #109 on: 11 Jan '11 - 17:06 »
Hi,

Does anyone know how to get the multitask remote controls to work with BASS?



Making BASS work in the background wasn't a problem, one simply has to add a key to the Info.plist file. However there are apps (Pandora) that can be controlled using the playback control buttons in the multitask bar, when they're in the background. I figured out that, if the app plays music using AVAudioPlayer, it's icon will automatically replace the iPod icon and it can subscribe to be notified when the user taps a button. However, I wasn't able to do the same thing with BASS.

Here are some examples, demonstrating this feature:
http://cl.ly/2af24504d26441d7f7ff
https://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html

ken

  • Posts: 739
Re: BASS for iOS (iPhone/iPad)
« Reply #110 on: 12 Jan '11 - 08:43 »
Hi,

Does anyone know how to get the multitask remote controls to work with BASS?



I'm looking for the same solution, also get the blue "play icon" in taskbar to show when running BASS. I think there is some events for the "remote controls" that can be subscribed to. I do use .NET and monotouch but the principle is the same.

DrummerB

  • Posts: 19
Re: BASS for iOS (iPhone/iPad)
« Reply #111 on: 12 Jan '11 - 13:52 »
Yes, you have to call
Code: [Select]
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];or something like that and implement the method
Code: [Select]
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent to handle those events. This works with AVAudioPlayer, but not with BASS. I guess Apple's audio frameworks have some hidden mechanism built in to notify the system that the app started playing music. One could probably fake some playback using an AVAudiPlayer and setting volume to 0, but that wouldn't be a very elegant solution.
I think the blue play icon will automatically be added to the status bar as soon as you were able to successfully set up the remote control buttons (those in the multitask bar).

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #112 on: 12 Jan '11 - 16:50 »
This came up before (off forum). As I recall, the enabling of kAudioSessionProperty_OverrideCategoryMixWithOthers (which allows the app's and device's audio to play together) was disabling the remote control events. To avoid that, kAudioSessionProperty_OverrideCategoryMixWithOthers can be disabled like this (before the BASS_Init call)...

Code: [Select]
#define BASS_CONFIG_IOS_MIXAUDIO 34
BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); // disable mixing

Let me know if it is still not working properly after that.

DrummerB

  • Posts: 19
Re: BASS for iOS (iPhone/iPad)
« Reply #113 on: 12 Jan '11 - 18:11 »
Thanks a lot Ian! That solved the problem. I read about that property somewhere and I tried to disable it, but didn't know BASS could do it. The only remaining issue is, that when the user taps the pause button, I have to pause the music using BASS_Pause(), because only pausing the single channel I'm using isn't enough. The audio frameworks must think BASS is still playing something, because the even though the channel is paused, the pause button doesn't turn into a play button and the little play icon in the status bar doesn't disappear. But I'm glad I found a workaround.
I'll probably post a sample project about this, when I have some time.

DrummerB

  • Posts: 19
Re: BASS for iOS (iPhone/iPad)
« Reply #114 on: 12 Jan '11 - 22:53 »
Okay, here is a sample app, demonstrating how to make BASS play back music in the background, and control playback with the multitask bar controls. Actually the app can also be remote controlled with some 3rd party iPhone accessories and speakers.

http://cl.ly/4513342M223M3v0s2Y3T

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #115 on: 13 Jan '11 - 17:43 »
The next BASSenc release will include support for CoreAudio codecs on OSX and iOS.

Now that is a welcomed feature. Ian, will it possible to encode to a IceCastServer ?

An updated build with that capability is now up in the package (see 1st post). You could use it something like this...

Code: [Select]
HENCODE encoder=BASS_Encode_StartCA(source, 'adts', 'aac ', 0, bitrate*1000, 0, 0); // start an AAC encoder
BASS_Encode_CastInit(encoder, server, password, BASS_ENCODE_TYPE_AAC, name, url, genre, desc, headers, bitrate, 0); // connect it to the cast server

Note the only useful codec for this purpose included in iOS is AAC, eg. there is no MP3 encoder (only decoder). Also note the BASS_CONFIG_IOS_MIXAUDIO option (mentioned a few posts above) needs to be set to 0 before BASS_Init or BASS_RecordInit is called, to allow AAC encoding.

It seems to be working quite nicely, but it hasn't been tested very much yet, so please report how you get on.

Thanks a lot Ian! That solved the problem. I read about that property somewhere and I tried to disable it, but didn't know BASS could do it.

Good to hear it worked. As I recall, the remote stuff won't work if the "MixWithOthers" option has been enabled at all, so that would probably be why it still didn't work after you disabled that (BASS had enabled it).

The BASS_CONFIG_IOS_MIXAUDIO option was added as a workaround, but was left undocumented in case it got superseded by other session-related option(s). It has since been found to be needed for AAC encoding too, so it will probably become documented in the next update.

The only remaining issue is, that when the user taps the pause button, I have to pause the music using BASS_Pause(), because only pausing the single channel I'm using isn't enough. The audio frameworks must think BASS is still playing something, because the even though the channel is paused, the pause button doesn't turn into a play button and the little play icon in the status bar doesn't disappear. But I'm glad I found a workaround.

Yep, BASS_Pause entirely stops the output (assuming the BASS_CONFIG_PAUSE_NOPLAY option hasn't been turned off). Without that (or BASS_Stop), BASS will still be outputing silence when there are no channels playing.

Okay, here is a sample app, demonstrating how to make BASS play back music in the background, and control playback with the multitask bar controls. Actually the app can also be remote controlled with some 3rd party iPhone accessories and speakers.

http://cl.ly/4513342M223M3v0s2Y3T

Nice :)

Dustin

  • Posts: 1
Re: BASS for iOS (iPhone/iPad)
« Reply #116 on: 17 Jan '11 - 23:39 »
I am glad to hear from Ken that we will be able to use Mono.

I have only one question, is it possible to encode with the EncoderOgg format on the iOS platform?

Basically I am looking for a single codec to use on multiple platforms that is not MP3 for voice recording and playback.


matt1980

  • Posts: 5
Re: BASS for iOS (iPhone/iPad)
« Reply #117 on: 18 Jan '11 - 02:03 »
Hi there...having two problems with BASS in an iPad app, with the latest version I downloaded today from the top of this thread...

The first is the biggie: I just downloaded the latest zip file from the updated link in the original post. As near as I can tell, these don't have armv7 object code in them. At first, Xcode was complaining that:

Code: [Select]
ignoring file /[...]/libbass.a, file was built for archive which is not the architecture being linked (armv7)
ignoring file /[...]/bassmidi/libbassmidi.a, file was built for archive which is not the architecture being linked (armv7)

Which baffled me for a while, but then I tried using ar -x on the .a files and I got bass.o and libbassmidi.a-armv6-master.o. After I added these to my project as frameworks, I got this instead:

Code: [Select]
ignoring file /[...]/bass.o, file was built for armv6 which is not the architecture being linked (armv7)
ignoring file /[...]/bassmidi/libbassmidi.a-armv6-master.o, file was built for armv6 which is not the architecture being linked (armv7)

I might be able to compile this as armv6 (I haven't tried) but I'm supposed to make iPad apps at least armv6/armv7, if not strictly armv7, I think. I didn't have this problem with the version of the library I picked up about a year ago...which I overwrote when I copied the new ones in :o .

However it could be I'm just lost--I'm not an expert at this build stuff. I am using the 4.3 beta version at the moment, but I'm thinking that's not the problem.

The second problem is preventing me from testing in the simulator--it crashes on launch, and I get the following in the log:

Code: [Select]
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
pthread_mutexattr_destroy$UNIX2003 called from function ??? in image LineSpace.

And according to the stack in the debugger this comes within BASS_RecordGetInputName.

I've actually been having this one for a while, since I got an updated copy of the library somewhere in the neighborhood of six months ago, perhaps--at about the same time I switched to iOS 4.x as my target, so this could have something to do with it as well. I can test on my iPad, so it hasn't been a show-stopper. But it hasn't gone away either. It would be nice to be able to use the simulator again.

Thanks, all in all a very nice library!

-Matt

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #118 on: 18 Jan '11 - 16:25 »
I have only one question, is it possible to encode with the EncoderOgg format on the iOS platform?

Basically I am looking for a single codec to use on multiple platforms that is not MP3 for voice recording and playback.

The EncoderOgg class uses the external OGGENC encoder, but external executables are not permitted on the iOS platform, so I'm afraid that option would not be available. I'm not sure what the performance would be like, but a possible solution would be to build the OGG encoding (libvorbis/etc) into your app.

The formats that iOS includes built-in encoding support for are AAC, ALAC (Apple Lossless), iLBC (internet Low Bitrate Codec for speech), IMA4 (ADPCM), -law and a-law. They are accessible via BASSenc's BASS_Encode_StartCA/File functions.

having two problems with BASS in an iPad app...

The BASS libraries should include both armv6 and armv7 flavours. From the 2nd problem (pthread_mutexattr_destroy$UNIX2003) it appears that you may be using an old version, as that issue was resolved, here:

   www.un4seen.com/forum/?topic=10910.msg83942#msg83942

Please check the date of the files that you have. The current LIBBASS.A file is dated 02/12/2010. If yours is older, perhaps you re-received the version that you downloaded a year ago from your browser's cache? You could try clearing the cache and re-downloading.

darren

  • Posts: 6
Re: BASS for iOS (iPhone/iPad)
« Reply #119 on: 18 Jan '11 - 18:08 »
BASSmix isn't a plugin in the sense that BASSFLAC/etc is, ie. it can't be loaded via BASS_PluginLoad as it doesn't add support for additional file formats. To use the BASSmix functions in your app you just need to add the LIBBASSMIX.A file to your project.

Can you please tell me which package is the LIBBASSMIX.a file is in? I can't seem to find it in the packages I have already downloaded for iPhone and OSX.


Oops, found it! :)
« Last Edit: 18 Jan '11 - 18:29 by darren »

keyClipse

  • Posts: 4
Re: BASS for iOS (iPhone/iPad)
« Reply #120 on: 19 Jan '11 - 19:13 »
Hi there,

 I want to have a 3D audio for my iphone app and before implementing this app I would like to know what kind of algorithm that you use for the 3D audio. Do you use HRTF or you use the 3D mixer supplied from apple's API?

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #121 on: 20 Jan '11 - 13:48 »
Neither :)

It does its own fairly basic 3D processing, translating 3D positions/velocities to panning/volume/rate changes.

aktherraza

  • Posts: 4
help in using bass in iphone
« Reply #122 on: 20 Jan '11 - 14:01 »
Hi everybody,

I'm in urgent need of some sample code to understand how to use BASS audio library with audio units in iphone. I'm trying to apply reverb effect, is its possible using this library. Since I'm newbie for Audio Technologies and iPhone, any help is greatly appreciated. Thanks in advance.

keyClipse

  • Posts: 4
Re: BASS for iOS (iPhone/iPad)
« Reply #123 on: 20 Jan '11 - 17:37 »
I think there is a reverberation effect. If you read from bass.chm there is this function called channelsetfx that sets the effects for your channel of audio.

@Ian: Wew that is bit of dissapointment. Will there ever be a release with the HRTF algorithm?

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: BASS for iOS (iPhone/iPad)
« Reply #124 on: 21 Jan '11 - 15:28 »
Will there ever be a release with the HRTF algorithm?

There are no immediate plans for that, but never say never.