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

Jon Sch°pzinsky

  • Guest
Re: BASS for iPhoneOS
« Reply #25 on: 27 Apr '10 - 21:31 »
Ive been trying to use the Bass.Net.dll with monotouch for some time now, and everytime i use a part of the Bass.Net SDK, the build fails with "mtouch failed with no output".

Could anyone enlighten me, with how i get this working on MonoTouch?

Ive linked the needed library and frameworks, but it still fails.

/Jon

ken

  • Posts: 739
Re: BASS for iPhoneOS
« Reply #26 on: 28 Apr '10 - 07:08 »
Ive been trying to use the Bass.Net.dll with monotouch for some time now, and everytime i use a part of the Bass.Net SDK, the build fails with "mtouch failed with no output".

Could anyone enlighten me, with how i get this working on MonoTouch?

Ive linked the needed library and frameworks, but it still fails.

/Jon

For now you can't use Bass.Net with Monotouch, there are dependencys like Drawing.Image that Monotouch don't support. But Bernd is working on a iPhone version, with most fatures that works for iPhone.

/Ken

Jon Sch°pzinsky

  • Guest
Re: BASS for iPhoneOS
« Reply #27 on: 28 Apr '10 - 10:07 »
Ah, that explains it  :)

Well, then ill be looking forward to it being released. Is there any (im a developer myself so i cant believe im asking...) estimate on when its done?

/Jon

radio42

  • Posts: 4574
Re: BASS for iPhoneOS
« Reply #28 on: 28 Apr '10 - 12:01 »
It is actually being done ;-)

You can get a pre-version here:
    www.un4seen.com/filez/4/Bass.Net.iphone.zip

Note, that the iphone version has the following limitations:
a) no picture tag reading support
b) no WaveForm rendering support

The Bass.Net iphone version already has support for:
- BASS
- BASSFLAC
- BASSMIDI
- BASSWV
- BASSmix
- BASS_AAC (which is not yet available from Ian, but might be soon)
- BASS_FX (which is not yet available from Jobby, but might be soon)

Jon Sch°pzinsky

  • Guest
Re: BASS for iPhoneOS
« Reply #29 on: 28 Apr '10 - 12:05 »
Now, that was good news  ;)

I will try it right away.
Is there anywhere you want bugs reported and such?

Jon

ken

  • Posts: 739
Re: BASS for iPhoneOS
« Reply #30 on: 11 May '10 - 14:16 »
It is actually being done ;-)

You can get a pre-version here:
    www.un4seen.com/filez/4/Bass.Net.iphone.zip



When using ChannelSync for reading Meta tags, my app crash on the iPhone device but works just fine in the simulator.

I set sync like this:
Code: [Select]
mySync = new SYNCPROC(MetaSync);
Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_META, 0, mySync, IntPtr.Zero);

and get meta data like this:
Code: [Select]
private void MetaSync(int handle, int channel, int data, IntPtr user)
{
       
  TAG_INFO tags = new TAG_INFO();


  if (tags.UpdateFromMETA(Bass.BASS_ChannelGetTags(_stream, BASSTag.BASS_TAG_META), false, true))
  {

          _NetStreamEventArgs.Artist = tags.artist;
          _NetStreamEventArgs.Title = tags.title;
                   
    }
           
 }


The app crash on "Bass.BASS_ChannelSetSync", here is the debug info I get from Monotouch
Quote
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) CasterPlay.AudioEngine:MetaSync (int,int,int,intptr)' while running with --aot-only.

  at (wrapper managed-to-native) Un4seen.Bass.Bass:BASS_ChannelSetSync (int,Un4seen.Bass.BASSSync,long,Un4seen.Bass.SYNCPROC,intptr)


I can read tags "manually" like this (but then I need a timer to pull the data..
Code: [Select]

TAG_INFO  _tagInfo = new TAG_INFO(URL);

if (BassTags.BASS_TAG_GetFromURL(_stream, _tagInfo))
 {

      _NetStreamEventArgs.Artist = _tagInfo.artist;
       _NetStreamEventArgs.Title = _tagInfo.title;
}
         

Is is Bass, Bass.Net or me...?


/Ken

radio42

  • Posts: 4574
Re: BASS for iPhoneOS
« Reply #31 on: 17 May '10 - 09:34 »
Sounds this could be related to an AOT (ahead-of-time compilation) issue with mono?
Did you to to NOT use AOT?
And did you try to use a static SYNCPROC instead of a private method?

I'm unable to reproduce this, as I don't have a Mac...

MikaelS

  • Posts: 198
Re: BASS for iPhoneOS
« Reply #32 on: 22 May '10 - 10:26 »
When I try to build a test project using BASS for iPhone, the compiler gives me the following warning message:
ld: warning: in /Users/mikael/Documents/BASSTest/basslib/libbass.a, file was built for unsupported file format which is not the architecture being linked (i386)

My application is a "clean" View Based iPhone application with no code added.
The only think I did as to add libbass.a into "Targets > BASSTest > Link Binary With Libraries" node.

It does not matter if I take the libbass.a file from the root folder or from the "Simulator" folder.

Any ideas? A working example project would be nice :)

Thanks in advance!

Edit: I'm using (have added) the bass.h file from the OSX setup to my project.
If I do not include this file (#import "bass.h") I do not get the warning. Help!
« Last Edit: 22 May '10 - 11:23 by MikaelS »

MikaelS

  • Posts: 198
Re: BASS for iPhoneOS
« Reply #33 on: 23 May '10 - 09:29 »
Nevermind my prior post.. It was XCode mixing things up ;)

MikaelS

  • Posts: 198
Re: BASS for iPhoneOS
« Reply #34 on: 26 May '10 - 17:11 »
What should be used to set the device general output volume with BASS for iPhone?

Can "BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, XXX);" be used or do I need to use AVAudioSession property?

Please help!

Thanks in advance.

ken

  • Posts: 739
Re: BASS for iPhoneOS
« Reply #35 on: 26 May '10 - 22:21 »
What should be used to set the device general output volume with BASS for iPhone?

You have to use "MPVolumeView" in iPhone SDK, this class will give you a slider that controls volume and are "connected" to the volume buttons on the iPhone. Not that The volumeslider will not show in simulator, only shows on a iPhone device.  MPVolumeView doc: http://bit.ly/blzs6w



MikaelS

  • Posts: 198
Re: BASS for iPhoneOS
« Reply #36 on: 27 May '10 - 09:36 »
Thanks for the reply Ken, it works like a charm :)

George

  • Posts: 13
Re: BASS for iPhoneOS
« Reply #37 on: 28 May '10 - 12:55 »
BASS for iPhoneOS is really great.

There seams to be a small bug. When VoiceOver (for blind people) is activated, there will be no sound from BASS on iPhoneOS.
Settings-->General-->Accessibility-->VoiceOver.

VoiceOver is in iPhone 3GS, iPad and latest iPod Touch.

It happens on all this devices...

Probably a device sharing issue?

Ian @ un4seen

  • Administrator
  • Posts: 20401
Re: BASS for iPhoneOS
« Reply #38 on: 28 May '10 - 15:41 »
I don't see that option on my test device or the simulator, so I can't try it at the moment, but I'll send you a debug version to get some info.

George

  • Posts: 13
Re: BASS for iPhoneOS
« Reply #39 on: 1 Jun '10 - 05:44 »
Hi Ian

The VoiceOver option is on iPhone 3GS, iPad and probably latest iPod Touch...

Probably you have iPhone 3G.

I did not received debug version. Please send with advice how to debug.

Regards


Ian @ un4seen

  • Administrator
  • Posts: 20401
Re: BASS for iPhoneOS
« Reply #40 on: 1 Jun '10 - 14:14 »
From the server log, the email was apparently successfully delivered to Yahoo last Friday. If you haven't received it, perhaps it has ended up in your spam folder? I have resent it now, with the attachment in 7-Zip format instead of ZIP, in case Yahoo didn't like that. If you don't receive that either, do you have another email address that we could try?

comctrl6

  • Guest
Re: BASS for iPhoneOS
« Reply #41 on: 3 Jun '10 - 00:37 »
The descriptions mention that mp3-free version of BASS will use "OS's decoder," which I presume means CoreAudio routines. Using CoreAudio would mean using the hardware decoder for encoded files (.mp3, aac, ...). I created a basic sample that plays music on the iPhone using BASS and the CPU usage was around 30% (give or take a few percentage points). I recreated the sample using CoreAudio's Audio Queue services, and the CPU usages dropped to almost 0% (give or take a few percentage points). So, does BASS use CoreAudio (hardware accelerated) to decode supported audio files, or is everything done in software?

Also, I tried using the mp3-free version of the library on the iPhone device to play an .mp3 file and I kept getting BASS_ERROR_CODEC. Using the "normal" version of the library works on the device, however. I also tried playing an AAC (.m4a) file and I got a BASS_ERROR_FILEFORM error. Both of these indicate that BASS isn't actually using any of the CoreAudio audio decoders. Is this correct or am I missing something?

Thanks for you help.

Ian @ un4seen

  • Administrator
  • Posts: 20401
Re: BASS for iPhoneOS
« Reply #42 on: 3 Jun '10 - 15:00 »
Which iPhonesOS version are you using? The "mp3-free" BASS version requires 3.0 or above to support MP3/AAC. It does use CoreAudio codecs, but not the Audio Queue stuff, as that can't provide decoded sample data (last time I checked).

comctrl6

  • Guest
Re: BASS for iPhoneOS
« Reply #43 on: 4 Jun '10 - 01:28 »
Thanks for your reply Ian.

I'm using iPhone OS 3.1.3 on both the simulator and the device. I have both a 1st generation iPod Touch and a 3rd generation iPhone (3GS). On both of those devices I experience the same CPU usage in playback using BASS (though 3GS CPU usage is a bit less, due to, I believe, higher clock rate) and the errors when trying to play mp3 files (using the mp3-free BASS) and AAC (.m4a) files.

I can provide the code fragment I used, if needed.

Thank you for your time.

Ian @ un4seen

  • Administrator
  • Posts: 20401
Re: BASS for iPhoneOS
« Reply #44 on: 4 Jun '10 - 16:42 »
That's strange. Using the same iPhoneOS version, I'm not seeing such problems. In case it is file-specific, please upload a troublesome MP3 file to have a look at here...

   ftp.un4seen.com/incoming/

Please also confirm how you are measuring the CPU usage.

comctrl6

  • Guest
Re: BASS for iPhoneOS
« Reply #45 on: 4 Jun '10 - 23:05 »
I did some more thorough benchmarking and my results follow. All these tests were run on a 1st generation iPod Touch, running iPhone OS 3.1.3, using the CPU Sampler instruments provided within Xcode. These numbers are averages of 3 runs each. Also I gathered these numbers while the given song was playing.

I setup BASS like:

Code: [Select]
BASS_Init(-1, 44100, 0, NULL, NULL);
NSString *file = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"extension"];
BASS_StreamCreateFile(FALSE, [file cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, 0);
BASS_ChannelPlay(chan, FALSE);

I setup AVAudioPlayer like:

Code: [Select]
NSString *file = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"extension"];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:file] error:nil];
[player prepareToPlay];
[player play];

CPU UsageBASSBASS (mp3-free)AVAudioPlayer
.wav4.5% (+/- 2%)4.5 % (+/- 2%)0.9 % (+/- 0.5%)
.mp330.0% (+/- 4%)23.0% (+/- 4%)0.9 % (+/- 0.5%)
.m4a13% (+/- 2%)13% (+/- 2%)0.9 % (+/- 0.5%)

It should be noted that the Instruments tool only works in Debug mode, so there is some overhead associated with these numbers, however, it seems like BASS is adding quite a bit of overhead on top of playback compared with AVAudioPlayer.

I'm planning on using the Tempo shift functionality of BASS_FX, that's why I'm experiment with these numbers. I understand that tempo shifting requires quite a bit of processing power, and I want to reduce as much of the CPU usage "noise" as possible.

ken

  • Posts: 739
Re: BASS for iPhoneOS
« Reply #46 on: 7 Jun '10 - 18:19 »
Have anyone submitted an app with BASS to AppStore?

I wonder since I just read on a live chat from Apple Worldwide Developers Conference 2010:

Quote
Three top reasons why Apple rejects apps is:
1: Doesn't function or do what the developer says it does.
2. Use of private API's. "Developers who use private API's know exactly what they're doing." Doesn't allow private API's because they're not guaranteed and apps that use them will break if the iPhone OS is updated."
3: They crash.

is BASS considerd a "private API"?

/Ken

yps

  • Posts: 144
Re: BASS for iPhoneOS
« Reply #47 on: 8 Jun '10 - 10:25 »
"Private API" = "part of the iPhone OS API that isn't documented in the iPhone SDK".

There's a couple of "special" things you can do with iPhone OS that isn't documented by Apple, for example direct access to the camera. Apple disapproves using these features because these private APIs are subject to change without notice with every update of the OS, and that would break all apps using these APIs.

Using 3rd-party libraries should be fine, as long as the library doesn't use any private APIs itself. Does BASS do so, Ian?

Ian @ un4seen

  • Administrator
  • Posts: 20401
Re: BASS for iPhoneOS
« Reply #48 on: 8 Jun '10 - 17:28 »
I did some more thorough benchmarking and my results follow. All these tests were run on a 1st generation iPod Touch, running iPhone OS 3.1.3, using the CPU Sampler instruments provided within Xcode. These numbers are averages of 3 runs each. Also I gathered these numbers while the given song was playing.

Can you please confirm what readings you are looking at in the CPU Sampler? Trying it myself, both the standard and "mp3-free" BASS versions appear to be using around 10% CPU to play an MP3 file; that is from the test process's "% CPU" column.

Btw, I am currently re-looking into the AudioQueue stuff. I'll post an update if that ends up working well.

Using 3rd-party libraries should be fine, as long as the library doesn't use any private APIs itself. Does BASS do so, Ian?

No, BASS doesn't use any private APIs.

lazy_b

  • Posts: 2
Re: BASS for iPhoneOS
« Reply #49 on: 9 Jun '10 - 03:11 »
I'm having an odd problem playing audio with BASS.  I decode and play an AAC music stream, with a tempo-shifting effect added onto it.  This works fine until I play another audio clip on top of it.  The audio clip plays correctly over top of the music, BUT once the clip is finished, the background music will only play when I'm playing an additional clip.  The music stops whenever I'm not playing an audio clip, and resumes (flawlessly!) during the next clip played.

This is how I'm playing audio:
Code: [Select]
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (error) {
// do stuff
}
player.delegate = self;
if (![player prepareToPlay]) {
       // do stuff
}

[player play];

And this is how I'm setting up BASS:
Code: [Select]
       BASS_Init(-1, 22050, 0, 0, 0));

        appMusicChannel = BASS_StreamCreateFile(NO, [currentTrack.filename cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_STREAM_DECODE);

playbackEndSync = BASS_ChannelSetSync(appMusicChannel, BASS_SYNC_END, 0, bassPlaybackEndSynProc, nil);

appMusicChannel = BASS_FX_TempoCreate(appMusicChannel, BASS_FX_FREESOURCE);

if (!BASS_ChannelPlay(appMusicChannel, NO)) {
printf("Could not play BASS channel. BASS error code: %i\n", BASS_ErrorGetCode());
}

I suspect there might be something in the run loop or the avaudiosession that I'm getting a little messed up, but I'm unsure what it might be.  The app can do other things in the background without causing problems, but once I run an avaudioplayer instance I get this weird behavior.