TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker and becoming a Supporting Member. For more info: Support TMC

Easy iTunes playlist syncing for Tesla USB flash drive

Discussion in 'Model S: User Interface' started by majorlance, Mar 5, 2015.

  1. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    Nice. I will have to check it out.

    I've always used playlists for my car playback but prior to the Tesla, would just dedicate an iPod classic to my library for my car. Basically, I could have my music by playlist, genre, song, etc. But I mostly used playlist like one would use a pandora station...

    The script I wrote focuses on playlists. All works well but Applescript seems to be a little wonky with timeouts. My workaround (re-naming genre to a playlist) solves the lack of support for traditional m3u playlists but results in duplicated files. I'd really like to see tesla offer support for them then whole library syncing would work for users with large libraries *and* give many of us a classic playlist function.

    Maybe be the mods can give us a sticky around music playback and we could post various workarounds... :)
     
  2. ra-san

    ra-san Member

    Joined:
    Dec 26, 2008
    Messages:
    296
    Location:
    San Diego, CA
    Yeah, lack of playlists on the car sucks. The folder workaround is a good one, given the limitations we're currently stuck with. Hopefully that'll change soon.

    I'm actually kind of hoping that the whole Apple Lossless thing is fixed by 6.2. In the conference call he said better audio codec support, and Apple Lossless has been open source with sample code for a long time now (as I've pointed out to them in emails). Since he specifically said audio codec support, I'm think it's that, or more likely Bluetooth aptX support vs. something as huge as CarPlay or the Android equiv. though someday I do personally still hope for full CarPlay support.

    On another note, and relevant to the aptX possibility, while the purist in me wants lossless libraries anywhere I can, I'm virtually certain at this point that the Bluetooth connection in the S supports AAC. Doesn't help Android folks out for the most part, but certainly does all the iPhone users. I've verified the part Tesla uses supports it, and based on communications with them personally, as well as past communications I've seen either here and/or the Tesla forums, I am pretty certain they utilize it. The only drawback, aside from the fact it's still compressed, is that far as I've seen once I start really digging into the details, I'm pretty sure the AAC (or whatever source) from the iPhone is decoded to lossless, then re-encoded as AAC again at a specific bitrate (it's in the spec - 256 maybe?) by the bluetooth stack in the phone rather than the phone just sending the AAC data direct from the song file. Still though, sounds a hell of a lot better than the baseline Bluetooth audio. I'm sure that much of it is just due to my aging ears :( but I tested Apple lossless (converted to Flac - still lossless) of a couple songs vs. the iTunes music match 256kbps AAC of the same song, via the iPhone connected by Bliuetooth, and can't honestly say I could hear a difference. Makes me a little sad, but from my A/B test days doing codec testing in a previous job, though 128 up to somewhat less than 320kbps mp3 was painfully obvious vs. lossless, >160kbps AAC was mostly transparent, and I can't recall 256+ AAC being able to be picked by anyone we tested with, including the professed golden ears.

    Regardless, I want my whole library available independent of cell connection, even if I choose to often just use my phone. And if most of my library is in lossless, and TB are cheap, seems silly not to keep it lossless for the car. Even if they start natively supporting Apple Lossless, which I hope they do, I'll still be needing a quick and easy way to keep a copy of my library in sync. I think ideally I'd want a tool that could, without a lot of setup each time, copy the whole library, and playlists, or any subset by playlist, to the removable storage used for the car with one click (once the initial selections are made first run).

    In my program, I was thinking of adding a details view of operations in progress next, but more I think about it, the more I think playlist support is more important for actual functionality. While seeing lots of progress bars chugging along is reassuring, once it's no longer a novelty and you just want to hit it and forget it, the actual usefulness of having folders made for each playlist seems a lot more of a win. I hate the duplicated space :( Will have to check - bet they'd support ext2/3 filesystems with hard links - thought I saw a utility another forum user had written a while back that handled shuffle by doing that, but special formatting is a mess to ask people to deal with. Just hope that they'll support playlist files soon.
     
  3. gzerninplatz

    gzerninplatz Member

    Joined:
    Aug 24, 2014
    Messages:
    326
    Location:
    Troutdale, OR
    Majorlance - does your script also check for unplayable files (DRM, etc.)? I think those may cause the entire folder to be unplayable...Tesla can't process to add the files to its directory...
     
  4. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    No but I can add that. I'll look at it this weekend.
     
  5. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    #25 majorlance, Mar 21, 2015
    Last edited: Mar 21, 2015
    ra-san,

    I'm with you. It would be so easy for Tesla to support m3u playlist files. I have a Pono player and wrote another script that syncs an iTunes folder with multiple playlists to to the pono (which looks like a hard drive to the mac) and then re-creates the playlists as m3u files, which the pono recognizes. It is *much* faster than using their PonoWorld app and it keeps me from having to manage two applications.

    I'll do some A/B testing between my iPhone and the flash drive. I have the Reus Systems upgrade in my car (new A pillar speakers and two 10" subs in the back). In my experience, the major difference in quality for bluetooth vs. direct (AAC, lossless, etc.) is at the low and high ends of the spectrum. I'll report back.

    I'm also very curious as to the audio improvements that Elon mentioned. My thoughts were:

    1) Improved bluetooth codec (most likely)
    2) Replacement for the crappy Dolby feature
    3) A multi-band spectrum equalizer (this would be easy)
    4) Ability to create a larger sound space by setting speaker distance with a slight time delay (don't really know how to describe this but my Alpine aftermarket head unit has this. Once adjusted properly, really opened up the sound.)
    5) Direct support for an iPhone/iPod through the USB ports (least likely)

    BTW, I tried using hard links once to replicate a playlist on a flash drive but it didn't work. I can't remember how it failed but my plan was to create a master library and then copy links to another folder for a playlist like function.

    As inspiration for my own script, initially I was copying a playlist to a folder and then randomizing the file name with "A Better Finder Renamer". Repeat again for next playlist. it would take a weekend and if I added more songs I'd have to start the process from scratch again.

    Once shuffle came out, I gave up on this approach and went with renaming the genre to the playlist name. I did it manually at first which inspired me to write the Applescript program. (I don't know objective C...) Big driver for doing this was that the Tesla media player would load album art when playing back by genre and it doesn't (I don't think this has changed) display album art in folder mode. I really like Album Art! :)

    What I don't like about my script is that it doesn't handle errors well. And background processes like time machine seem to interfere or hang it. Not certain why... I copy over 175 GB of data (about 3,700 original songs which expands to 13,000 when duplicated by playlist) so there is a lot to move around. But storage is cheap!

    It will be interesting to see what Tesla delivers with 6.2. Maybe we could combine our approaches to come up with a flexible, bullet proof solution!
     
  6. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    ra-san,

    Re-read your post and also did a quick A/B (not blind) test of my iPhone 6 via bluetooth vs. flash drive.

    I think that you're saying the chipset will support Airplay (your AAC comment) and could be
    enabled. Is this correct?

    As far as my own test went, I tried some old stuff, new stuff and 256 AAC vs. lossless. In all cases, I thought I heard more clarity and a little more low end bass with the flash drive. But it was close and may have had a little user bias as I knew what I was playing. I also confirmed that playing USB folders still does not have artwork or complete artist/album/song information from the ID3 tags embedded in the songs.

    Also, I didn't listen or see the transcript. Just read a couple of articles so if he said codec, some of my original hopes may be out of line...


     
  7. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    #27 majorlance, Mar 21, 2015
    Last edited: Mar 22, 2015
    Updated script to filter out iTunes protected files. If your playlists have a protected file in them, the script will ignore it. User gzerninplatz reported that the Tesla media player was failing, most likely to the inclusion of the older iTunes protected songs. (I purged my library of those some time ago and didn't think to check!)

    I've also added code to reset the "last modified" date of the song to be whatever it was before the script briefly changes the genre. So the song file will have the correct last mod date but iTunes doesn't automatically reload the song data. It will refresh it the next time the song is played, however.

    Finally, I'm going to try and post all of this to github (sa-san was the inspiration for this). That way I won't have to post new links in this thread.

    New download link:

    Dropbox - Tesla iTunes Playlist Sync v1.2.scpt

    Enjoy!
     
  8. gzerninplatz

    gzerninplatz Member

    Joined:
    Aug 24, 2014
    Messages:
    326
    Location:
    Troutdale, OR
    I got an error with this script....might want to wait till Lee has a chance to look at it again. It thought I had a Pono and halted...I don't.
     
  9. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    Fixed. Left a reference in for my testing... no Pono needed now! ;)

    The link above will includes the fix (use Tesla folder in iTunes to look for playlists).

    Thanks.
     
  10. gzerninplatz

    gzerninplatz Member

    Joined:
    Aug 24, 2014
    Messages:
    326
    Location:
    Troutdale, OR
    HEARTFELT THANKS TO LEE (majorlance)!!! This thing is easy to run, and does a world of good for Tesla audio...
    ---------------------------
    All working great now - this is SUCH a great thing, FAR better than just settling for bluetooth audio - I'm glad Tesla "forced" him into doing this script! I'd just purchased a 128GB iPhone 6 so that I'd be able to bring enough of my library to the car....but the sync'ed flash drive is far superior....better audio, and can just leave the phone in my pocket and not even run its battery down...and never a bluetooth pairing fart, ever...I'm rolling with 18,000+ tunes now, playlists intact (110GB on a 128GB flash drive)!!

    Do take his advice and do your first run to a hard drive as destination to create the base file - I used an external disk drive, (I don't even have space on my internal drive for another copy of the large library). I then simply copied that file to the flash drive, whole process took about 5 hours. Now I reset the destination to the flash drive for follow-on sync and it only takes a few minutes to make the small changes needed each time...
     
  11. andrewket

    andrewket Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    5,699
    #31 andrewket, Mar 22, 2015
    Last edited: Mar 22, 2015
    Running: Yosemite, iTunes library on external drive. XLD.app and xld (cli) installed in /Applications.

    I'm running a test, with the source location the Music folder from the external drive, and the destination a test folder on the desktop. I have 4 playlists in the Tesla playlist folder in iTunes. I'm running scan, just to see what TeslaTunes would do, and it's scanning my entire music library and marking every song to copy or convert which is not that I wanted and not what I thought the script would do. Shouldn't it scan my entire library but only copy/convert songs that are included in the playlists within the tesla playlist folder?

    Am I missing something? The first post says you can selectively copy playlists.

    Edit: for experimentation, I allowed the process to run with "scan and copy/convert". It's essentially copying my entire iTunes library to the test folder, and it does not appear that it's converting. All the files still end in .m4a. Does it do the convert after the copy?

    Edit edit: ok, I see now on the github page that the instructions there say "I'll add more descriptive messages for when something unexpected happens, and I may integrate in with iTunes enough to grab playlists and let you copy/convert them instead of a whole library directory, if that's desired (personally, I'm only interested in my entire library - don't make me choose a subset!)."

    So that explains why it's copying the entire music library. But it still doesn't appear to be calling xld and converting to flac. The CLI script is in /Applications and is executable.


     
  12. andrewket

    andrewket Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    5,699
    Anyone? Help? :)
     
  13. gzerninplatz

    gzerninplatz Member

    Joined:
    Aug 24, 2014
    Messages:
    326
    Location:
    Troutdale, OR
    andrewket - are you running ra-san's script or majorlance's? ra-san does not do playlists, majorlance does. look for the script link just a few posts above this one....from majorlance.
     
  14. ra-san

    ra-san Member

    Joined:
    Dec 26, 2008
    Messages:
    296
    Location:
    San Diego, CA
    #34 ra-san, Mar 22, 2015
    Last edited: Mar 22, 2015
    Yup, that's right. His script sounds like the one you want. Mine doesn't require installing anything else or doing anything with playlists. It just copies every file the tesla can handle while also converting the apple lossless to flac for the destination directory. Xld isn't needed for mine. The flac conversion is built in. But if you only want a few playlists copied, it's definitely not for you and sounds like the AppleScript from major lance is what your after.

    Also, seems like you may have been surprised my app wasn't converting all files to flac, independent of the playlist thing? I only convert apple lossless to flac. There's no point in converting other, lossy file formats into flac. They wouldn't sound better, and would only get bigger.
     
  15. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    #35 majorlance, Mar 23, 2015
    Last edited: Mar 23, 2015
    Andrewket,

    I was traveling yesterday (spring break trip to Breckenridge), I'll take a look tonight.

    -----
    Back from the slopes!

    Read the other posts and all are correct, you'll need to download my script if you want the playlist function (basically selectively copying playlists in a Tesla playlist folder in iTunes and renaming the genre to the playlist name - giving you playlist functionality using genre in the Tesla media player).

    Here's the link:

    Dropbox - Tesla iTunes Playlist Sync v1.2.scpt

    Let me know if it works for you.
    ---------
    I plan on re-posting the script to github so that I don't have to do versioning from dropbox. I'll probably post to a new thread and then cross link to this one.
     
  16. Pollux

    Pollux Active Member

    Joined:
    Jul 16, 2013
    Messages:
    1,542
    Location:
    Merry land / District of Confusion
    Hi, @majorlance,

    First let me say THANK YOU for this great tool! I have been using it to convert some music for my 10-year old son, who is loving having "his" USB drive full of "his" music. :)

    I am embarrassed to admit that the success I am enjoying comes in spite of my inability to follow your directions. :-( I am able to download and use your script. But I believe I am failing to install xld correctly, and because of that failure, I think some of the music I'm specifying in my playlists is not actually being processed into the target folder. In fact, I suspect that all of the songs failing to be processed correctly are Apple Lossless, thus implicating my incorrect installation of xld.

    I am following these directions:

    When I download from source forge, I obtain the file xld.zip.

    I then double-click on that file.

    The result is a directory named "XLDOpusOutput.bundle".

    Within that bundle, I see a directory named Contents, containing:

    alan-mbpro:Contents alan$ ls -1R
    Info.plist
    MacOS
    Resources


    ./MacOS:
    XLDOpusOutput


    ./Resources:
    English.lproj
    Japanese.lproj


    ./Resources/English.lproj:
    XLDOpusOutput.nib


    ./Resources/Japanese.lproj:
    XLDOpusOutput.nib

    What I don't see: any directory named CLI or any executable named xld.

    So... well... I've tried copying the MacOS/XLDOpusOutput file (which is identified by file as a Mach-O universal binary, which sounds good to me) to ~/Applications/xld and making sure it is executable... but I don't think that that's working. When I run the script, I usually get a message saying that there were a bunch of files processed and some large number of failures.

    I regret bothering you with my problem, but will be grateful for any advice you can supply.

    Thanks,
    Alan
     
  17. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    #37 majorlance, Mar 24, 2015
    Last edited: Mar 24, 2015
    Pollux,

    It's the command line xld (all lower case) that hasn't been installed correctly. My initial instructions were a little confusing as the folder where it is stored is call CLI (uppercase). Another user had a similar error and here is what I posted:

    Copy the xld (all lower case) script from the CLI folder to your Applications folder. (You also need to make it executable using terminal and chmod. Open terminal, type cd /Applications, type sudo chmod 755 xld. Enter your system password and press enter.)

    More detailed instructions below...

    Here is the link to download XLD:

    http://sourceforge.net/projects/xld/

    When you download it, it should be a dmg file (just checked this and it is). If you double click on it (in downloads) you should see:

    Screen Shot 2015-03-24 at 6.40.06 PM.png

    Drag the XLD (all uppercase) to your Applications directory

    Next, double click on the CLI folder and you'll see this:

    Screen Shot 2015-03-24 at 6.24.00 PM.png

    Drag the file xld (all lower case) to your Applications directory.

    Next, open the terminal application (it should be in the Applications/Utilities folder. You'll need to change to the Applications directory and then use the sudo chmod 755 xld (all lower case) to make the script executable. It should look something like this (ignore the slim and lee!)

    Screen Shot 2015-03-24 at 6.32.34 PM.png

    This step is required to make the command line xld executable from the script.

    Now the Applescript sync should properly convert all of your Apple Lossless files to flac. Tip- If you have a large library that you're syncing to the flash drive, it may be easier and less error prone to sync them first to a folder on your hard drive and then copy the files to your flash drive.

    Let me know if this helps!
     
  18. Pollux

    Pollux Active Member

    Joined:
    Jul 16, 2013
    Messages:
    1,542
    Location:
    Merry land / District of Confusion
    @majorlance,

    Thank you for your patience with me and for such detailed instructions, accompanied by pictures!

    I will try all this tomorrow.

    Thanks,
    Alan
     
  19. majorlance

    majorlance Member

    Joined:
    Sep 22, 2014
    Messages:
    204
    Location:
    Bethesda, MD
    My pleasure. Good luck and let me know if it works for you.

    Lee
     
  20. Pollux

    Pollux Active Member

    Joined:
    Jul 16, 2013
    Messages:
    1,542
    Location:
    Merry land / District of Confusion
    Hi, Lee,

    I'm afraid I don't see the same thing you are seeing. When I click on your link,

    http://sourceforge.net/projects/xld/

    I get taken to that web page. There's a big green button near the top that says, "Download". In small print underneath Download is the phrase, "XLDOpusOutput-1.1.zip". What I download is automatically unzipped for me, and the result is that I see something called "XLDOpusOutput.bundle". Clicking on that yields a Terminal window, with the shell's current directory set to the top of the bundle.

    If, on the other hand, I follow the source forge link to the XLD Web site, there I am able to find a link to download xld-20141129.dmg.

    http://sourceforge.net/projects/xld/files/xld-20141129.dmg/download

    Ahhhh! When I download *that*, I am able to follow the remainder of your instructions to the letter.

    I just ran the script, and now have only a single track error rather than the 100+ I had before. And I can verify that my target folder has pretty much all the music I expect... well, I suspect that there's one track missing but I haven't compared the source playlists and the target folder to figure out which one.

    Dunno why I get different results than you when clicking on the Source Forge download button, but all's well that end's well.

    Thank you very much for the script and your help! I want you to know that my boy is *very* happy to have "his" music in the Tesla. Me, too!

    Thanks again,
    Alan
     

Share This Page

  • About Us

    Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.
  • Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


    SUPPORT TMC