Search code examples
matlabimage-processingoctavevector-graphicsaudacity

How to export the left and right channels of a very large wave/audio file (400meg/22+mins) as an image


How to export the left and right channels of a very large wave/audio file (400meg/22+mins) as an image (the best format maybe a vector image format) See wave file image below. I'm trying to superimpose the Left and right channels on top of each other to get a graphic.

I know I can do a screenshot but there's no way to get a 22+min sound file zoomed in to fit on one screen. Is there a way to export each channel zoomed in as vector art?

enter image description here


Solution

  • In GNU Octave you can do

    [Y, FS, BPS] = wavread ("out2.wav");
    samples = rows (Y);
    # Plot 0.2s blocks
    len_seconds = 0.2;
    blocksize = FS * len_seconds;
    numblocks = floor (samples / blocksize);
    for k=0:numblocks;
      idx_start = k * blocksize+1;
      idx_stop  = (k+1) * blocksize;
      t = linspace ((idx_start-1) / FS, idx_stop / FS, blocksize);
      plot (t, Y(idx_start:idx_stop, :))
      grid on
      xlabel ("time [s]");
      print ("-dpdf", sprintf ("waveplot%i.pdf", k));
    endfor
    

    which reads the entire wav and plots blocks which are 0.2s long. I've attached the first generated output (converted to png):

    First block

    If your PC has low memory (<8GB) I suggest reading the wav in chunks and process them separately, see "help wavread": [...] = wavread (FILENAME, [N1 N2]). You should also consider that the generated graphical plots needs much more space on the hardrive, I guess factor 5..20 dependent on your image format.