dRowAudio - cannot access itunes library


#1

Howdy

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).

 

Thanks for any help.


#2

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.

Hope that helps!


#3

Thanks - that does clarify things. I was assuming the iOS music database was the iTunes library.

 

I'll check out the audio picker and likely have questions forthcoming. Thank you again.


#4

Creating the AudioPicker and then doing show() is having interesting results...and it varies from platform to platform.

 

On the ipad simulator, I can call show() and it will show up pretty well - only issue is I have to click cancel twice to close it.

 

I'm trying to get it to show on my phone though, and doing show() alone doesn't do it (I get a black screen).

Even something like

libraryPicker.show(false, Rectangle<int>(0,0,400,400));

is producing a black screen.

 

In the phone simulator, if I hit the home button, then go back to my app, the picker is visible. On the actual device though, still a black screen.

 

Anything I might be doing wrong?

 

Thanks


#5

What orientation are you using? I think you can only use the picker in portrait mode.

I also think this is only available on actual devices, I don't think the simulators emulate a Music library (or at least they didn't when I wrote it).


#6

Thanks and good points.

I use landscape mode and I force that.

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.


#7

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.

If you do find a solution let us know!


#8

Thanks for your help dave!

Will report back with what I find.


#9

Would you have any ideas though, why the picker shows up in the simulator and not on the device?

The positioning of it does not seem to be accurate.


#10

Solved the above by not setting the position.

My new question is how to use the converted .caf.

I've got all my listeners hooked up and reacting, but for example:

virtual void conversionFinished (const File &convertedFile){
        Logger::writeToLog(String(convertedFile.getSize()));
    }

..produces 0.

 

What am I missing here?

edit: maybe I should mention that my terminal does read out the drow debug code correctly (the '0' is my logger output)...

file size is 45604864
0

 


#11

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.


#12

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.

 


#13

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.


#14

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.

So I was able to get the file by doing:

String docDir = File::getSpecialLocation(File::currentExecutableFile).getParentDirectory().getSiblingFile("Documents").getFullPathName();
File tempFile = File(docDir+"/"+savedFileName+".caf");

At that point, I have a file I can use just like normal.

 

So I'm not going to push forward with the AvFormatReader as it seems to be much lower level why that only partly works...what I have now is fine.

 

thanks again for your tips.


#15

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:

const File docDir (File::getSpecialLocation (File::currentExecutableFile).getParentDirectory().getSiblingFile ("Documents");
const File tempFile (docDir.getChildFile ("savedFileName.caf"));

#16

Revisiting this trying to get the AVAssetAudioFormat working.

I can use this just fine, but the reader I then pass on displays the correct sample length, but only plays a portion of the file (first second or so).

 

Any ideas what might cause that?

 

I should mention that everything I have that uses the reader acts as if the file is fine - its just mostly silent after that first blip.