25 May '13 - 19:30 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 2 [3] 4 5 ... 36
  Reply  |  Print  
Author Topic: BASS for iOS (iPhone/iPad)  (Read 110171 times)
Ian @ un4seen
Administrator
Posts: 15276


« Reply #40 on: 1 Jun '10 - 14:14 »
Reply with quoteQuote

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?
Logged
comctrl6
Guest
« Reply #41 on: 3 Jun '10 - 00:37 »
Reply with quoteQuote

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.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #42 on: 3 Jun '10 - 15:00 »
Reply with quoteQuote

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).
Logged
comctrl6
Guest
« Reply #43 on: 4 Jun '10 - 01:28 »
Reply with quoteQuote

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.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #44 on: 4 Jun '10 - 16:42 »
Reply with quoteQuote

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.
Logged
comctrl6
Guest
« Reply #45 on: 4 Jun '10 - 23:05 »
Reply with quoteQuote

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:

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:

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.
Logged
ken
Posts: 630


« Reply #46 on: 7 Jun '10 - 18:19 »
Reply with quoteQuote

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
Logged
yps
Posts: 107


« Reply #47 on: 8 Jun '10 - 10:25 »
Reply with quoteQuote

"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?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #48 on: 8 Jun '10 - 17:28 »
Reply with quoteQuote

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.
Logged
lazy_b
Posts: 2


« Reply #49 on: 9 Jun '10 - 03:11 »
Reply with quoteQuote

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:
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:
       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.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #50 on: 9 Jun '10 - 13:53 »
Reply with quoteQuote

Please confirm the roles of BASS and AVAudioPlayer, eg. is BASS playing the background music and AVAudioPlayer playing all of the clips? I haven't really looked at AVAudioPlayer before, but trying it just now, there didn't appear to be any problem mixing it with BASS output, eg. BASS continued playing while/after AVAudioPlayer played another file. Should BASS have stopped when the AVAudioPlayer did? If so, are you doing anything else not shown in the code above, eg. audio session stuff?
Logged
lazy_b
Posts: 2


« Reply #51 on: 9 Jun '10 - 21:34 »
Reply with quoteQuote

Bass is playing background music, and I'm using AVAudioPlayer to play sounds over top of bass.  The goal is to have the music playing continuously and occasionally overlay other sounds.  The overlaying works perfectly, the problem is that once the first AVAudioPlayer get kicked off, the music will ONLY play when the AVAudioPlayer is playing.  I looked into the session pretty thoroughly, and there is no change in the following settings between the music starting (no problems) and the AVAudioPlayer playing (music only while avaudioplayer is running).  As far as I can tell, the problem isn't with the session settings, as the audio plays exactly as I'd like it to.  Is there a more preferred way to play sounds on top of a BASS music stream?  I just went with AVAudioPlayer because it was extremely convenient.

Oh, and it does bear mentioning that the app itself is an event-based app, which periodically will wake up from a timer or a UI event (and more than likely want to play a sound) but is ordinarily not continuously processing.  I've been looking around for documentation as to how BASS fits itself into the main application run loop but haven't had any luck as yet.  Are you spawning a pthread to decode/ process the file perhaps?  Could there be some problem with that thread not being scheduled properly?

kAudioSessionProperty_AudioCategory
kAudioSessionProperty_OtherAudioIsPlaying
 kAudioSessionProperty_ServerDied
 kAudioSessionProperty_CurrentHardwareInputNumberChannels
 kAudioSessionProperty_OverrideAudioRoute
 kAudioSessionProperty_OtherMixableAudioShouldDuck
 kAudioSessionProperty_OverrideCategoryMixWithOthers
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #52 on: 10 Jun '10 - 16:14 »
Reply with quoteQuote

Is there a more preferred way to play sounds on top of a BASS music stream?

You could just use BASS Smiley ... You could use BASS_StreamCreateFile, like you did with the background music but without the tempo processing (also remove the BASS_STREAM_DECODE flag). Another option is to use BASS_SampleLoad.

Regarding the BASS/AVAudioPlayer troubles, I'll send you a debug version to find out what is happening.
Logged
ken
Posts: 630


« Reply #53 on: 12 Jun '10 - 16:16 »
Reply with quoteQuote

It is actually being done ;-)

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

N

Bernd,

How do you suggest I do Recording to wav (or compresed format if possible) and have VU-meters. in PC I use EncoderWAV and DSP for VU-meters but since the Misc namespce is not in iPhone version...

public void StartRecording()
{
   Bass.BASS_RecordInit(-1);

   RECORDPROC _recProc = new RECORDPROC(recordPROC);

   int _recChannel = Bass.BASS_RecordStart(44100,2,BASSFlag.BASS_RECORD_PAUSE,_recProc,IntPtr.Zero);
   Bass.BASS_ChannelPlay(_recChannel,false);


}

private int recordPROC(int handle, IntPtr buffer, int length, IntPtr user)
{
   return 1;
}



Logged
radio42
Posts: 4012


« Reply #54 on: 12 Jun '10 - 16:37 »
Reply with quoteQuote

I'm not sure about any encoding (as BASSenc isn't currently supported on iPhone) - but you might code your own wave file writer.
Logged
yps
Posts: 107


« Reply #55 on: 15 Jun '10 - 08:44 »
Reply with quoteQuote

Doess the iPhone port support full duplex recording and playback? Has anyone tried if that works?
Logged
MikaelS
Posts: 88


« Reply #56 on: 18 Jun '10 - 10:30 »
Reply with quoteQuote

When will BASS for iPhone appear for iOS 4.0 ?

It seems like iPhone applications needs to be compiled (and work) with iOS 4.0 to get accepted to the AppStore.
So when I now updated to iOS 4.0, my project will no longer compile.

Thanks in advance for any help!
Logged
radio42
Posts: 4012


« Reply #57 on: 18 Jun '10 - 11:13 »
Reply with quoteQuote

A new verison of the .Net iPhone version (to be used with monotouch) is ready:
v2.4.1.0

You can get it here:
    www.un4seen.com/filez/4/Bass24.Net_iphone.zip

Note, that the iphone version has the following limitations:
a) no picture tag reading support
b) no WaveForm rendering support
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #58 on: 18 Jun '10 - 16:24 »
Reply with quoteQuote

Doess the iPhone port support full duplex recording and playback? Has anyone tried if that works?

Yes, I have tried that (recording and playing simultaneously), and it seems to be fine.

So when I now updated to iOS 4.0, my project will no longer compile.

I haven't tried iOS 4 yet (it's still in beta), but I'll have a look at it shortly. I would have thought it would be back-compatible with iPhoneOS 3.x, though. What error message(s) are you getting from XCode?
Logged
MikaelS
Posts: 88


« Reply #59 on: 19 Jun '10 - 11:08 »
Reply with quoteQuote


So when I now updated to iOS 4.0, my project will no longer compile.

I haven't tried iOS 4 yet (it's still in beta), but I'll have a look at it shortly. I would have thought it would be back-compatible with iPhoneOS 3.x, though. What error message(s) are you getting from XCode?

Sorry, my fault. When I upgraded XCode it mangled my project settings and some other things, so after a bit of investigation I managed to revert the settings back to what it should be and now it compiles fine again (Running on iOS 4.0 in the simulator, target os is still 3.1.3)
Logged
Pages: 1 2 [3] 4 5 ... 36
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines