Thanks first of all for the helpful dRowAudio library.
I'm trying to access the itunes music library from my device, and having a number of problems.
Number 1 is in the demo, when I click on 'iTunes Library'...I'm presented with an empty list. I do have music in my library on my device.
The other issues I've somewhat gotten around - notably the window size being incorrect and hard to use on ios (ipad in landscape is the only way I could get to see everything).
Hi turntable, glad you like the module. The iTunesLibrary isn't supposed to be used on iOS because it doesn't have iTunes (at least not in the same sense as OSX). I really should have ifdef'ed it out but I think I wrote it long before I started on any iOS classes.
For iOS, you'll need to use my native iOS "AudioPicker" class. This shows the standard iOS music library and you get callbacks to native MPMediaItems when the library is dismissed.
From here, you can open streams to the MPMediaItems if you register an "AVAssetAudioFormat" with your standard AudioFormatManager.
This is really the only way to deal with audio on iOS, you never get direct access to the file system.
When I do it on the simulator, I still get the picker, I just have an empty library (as expected).
The orientation point is interesting, when I do it in the ipad simulator, it shows up, but oriented portrait (even the though the app is running landscape).
When I do it on the phone sim, once I home button out, then get back, the picker is there, only in portrait (fwiw the rest of my gui is gone at this point).
On the phone, I only get a black screen.
I'll try locking it to portrait mode and see what happens.
edit: Well look at that - when in portrait mode it works.
Anyway you know around this? I am going to for the moment try to swith to portrait, then switch back to landscape on finished/cancelled.
edit2: that doesn't work as setting the orientation enabled doesnt seem to force the device into that orientation.
No, I never investigated that deeply I'm afraid. It is a well know fact that the music library will only display in portrait though, a quick Google will show lots of stack overflow threads.
Not sure, you'd have to examine the file to see if it was created correctly. You can do this through the Xcode Organiser.
To be honest though I wouldn't use the converter class any more. I wrote that before the AVAudioFormatReader which enables you to read the stream like any other file. When using this, iOS takes care of all the threading and buffering so should be much simpler.
Thanks again - I have eschewed the converter in favor of the format reader.
I've gotten close but still having an issue, wonder if this sounds like anything to you...
I can load the sound fine, when I try to play it (via a version of the juce samplersound), I only hear the first short bit of the file, like half a second worth.
It seems longer than a buffer, and doesn't change when I change the block size.
That's the issue I'm having with the formatreader.
In regards to the converter (I would like to use that, I think)...I can see the .caf file in the organizer, but can't find much more information about it. What can I do to diagnose that? again - the file seems to process fine but when I try to get at it, it is empty.
Well the first thing to try would be copy it to your computer and see if it has a sensible size or will play back in the OS or Audacity.
Then if everything seems ok there, step through what fails when the AudioFormatManager tries to load it. Presumably at some point the stream will fail or there will be 0 channels etc.
Thanks for that tip about finding the file and loading in audacity - it worked.
You go to organizer and then you 'download' yer app data. It creates one file and within that file is the Documents folder which contained my sample that the iosaudioconverter saved.
I was able to load that into audacity and verify that the file was being created correctly. So I think what is broken is the passing of the completed file to the conversionFinished and getConvertedFile() - or my implementation was somehow broken - as I showed earlier I tried only the most basic functions on that file.
Ok, well the next thing to check would be the path contained in the File passed to
conversionFinished. Again, it should be pretty obvious what's going wrong here if you just put a breakpoint in that method and look at the call stack.
One other thing is I would re-write your path snippet above just using Files: