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

According to internet sources, the bug occurs under the condition that the computer utilizes differently formatted hard disks, i.e. disks which are not all formatted with Mac OS X Journaled. 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 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. Additionally, the length of the file will also be misinterpreted, because a wrong sample rate is assumed.

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

33 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?

    • I’d be happy to help you restore your files via Skype/TeamViewer or similar. Another possibility is to send me the files via Dropbox/WeTransfer or similar. Please get in touch with me via mail to dev@davehofmann.de.

  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.

Leave a Reply to Terrence Tobin Cancel reply

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