BASS for iOS (iPhone/iPad)

Started by Ian @ un4seen, 16 Feb '10 - 16:32

Ian @ un4seen

You can indeed change the device output rate via "setPreferredSampleRate", and BASS will pick that up and change its output accordingly (you can check the BASS_INFO "freq" value to confirm). You could change the mixer's rate to match via its BASS_ATTRIB_FREQ setting, but that will result in any already buffered data (in the mixer's playback buffer) being played at an incorrect rate, and will also bit a bit fiddly regarding source rates. So it would probably be best to recreate the mixer with the new rate (if you want to avoid resampling). You could also disable buffering via the mixer's BASS_ATTRIB_BUFFER setting a bit prior to changing the rate, so that there is no buffered data at the time of the rate change, and you can immediately stop the old mixer and start the new one.

puzzler

Latest iOS bass version. Latest iOS version on iPhone 7.
1. run app and play some music/sounds
2. call to this phone
3. after call completed and focus returned to app - no any music/sounds at all

How to fix it? Or possible to fix it?

Ian @ un4seen

Do you see any messages in the console when the problem happens? Are you requesting interruption notifications (eg. AVAudioSessionInterruptionNotification), and if so, do you get notified when the interruption begins and ends? If you aren't using your own interruption notifications, please try using the BASS_CONFIG_IOS_NOTIFY option and see if you receive notifications then, something like this:

BASS_SetConfigPtr(BASS_CONFIG_IOS_NOTIFY, IOSNotifyProc);

...

void IOSNotifyProc(DWORD status)
{
NSLog(@"IOSNotifyProc(%d)", status);
}

Also confirm whether you are using either of the BASS_CONFIG_IOS_MIXAUDIO or BASS_CONFIG_IOS_NOCATEGORY config options.

puzzler

I use BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 5), don't use any interruption notifications, don't use flag BASS_CONFIG_IOS_NOCATEGORY

After app gets focus I get error at console "AUIClient_StartIO failed (561015905)
test with notify returns "IOSNotifyProc(2)"

Ian @ un4seen

OK. That looks like the same problem that another user reported with iOS 8 here:

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

The solution then was to delay the resumption (seems like the notification is received too soon). I will send you a debug BASS version to get some more info on what's happening there.

norbert

Can't get a sample in a SFZ file loaded:

 BASS_MIDI_FontGetInfo  shows presets=1, samsize=0, samload=0, although I do a BASS_MIDI_FontLoad afterwards):

At runtime I create the sfz file with content:
<region>
sample=beat.wav

I've tried various other combinations for the sample path (absolute paths).

- The file beat.wav is located in the same folder as the sfz file (both in "Documents")
- The  file beat.wav actually  exists (tested with File.Exists())
-  Bass_GetError returns BASS_OK after each single call
- The same works on Android and there samload shows a value > 0 after BASS_MIDI_FontLoad

How should the path to a sample in a sfz file be specified in iOS ?

Ian @ un4seen

Are you using BASS_MIDI_FontInit or BASS_MIDI_FontInitUser to load the SFZ file? If you're using BASS_MIDI_FontInit, then you should provide the full/absolute path to the SFZ file, but you don't need to do that for the samples (if they're in the same directory). If you're using BASS_MIDI_FontInitUser, then you will need to provide the full path to the samples in the SFZ file. I tried both ways just now, and they worked fine, so it's strange that they apparently aren't there. In my tests, I put the files in the app's resources and got the path like this:

const char *sfzfile=[[[NSBundle mainBundle] pathForResource:@"test.sfz" ofType:nil] UTF8String];

norbert

#1232
using BASS_MIDI_FontInit
bass can find the sfz file,it can find the preset that it named like the soundfont (font get presets)
I can see both wav and sfz  file in the finder ( simulator documents folder)
I m creating the sfz file at runtime in the documents folder and then copy the wav file from the resources folder to the documents folder.


using xamarin.ios.

I've now also tried with NSBundle.MainBundle.PathForResource for the sfz file, and again it shows presets =1 and samload = 0.  ( Both  wav and sfz  added as bundle resource )

Ian @ un4seen

Are you sure the sample file (beat.wav) is valid, eg. can you open it (at the same path) with BASS_StreamCreateFile?

norbert

#1234
Yes, BASS can load the wav file:

  string metronomeFile = NSBundle.MainBundle.PathForResource("metronome.sfz", null);
  string beatFile = NSBundle.MainBundle.PathForResource("beat.wav", null);
  int chan=  Bass.BASS_StreamCreateFile(beatFile, 0, 0, BASSFlag.BASS_DEFAULT); // returns -21467898

int newfont = BassMidi.BASS_MIDI_FontInit(metronomeFile , BASSFlag.BASS_DEFAULT);  // returns 1
BassMidi.BASS_MIDI_FontLoad(newfont, -1, -1);

BASS_MIDI_FONTINFO fontInfo = new BASS_MIDI_FONTINFO();
BassMidi.BASS_MIDI_FontGetInfo(newfont, fontInfo); // samload is 0
       


metronome.sfz:
<region>
sample=beat.wav

Ian @ un4seen

That's strange. The same code (in objective-C) is working fine here, so I'm not really sure what could be going wrong there. What is the sample format of the BEAT.WAV file? It must be mono or stereo, and 16-bit or 24-bit.

norbert

#1236
it's bitrate shows 705 kbit/s, so that should be 44.1khz 16 bit mono.

I also tried Bass.BASS_ChannelPlay(beatfile,true) and it plays the sound !

Maybe you could provide a debug version of bassmidi (don't know whether it would help finding the problem)?

Ian @ un4seen

BASS will play 8-bit WAV files, while BASSMIDI won't. So that could be one explanation. Please upload the file to have a look at here:

   ftp.un4seen.com/incoming

norbert

I uploaded sfz + wav file.  The same wav file works on Android with bassmidi...

Ian @ un4seen

#1239
Ah, I see what the problem is now. Your SFZ file begins with a UTF-8 BOM, which means that the first line ("<region>") won't be recognised. Here's an update that will check for a UTF-8 BOM and skip it:

   www.un4seen.com/stuff/libbassmidi.a

Let me know if you still have the problem with that.

norbert

#1240
After changing the link to  libbassmidi.a  I can tell you that it's working now ! Thanks! I guess there will be an official update ?

Ian @ un4seen

Good to hear that the BASSMIDI update did indeed fix the problem. It is now up in the package in the 1st post.

Aven

Hello,

I build in the configuration "Debug" and there are some errors:

Undefined symbols for architecture armv7:
  "_vDSP_create_fftsetup", referenced from:
      _BASS_ChannelGetData in libbass.a(libbass.a-armv7-master.o)
  "_vDSP_fft_zip", referenced from:
      _BASS_ChannelGetData in libbass.a(libbass.a-armv7-master.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What could be the problem?
I will appreciate for any help!

P.S.: While the build release is going well.

Ian @ un4seen

Adding the Accelerate framework to your project should fix that. A full list of required frameworks can be found in the 1st post.

Ian @ un4seen

The iOS version of the BASSHLS 2.4.1 release is up now in the package in the 1st post.

Ian @ un4seen

The iOS version of the new BASS 2.4.13.8 release is up in the 1st post.

p.xdevel

Hello,
I would like to use the bass library on my swift project on Xcode. I tried to include the files following the tutorial, but I have a problem: when I launch the application on the simulator everything works, while when I send it on the device (iPhone) it returns the following error:

ld: '/bass/plugins/bassflac/libbassflac.a(libbassflac.a-arm64-master.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


I tried to disable the BITCODE as seen in other online tutorials, but the problem persists.
How can I solve this problem? I think the problem is compatibility with Arm64 devices

Ian @ un4seen

That's strange. Is the problem only happening when launching the app, not when just building it? From the error message, it looks like a build problem. Have you definitely disabled bitcode for all architectures in your Xcode project? Perhaps it is currently still enabled for the arm64 architecture?

p.xdevel

Thanks for the reply!

This is the error that appears when I launch Build

ld: warning: ignoring file /Bass.framework/Bass, missing required architecture arm64 in file /Users/developer/Desktop/pieroRadio/Bass.framework/Bass (2 slices)
Undefined symbols for architecture arm64:
  "_BASS_Init", referenced from:
      __T010pieroRadio14ViewControllerC11viewDidLoadyyF in ViewController.o
  "_BASS_StreamCreateURL", referenced from:
      __T010pieroRadio14ViewControllerC11viewDidLoadyyF in ViewController.o
  "_BASS_StreamFree", referenced from:
      __T010pieroRadio14ViewControllerC11viewDidLoadyyF in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


I created a framework according to the guide and even disabled them BitCode. Also I set Build Active Architecture Only "= NO.
The error occurs when I launch the application on the device, but not on the Xcode simulator.
How can I solve this?

Can you send me a detailed guide to create a framework and an Xcode project to my email?

Ian @ un4seen

It shouldn't be necessary to create a framework for BASS or the add-ons. You can just add the libraries (.A files) to the project's "Link Binary With Libraries" list. Also check that you are using the latest BASS library, not an old version from before the arm64 architecture was supported. You can run "file libbass.a" to see what architectures are included in the library.