1

I am trying to take an input signal and perform an FM modulation on it in octave.

This gives me an unexplained 'out of memory' error. As far as I know, my input file is not excessively large, so I don't know why I get this error.

See my trial code below (with line numbers):

 1  pkg load communications
 2
 3  [sound1, fs] = audioread( 'sound1.wav' );
 4
 5  fc     = fs / 2;
 6  devreq = 100;
 7  dt     = 1 / fs;
 8  len    = length( sound1 ) * dt;
 9
10  y = fmmod( sound1, fc, fs, devreq );
11
12  plot( abs( y ) )

The error I am receiving:

error: out of memory or dimension too large for Octave's index type
error: called from
    fmmod at line 32 column 5
    Q2 at line 10 column 2
Tasos Papastylianou
  • 21,371
  • 2
  • 28
  • 57
  • I doubt this has anything to do with the particular function you're using, and more likely to relate to bugs making you "actually" [running out of memory](https://stackoverflow.com/questions/43826011/octave-out-of-memory-or-dimension-too-large-for-octaves-index-type#comment74712843_43826011), or [valid 32-bit indices per object](https://stackoverflow.com/questions/39494071/how-to-increase-memory-limitations-in-octave#comment66309847_39494071). Would you care to put above a minimal testcase reproducing your issue so that we can help you more specificallly? – Tasos Papastylianou Oct 11 '20 at 10:39
  • Thanks for your reply, please see below a snipet of example code and then below that the error message: [sound1,fs]=audioread('sound1.wav'); Sampling_Frequency1=fs fc=fs/2; devreq=100; dt=1/fs; len=length(sound1)*dt; t=0:dt:len; t=t(1:end-1); y=fmmod(sound1,fc,fs,devreq) plot(abs(y)); The error message: error: out of memory or dimension too large for Octave's index type error: called from fmmod at line 32 column 5 Q2 at line 12 column 2 – Rhyston Da Silva Oct 11 '20 at 11:34
  • Thank you. With this example I can see what is wrong. The output of audioread gives an Nx1 output (or Nx2 if you have a stereo file, but from the error presumably you don't). Whereas fmmod seems to expect an 1xN input specifically. If you examine the (very simple) fmmod code, it uses simple addition without checking the vector orientation. Therefore when you pass an Nx1 vector, it interprets the operation (Nx1)+(1xN) as broadcasting, and tries to output an (NxN) array, which is too large for the available memory. The solution is to pass `sound1` to `fmmod` transposed, to make it (1xN). – Tasos Papastylianou Oct 11 '20 at 14:00
  • Btw, thank you for asking this question; the input orientation was a very dangerous assumption by the author of this function, so I would treat this as a bug. I would encourage you to report this as a bug on the [octave bug tracker](https://www.gnu.org/software/octave/bugs) to let the maintainer know :) (also, welcome to StackOverflow) – Tasos Papastylianou Oct 11 '20 at 14:03
  • I've edited the title and text slightly to make it more suitable for future 'googlers', I hope you don't mind. If the question is re-opened I will provide a fuller answer. – Tasos Papastylianou Oct 11 '20 at 14:24
  • Thank you very much for your response. It was extremely helpful. Once I transposed the sound1.wav file then I was able to run it through fmmod withouth any problems, however will this not change the final output? I will definitely when I have some time report it as a bug to the octave maintenance team. I am not sure why they closed the question, but I do hope it gets reopened for future 'googlers'. Thank you again for your assistance. – Rhyston Da Silva Oct 14 '20 at 06:58
  • No it doesn't change the final output. You're just choosing to represent your one-dimensional signal as a horizontal vector instead of a vertical one. If later functions expect your input to be in vertical form, you can always change it back. We are of course talking about a mono signal; in the case of stereo, (unless you are happy to treat it as the independent transmission of two mono signals), actual fm-stereo modulation is more complex, typically involving multiplexing (see https://en.wikipedia.org/wiki/FM_broadcasting#Stereo_FM). – Tasos Papastylianou Oct 14 '20 at 08:00

0 Answers0