0

I am trying to do some operations on MIDI tracks, such as increasing/decreasing the playback speed.

For those who want more detail: To change playback speed, I need to divide 'delta times' of each track by the multiplier. Eg. If I want to speed up the track x2 then I divide the delta times by 2. Delta times are stored as variable length qualities so if I divide the delta times, I need to update the track's size by reducing the size in bytes so as to keep the state of the track consistent (because shorter delta times mean less number of bytes needed to store variable length quantity).

In my struct, the track length (size in bytes of the entire track) is stored as uint32_t. The problem occurs when I try to store the changed track size back. So lets say if my original track size was 3200 and after reducing the delta times the difference in bytes is 240, then I simply subtract this difference from the original length. However, when I use the 'du' command to check the new file size, the file size inflates heavily. Like it goes from somewhere like 16 kB to 2000 kB. I dont understand why.

  • The problem appears to be that you write too much data into the file. This code does not write data. – CL. Apr 14 '20 at 06:58
  • The writing part of the code is completely correct. I know that for sure. And yes, I am indeed writing too much data into the file. However, I believe that the issue lies with the operations somewhere. Since I am dealing with uint, int, and float, I think somewhere the intended representation is getting changed to something really big in size. I dont understand where though. –  Apr 14 '20 at 07:02
  • What happens when you divide all delta times by 1? What is the first place where the old and new files differ? Can you show a hexdump of those? – CL. Apr 14 '20 at 07:39
  • @gazillionTickets Is there some reason you deleted all your code? – Brad Apr 15 '20 at 01:50

0 Answers0