When Logic Destroys Your Audio Files

This post is about a serious bug in Logic, which causes audio files to be damaged. The symptom of this bug is the following error message when opening a previously perfectly working project: One or more audio files changed in length.

Background

This is how I encountered the bug: we had recording sessions with our band and had completed the first session. In the studio, we could listen to all tracks without any problems. After some time, when our sound engineer opened the project again, he encountered the error message above for some files. After listening through the projects, he discovered that a large number of audio clips could not be played back anymore. We had one backup of the project we had made right after the recording session, but unfortunately it contained the same corrupted files. This meant that we had to repeat the recording session 🙁

We had a few more recording sessions, after which we made 3 or 4 backups right away. After we had recorded a whole album, the issue occurred again. The files were corrupted on all backups again, although we could listen to the tracks in the studio without problems. Consequently, the data was corrupted after the recording and before re-opening the Logic project.

Then, our sound engineer noticed the following: when he opened a project for the first time, logic reported 4 corrupted files. When opening the same project again, suddenly 24 files were corrupted. This leads to the conclusion that Logic itself is responsible for destroying the audio files.

Conditions under Which the Bug Occurs

The exact conditions under which the error occurs are not exactly clear, but one of the following things or a combination of those things seems to be involved:

  • Using hard drives or SSDs that are not formatted with an Apple File system (i.e. Mac OS X Journaled or APFS)
  • Using external (hard) drives
  • Using the Comping Feature in Logic (the one where you see multiple takes stacked on each other and can combine them to an “optimal” take)

The files are damaged when logic is closed, which means that even if the project works perfectly before closing the application, there is no guarantee that it will work when opened again.

We experienced these problems with Logic 9, but internet forum posts suggest that it can also happen with Logic Pro X. If someone can confirm, knows the exact error conditions or has any updates, please feel free to comment.

Error Analysis

Logic destroys the audio files in seemingly random order, e.g. in a sequence of 79 audio files recorded for one track the files with numbers 43, 48, 56, 57, 58, 59, 65, 74 and 79 were corrupted.

For a more thorough analysis, I compared working files with corrupted files using a Hex editor, in which each single byte in the file can be visualized in hexadecimal representation. The first bytes of an intact wave file look like this:

For a detailed description of each byte, refer to this page. In short, these are the contents of the wave file header:

  • Bytes 1-4: RIFF chunk descriptor
  • Bytes 5-8: chuck size (total number of bytes in the file after this block)
  • Bytes 9-12: format (in this case WAVE)
  • Bytes 13-16: fmt-subchunk header (contains fmt )
  • Bytes 17-20: subchunk 1 size (in this case 16 for PCM)
  • Bytes 21-22: audio format (1 = PCM)
  • Bytes 23-24: number of channels (1 = Mono, 2 = Stereo, etc.)
  • Bytes 25-28: sample rate (e.g. 44,100 Hz)
  • Bytes 29-32: byte rate: number of bytes required to store 1 second of audio for all channels (= sample rate * number of channels * bits per sample / 8)
  • Bytes 33-34: block align: number of bytes required to store one sample in all channels (= number of channels * bits per sample / 8)
  • Bytes 34-36: resolution in bits per sample, e.g. 8, 16 or 24 bits
  • Bytes 37-40: data chunk header (contains data)
  • Bytes 41-44: number of bytes representing the raw audio data
  • Bytes 45ff.: raw audio data

Now let’s have a look at a destroyed audio file:

If the bug occurs, Logic fails to write the wave header correctly. Instead, the file contains only zeroes in the first 44 bytes, which is exactly the length of the wave header. The good news: the raw audio data, starting at byte 45, is still intact (note that the hex editor starts counting bytes at index 0).

If such a corrupted wave file is opened, logic can’t read the header and assumes a default 8 bit setting, which leads to a misinterpretation of the audio data. Consequently, the length of the file will also be misinterpreted. Furthermore, the interpretation will be even more off because a wrong sample rate is assumed. Not good.

Repairing the Audio Files

As a preliminary fix, you can restore the destroyed files by copying a wave file header (i.e. the first 44 bytes) from a correct file (with matching sample rate and bit depth) to a corrupted file in a hex editor.

Update August 29, 2019: It was confirmed that this also works for AIFF files. In this case, the first 512 bytes have to be copied. Thank you very much to Sawyer Wildgen for sharing this!

A wave file header specifying a sample rate of 44.100 Hz and 24 bit resolution starts with bytes similar to these (in hexadecimal representation):

1
52 49 46 46 5B 89 3E 00 57 41 56 45 66 6D 74 20 10 00 00 00 01 00 01 00 44 AC 00 00 CC 04 02 00 03 00 18 00 64 61 74 61 6B 5C 3E 00

However, one potential issue now could still be that the (sub)chunk sizes (bytes 5-8 and 41-44) are not correct, but most audio editors don’t check these values. If you want to correct these as well, make sure that you use the correct little endian representation for these byte groups. This means the byte order is reversed. A complete example is given below.

The formulas to calculate the correct values for WAVE files are:

  • chunk size = <file size in bytes> - 8
  • data chunk size = <file size in bytes> - 44

Integer to Little Endian Hex Conversion

Example: Converting the number 44,100 to a little endian hex number:

  1. Convert number to hex using a scientific calculator or an online converter such as this one. The result is: AC 44. Note that this result comprises two bytes and is encoded big endian (most significant byte first).
  2. Make sure the result is padded to the correct byte size. If the field in the header is 4 bytes, we have to add two zero bytes at the beginning: 00 00 AC 44
  3. Reverse the byte order: 44 AC 00 00. The result is now little endian (least significant byte first), as required by the wave header specification.

To confirm, you can open a working wave file with 44,100 Hz sample rate in a hex editor and check bytes 25-28, which will contain 44 AC 00 00.

Using Wave Recovery Tool to Restore the Wave File Headers

Because quite many files were damaged in our case, I did not want to fix all wave headers manually. Therefore, I developed a program which can fix the wave files all at once. Wave Recovery Tool is available on github and is published under the terms of the GNU General Public Licence.

Conclusion

This post reveals a serious bug in Logic, which can potentially destroy hours and weeks of hard work. Fortunately, the data can be restored completely either manually or using a Wave Recovery Tool I developed. I seriously hope that this bug will be fixed soon or is already fixed in recent versions of Logic.

Notes Regarding AIFF Files

In this blog post, I demonstrated the issue by means of wave file header structures. The same can be done for AIFF files, however the header structure is more complicated. The good news: I extended Wave Recovery Tool and now it is also possible to restore AIFF files under certain conditions.

59 thoughts on “When Logic Destroys Your Audio Files

  1. Huge thank you for this, Dave. I’m hoping this will save the files that have been corrupted in my project. So much work will be lost otherwise. Question: I’m reading the instructions on GitHub, and it seems one would need to have some cursory knowledge of interpreting hexadecimal or software coding or things of that sort. Unfortunately I have basically zero knowledge in that department. Will I need a computer geek at my side when I do this, or will I be okay just following your instructions? My apologies for my ignorance. There will certainly be a donation attached to whatever success I have with your software. Thanks for your time!

      • Hi Loren, the tool can restore wave files with any bit depth (e.g. 16/24 bit), sample rate (including 44.1, 48 and 96 kHz) and number of channels (Mono, Stereo and even more). You basically have to tell the program these three parameters, and it will write these information (among the other required stuff) into the wave header.
        You do not need any knowledge of hexadecimal number representation, nor do you need programming skills. However, you have to start the program from the Terminal of your operating system providing the mentioned parameters, a folder where the broken wave files are stored, and a new empty folder in which the repaired files should be stored. I tried to document this on the github page as exact as possible, however if you run into problems or error messages you can contact me under the email address provided on github. Good luck and best regards, Dave

  2. This just happened to me using Logic Pro X on a brand new Macbook Pro. I created a comp vocal track. I continued recording other tracks and somewhere along the way I realized I accidentally deleted the first comp track. Once I realized it had disappeared, I clicked ‘command Z’ over and over until it reappeared again. Unfortunately the comp track now wouldn’t produce any audio. It looks completely normal on the screen but it’s silent. 🙁

  3. And just to add, yes, I got the message “One or more audio files changed in length!” At first it was 24, then later it turned into 36, but all my other tracks seem to be intact. Very strange.

  4. Hi Dave! I’m glad somebody with your expertise ran into this problem too, as I’ve been discouraged from making music ever since encountering this bug, and losing so many files to it.

    Would you be a godsend and please post instructions for dummies like myself who know nothing about Python and exactly what I need to do?

  5. Hi,

    This just happened to me on the company I work for. 32 hours of work with a hired voice actor down the drain… The amount of damaged files goes up every time i restart the project. And even if I were to recover the files, the time it would take to reassemble the tracks would be ridiculous because of all the punch-ins I´ve done during the session. This is a very serious issue! We´ll lose a hefty amount of money on this project. I´m still to contact Apple though, but I doubt they´ll have anything to say about it. And I´m very hesitant to even use Logic pro X again in a workrelated session. I worked with Logic 9 for years and never had any issues of this kind.

    Thank you for addressing this issue!

    • If you restore the audio files and put them in the corresponding folder (named Media/Audio Files or similar), you can open the project again and all your edits will not be lost. To find the directory, you have to right-click your .logicx container and choose “Show Package Contents”.

      • I have the same issue but we’re working with aiff files in logic :\
        aiff header is a bit different from wave ones

        • I think the main difference is the byte order, so it might be possible to extend the tool to support AIFF files. Currently I do not have the time for this, but I will keep it in mind for future enhancements. Of course, if you know Python you are welcome to add the required code since it is an open source project.

  6. I have the same problem. I know repair any files (aiff) with hex editor, but is there files without informations. This files is not possible repair:(
    Do you know why is there problem in LOGIC PRO X?
    thank you.

  7. Where’s the link for the wave recovery tool? Was it removed? I see no “clone or download” link on its page.

  8. Hey! Thank you so much for this explanation! I really hope I can fix my files, does anyone know if this problem still occurs with the latest Logic?

  9. Is there any way you could help me recover my AIF files? I’ve followed every instruction for the past couple hours, with no luck. I get an error every time and have issues regarding the file or directory as it says…

  10. This just happens to me as well- the project was just about done easily 40 hours on it.
    I am so frustrated.
    The question I have is this corruption going to migrate to other projects. Should I open other projects luckily I have backup WHOLE full backups but JFC Logic?
    I am feeling a move soon.
    Should I erase the project that is the culprit?
    Thanks for any advice

    • Once the error occurs it can destroy any file in any project that you open and/or close in Logic. Deleting projects won’t help, I’m afraid. Can you confirm that you are storing your projects on a disk which is not formatted with the Mac OS X Journaled file system?

  11. This may have jut happened to me. I store Logic data files on a Mac OS X Journaled drive, however, the drive Logic runs on my main Mac Pro internal SDD drive which says it is formatted as APFS. Could this be the problem?

    • This is exactly the same situation I am in.
      When I did it I lost a lot of files.
      But it is getting worse because now it happens also when I save the projects in the Internal Drive. I am also loosing files when the session is closed.
      What should be the solution?

  12. Hello. I am encountering the problem described here. I read your solution and downloaded Syphon but have come to see that the steps involved in your solution are far beyond my understanding in terms of using terminal, etc. You mention that you do consultant work. Could I please learn more about this option?

  13. Thank you so much, Dave. Your program worked amazingly and the instructions were very easy to follow. If you have a crypto donation address or something, let me know. Feel like I owe you something. Thanks again.

  14. It really is disheartening to see this with Apple. I remember recording our sessions using Micrologic 1.6 on a Quadra 650. I was a die hard Apple user. There wasn’t a professional recording or film studio in the country that didn’t utilize Mac’s. They were the workhorses of industry with the fewest problems. They really went downhill.

  15. I’ve had the same issue all of a sudden, after several months of using Logic, and I’m really stressed because I’m trying to finish an EP under a deadline. Could I be that my version is just too old? (I’m using 10.4.1.)

    Dave, I tried following your instructions but I was also confused and couldn’t fix the problem. In one of my corrupt projects, an audio file was converted to 8 bit while the rest in the project are 24 bit, even though I didn’t manually change anything. And Logic didn’t allow me to convert that file to 24 bit, I’m assuming because it’s an AIFF file?
    (If it helps to know, all my files are saved in an external hard drive.) Any help or advice you can offer would be much appreciated!

    • From my experience, when a file is categorized as 8 bit the header is usually broken. Most softwares just display some default value (in this case 8 bit) because 0 bit would not make any sense. As described in my post, you can restore the files using a hex editor or my wave recovery tool. If you want you can send me broken files via mail or some file transfer platform like WeTransfer and I can try to restore them for you.

  16. Dave, thank you very much. Your info with python worked just as you described.

    But the session in Logic Pro is continuously destroying randomly my aiff files.

    Since the files in my session are different takes of a very complicated song, it would take an absurd amount of time creating another session and trying to organize them like the tracks/takes they were.

    Is there anyway I can fix the session? Is it true that now any session could start destroying my files??

    I’m sorry to ask, but this urges a lot. Thank you again!!

    • You don’t have to re-arrange the audio clips in your session, you can re-insert the files into your existing session. To do that, first copy the files out of your project folder/container to some other location (e.g. Desktop) and repair the files there. After the recovery was successful, copy the repaired files back into the project folder/container, overwriting the damaged files. Then start your session again and everything should be in the same place as before.

      I don’t know of a way to stop Logic from destroying the files other than to save your project on another hard disk with suitable file system (i.e. Mac OS X Journaled / APFS) or to update to the latest version and hope that the bug was fixed.

      • Hi Dave. Is APFS okay? I have a new Mac mini running Catalina 10.15.6. with Logic Pro X 10.5.1. On Disk Utility, it says hard drive type APFS volume. (Should be original factory settings, as I didn’t make any changes.) I didn’t have any problems for the first month or two that I used this system and program, but I just started getting the file length message. Wondering if there’s another fix to prevent future errors… Thank you.

        • I’ve had no issues so far with APFS, but as you see in the comments some users reported problems. However, if I understand correctly in their case the application and the data was stored on two different drives. Maybe it only works properly if you run Logic from the same physical disk on which the projects are stored, and this should be an internal drive with an Apple file system.

  17. Hey,

    Thanks so much for diagnosing this issue and making this tool available.
    I have just encountered this error message (Logic Pro X on a Macbook Pro running High Sierra), although no files actually seem to be damaged?
    Nevertheless, I’m really concerned about files becoming potentially corrupted…

    Do you think that installing Logic 10.5 will help at all?

    Hope all is well with you during these crazy times,

    peace

    • Ok, I downloaded your WaveRecovery tool (thanks so much for making that available) and it is showing zero errors in my audio files….
      I’m not sure whether to be relieved or be more concerned…….
      I analyzed the audio files on my MacBook and the backup files on my outboard drive (both Mac OSX Journaled)…… very strange…..

  18. Useful article, thank you! What can i do to prevent this happening in the future?
    Logic is doing this now to every file I record and save.

    • The only thing I can recommend is using the internal system drive for storing your projects and hoping that the error does not occur anymore then. May I ask which version you use and whether you stored your projects on a secondary or external drive?

  19. First of all, thanks for making the recovery tool – it helped save over 200 audio takes, Dave! I’d just like to add some details about my case in case it helps narrow down why this is happening.

    macOS High Sierra 10.13.6 (Late 2013 MacBook Pro)
    Logic Pro X 10.1.1
    Upgraded internal storage to 1TB Kingston A2000 with Sintech adapter, formatted as APFS

    Logic and the project itself were both stored on the internal 1TB SSD, so both were on an APFS-formatted drive. This is the first time I’ve had this happen, and it happened while recording and vocal comping (had around 500 .AIFF takes, 200 had corrupted header). Given the project and logic weren’t on differently formatted drives, that can’t be the only condition in which this bug occurs. I wonder if it is a bug with comping in Logic…? I also had some takes that *didn’t* have corrupted headers but instead were overwritten with blank data (empty waveforms), so there’s no getting those back. Very disappointing stuff, this shouldn’t happen on a professional DAW.

    Has anyone experienced this on the latest version of Logic? I might try updating MacOS and Logic.

    • Very interesting, thanks for sharing this Jack. I can confirm that we used comping as well when this happened. Anyone else?

  20. HELLO DAVE I DOWNLOADED YOUR WAVE RECOVERY TOOL AND PYTHON3 AND WENT THROUH ALL THE PROMPS AND I MADE SOME HEAD WAY BUT WHEN I PLAY THE AIFF FILE ON LOGIC PRO X ALL I HEAR IS STATIC ON ALL THE CORRECTED FILES WHERE DID I GO WRONG

    • Hi Jerry, if the results are noisy you got the sample rate, the bits per sample and/or the number of channels wrong. If you don’t know which sample rate / bits per sample / channels you used while recording, you need to try out all possible combinations until it sounds good. The most common sample rates are: 44100, 48000, 96000 and the most common bit depths are 16 and 24. The most common number of channels are 1 for Mono and 2 for Stereo, obviously.

  21. Dave,

    Heres my issue: i received the One or more audio files changed in length message and saw that I have two AIFF audio files that have been corrupted. The files are cut short. What used to be 30 second files are now just 8-10 seconds. After using the tool, the file length has been restored BUT anything after those 8-10 seconds is just static. I know I recorded in 44.1 sample rate and 24 bit mono. Deviations just make it worse. Any chance I could email you these to get some assistance? Really just looking to see weather or not these files have an hope of salvation from your expert point of view.

  22. So glad to see such an in depth breakdown of this issue. I have this happen every once in a while and I’m usually recording to an external drive. Can also echo what others have said about this specifically happening with comped tracks.

    Oftentimes I just close and reopen a few time and it self-resolves, and I’ve even had success in the past with that on the project I’m currently having difficulty with.

    I ran the wave recovery tool, but it’s not showing that there are any errors and I’m perplexed. The files are all .aiff and I tried to ctrl f search through the readout for keywords like “error” and “warning,” per the GitHub page, but nothing came up.

    Am I doing something wrong or could it be that the header isn’t actually the problem with these files?

  23. Hello Dave, Help! Logic has F’d my files at the worst possible time! I have followed your instruction to the T but have not been able to get the sessions working are you available for a zoom call?

  24. Just had this happen to me right as I’m deciding whether to reinvest in Apple as I have an older Macbook that can’t get the latest update of LPX. Unless anyone here has any similar complaints about Ableton or Protools I’ll probably switch over. This is huge. Especially because the post I started from on Apple Forums was started 5 years ago.
    Thank you so very much Dave! I’m very happy you’ve done Apple’s job for them.

  25. Hey Dave,

    I seem to have the sub chunk size warning that you mentioned on GitHub. When I go to run the code I get a “no errors were found” message for each file and the “restored” folder is empty. I have tried inputing the specific file information including bit depth but seem to still get the same result. Any insight would be immensely appreciated!

    -Josh

    • Hi Josh,

      during analysis, the tool distiguishes between warnings and errors. Warnings normally don’t need to be fixed. For example, for some reason many audio applications are not 100% accurate when it comes to encoding the sub chunk size. In my experience, this is usually not a problem because the applications seem to rely on the actual data (the chunk contents) instead of the metadata (the sub chunk size number above it). However, if errors are detected the file is normally not playable anymore (and this leads to “audio files changed in length”, among other issues). That being said, you can force the tool to restore the files even if only warnings were found. To do that, just add the parameter -f or --force to the command line. Should you need any more assistance, you can email me one of the files for further analysis.

  26. Dear Dave, Thank you so much for sharing your findings with the world. We need more people like you.

    I’d like to share with people what seems to be a slightly different problem:

    Last night I ended my podcast editing session, saved, quit LPX and went to bed.
    This morning I decided to reorganize all my folders and when I reopened the project it threw a couple of different errors.
    The first error was about a missing folder which makes sense since I did rename the folder.
    The second error was about a couple of audio files that were inside that folder.
    The third error was telling me that 48 regions had changed in duration.

    I then skipped through all the error warnings and manually linked the files. However, when I played the timeline, I noticed that all the audio regions in one of my audio tracks seem to have slid toward the left which resulted in the audio playing too early by about 1.75 seconds (not an exact measurement). Interestingly enough. the other audio track was OK! Very weird.

    The good news is that I closed the LPX project (without saving), I then went back to my hard drive and moved the folder in question back to its old location and changed its name back to its old name. I was now able to open the LPX project and everything plays with correct synchronization now.

    The bad news is that this seems to be yet another Logic Pro X bug that’s not exactly related to the issue you report where LPX destroys audio files and fails to interpret the header data.

    I’m posting this here in case it helps anyone with the same issue as the one I had.

    Takeaway: Until Apple fixes this issue DO NOT change folder names or reorganize them on your hard drive.

    I’m also curious if anyone else has experienced this problem. If so, how did you fix it?

    Also, I’ve only started using LPX recently and am nervous to adopt it as my main audio editing tool. Does anyone out there use anything more stable that you can recommend?

    SPECS:
    – 2013 Mac Pro, 32 GB Ram (don’t laugh, I’m waiting for Apple to announce the new Mac Pro Mini or M2 chips)
    – External Drive: 4TB Western Digital Black formatted as APFS (this is where I save all my LPX projects and media)
    – Logic Pro X 10.6.1 / Build 5415

    Thanks!

  27. Dear All!

    This error just happened to me today.
    – yesterday I finished work and plugged in my time machine drive
    – i let it backup during night
    – today i freed up some space on the built in SSD (Mac mini 2018) by deleting (not touching my audio folders for sure) and copying things to another external drive
    – opened Logic – bang! (One or more audio files changed in length)

    it happened to all of my projects, not only to the one i was using yesterday. very strange.
    i’ll try to recover from time machine and get back to you…

      • Yes, as described in the post our backups (which we made directly after the recording session) were already damaged. Apparently the files are destroyed either directly while recording or when closing the application.

  28. Hi Dave,
    I’m attempting to repair my damaged files, but I get this message in Terminal: [Errno 2] No such file or directory

    Thanks in advance,
    John

    • Hi John,
      did you copy your audio files into a folder named audio on your desktop? Did you spell the folder name correctly regarding upper and lower case letters? Did you change you working directory to [user home]/Desktop with cd Desktop before you entered the command? If all does not help, you can email the exact commands you use to my email address displayed on the github page of Wave Recovery Tool.

  29. Hi

    Many thanks for doing this Dave. I’ve followed all instructions and unfortunately all files still seem to be corrupt. I’ve even tried a –force on the Audio folder but to no avail, and because my samples are of mixed sample rate, its too much work to go and reset them individually.

    It does seem that all files have the first 512 bytes zereod out though, no matter how far back I go in my backups, they’re all the same.
    Is there a way to shift them via your tool? Or am I missing something and this is what your tool is doing … if I run your tool without the –force, it picks up my AIFF files as having zero errors
    MacOS Journaled external SSD btw

    Thanks again

  30. Wow, this is insane! Shame on you, Apple! And Huge thanks to Dave! I didn’t read the whole thing yet, but I think I found the right answer for my frustration. I hope I can recover the corrupted audio files in my project!

Leave a Reply to Terrence Tobin Cancel reply

Your email address will not be published. Required fields are marked *