whats wrong in the following?
Show older comments
[y, Fs] = audioread('Track48.wav');
y1 = y(:,1); y2 = y(:,2);
Y = [y1 y2];
wavwrite(Y ,Fs, 'newfile.wav');
% %audiowrite('newfile.wav', Y ,Fs);
........................................................................................
Error on running:
Error using wavwrite>OpenWaveWrite (line 170)
Unable to open file. Reason: Permission denied
Error in wavwrite (line 96)
fid = OpenWaveWrite(wavefile);
Error in Test2 (line 16)
wavwrite(Y ,Fs, 'newfile.wav');
Thanks a lot
Answers (1)
madhan ravi
on 10 Jan 2019
Edited: madhan ravi
on 10 Jan 2019
0 votes
Try changing the working directory or run as administrator it is clear from the message that file permission is denied.
21 Comments
VINAYAK KARANDIKAR
on 10 Jan 2019
madhan ravi
on 10 Jan 2019
Try with audiowrite() instead of wavwrite() , perhaps?
VINAYAK KARANDIKAR
on 10 Jan 2019
Walter Roberson
on 10 Jan 2019
no that error can only ever mean that you are not authorised to create the file at that location or that you are not authorised to overwrite an existing file at that location . It can never mean there is a problem in the content of the file .
If the code works for a bit but then fails then one possibility is that you or the code changed to a different directory .
VINAYAK KARANDIKAR
on 10 Jan 2019
Walter Roberson
on 10 Jan 2019
which release are you using and which operating system ? You should probably be switching to audiowrite()
VINAYAK KARANDIKAR
on 10 Jan 2019
Walter Roberson
on 10 Jan 2019
audiowrite('newfile.wav', Y ,Fs);
should work.
Walter Roberson
on 10 Jan 2019
Try
[y, Fs] = audioread('Track48.wav');
audiowrite('newfile.wav', y, Fs);
and see if there is any difference in what you hear between the two using an external player.
VINAYAK KARANDIKAR
on 10 Jan 2019
Walter Roberson
on 10 Jan 2019
Perhaps post a Dropbox or Google Drive link to a copy of it?
VINAYAK KARANDIKAR
on 10 Jan 2019
VINAYAK KARANDIKAR
on 12 Jan 2019
Walter Roberson
on 12 Jan 2019
That file has a sample frequency of 900001 which is beyond the capabilities of my hardware to play.
VINAYAK KARANDIKAR
on 12 Jan 2019
Walter Roberson
on 13 Jan 2019
Based on the file name, it looks like it might be from a scientific instrument that was sampling at 97990kHz (nearly 1 GHz), and that it is possibly in quadrature mode. I am not currently convinced that it is intended to be "sound" in the human range.
... Though if it is quadrature encoded, it does not appear to have constellations.
If you use the 'native' mode for audioread(), and look at min() and max() of the data, it looks like it does not span the full range like human sound would be likely to. It looks like it is close to symmetric around 0 with a full span that just might be 2^14*3/2 or possibly 24000 .
Ah, look at that. Filename is SDRSharp_20170415_070322Z_97990kHz_IQ.wav and SDRSharp is the name of a Software Defined Radio program. You are not dealing with audio.
VINAYAK KARANDIKAR
on 13 Jan 2019
Walter Roberson
on 13 Jan 2019
The file is samples of radio frequency transmissions. Storing it in a .wav was convenient to the people who created it, but that does not mean that it was audio in the human sense. It is just data recordings.
The data was recorded with the program SDR# (SDRSharp)
audioinfo() reports that it is 16 bits per sample, and examining the data I see differences in value at the int16 level as small as 1, but the top bit does not seem to be used. This suggests that it really is 16 bits, rather than 12 bits stuffed into 16. However, if you look at histogram in more detail, it looks likely that the samples are in bins of width 2^8 (256) at the int16 level, as if there were roughly 91 frequency bins that are 256 apart and that for whatever reason, values are distributed around those centers instead of being exactly those centers (perhaps for phase reasons, perhaps for signal edge transition reasons, perhaps for noise reasons.) But if you
[data,fs] = audioread('SDRSharp_20170415_070322Z_97990kHz_IQ.wav', 'native');
N = 8; histogram(floor(data(:)/(2^N)),-2^(14-N):2^(14-N)-1)
then you do get a nice smooth bimodal distribution with the peaks near +/- 3072 (and distinctly non-trivial counts between.) This is not a binary encoding.
You mentioned FM: frequency modulation around centers 256 apart could plausibly account for the bin shapes.
The file name hints at 97.9 MHz, which is plausible for FM Channel 250 https://en.wikipedia.org/wiki/List_of_channel_numbers_assigned_to_FM_frequencies_in_North_America for non-digital FM radio, but the file name also hints at 97.99 MHz which could be "98.0 MHz" which could be from Europe or Africa (in North America, only odd frequencies are used.)
I am getting a bit lost following the technical description of how FM encodes stereo.
Atch, I just realized that in part I have been mentally confusing frequency vs amplitude. The histograms I am referring to above are about amplitude. You need to do a frequency analysis.
VINAYAK KARANDIKAR
on 13 Jan 2019
Walter Roberson
on 13 Jan 2019
Introduced in R2014b
You can use hist() instead of histogram() for this purpose.
Next time please fill out the Product / Release fields in your question so that we do not give you answers that are not suitable for your old release.

VINAYAK KARANDIKAR
on 13 Jan 2019
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!