Hi everybody,
I'm rather new to Matlab and I have a question as to how to proceed on cutting out several clips of certain time and duration from an original wav file into a new wav file with the original timestamps preserved. I've done some searching around online and the common consensus seems to be the Matlab functions wavread and wavwrite. I've looked on help for Matlab but I am still rather confused as to how to go about in doing this task. Can anybody provide advice as to what I should do?
Thank you,
-Lok
|
|
0
|
|
|
|
Reply
|
Lok
|
2/11/2011 9:33:05 PM |
|
"Lok" wrote in message <ij49uh$36e$1@fred.mathworks.com>...
> Hi everybody,
>
> I'm rather new to Matlab and I have a question as to how to proceed on cutting out several clips of certain time and duration from an original wav file into a new wav file with the original timestamps preserved. I've done some searching around online and the common consensus seems to be the Matlab functions wavread and wavwrite. I've looked on help for Matlab but I am still rather confused as to how to go about in doing this task. Can anybody provide advice as to what I should do?
>
> Thank you,
>
> -Lok
Hi Lok, Once you use wavread to import the data into MATLAB, it is a vector (If it is a two-channel recording, it will be a Nx2 matrix, but you can just work on one of the columns). You have to use the sampling frequency, which is an optional output of wavread() to create a time vector to serve as your "time stamps".
Once you know the sampling interval in seconds (fractions thereof..) between the elements of your vector, you can extract whatever portions you need. At that point it's MATLAB indexing.
For example:
Assume the sampling frequency of test.wav is 44.1 kHz
[data,Fs] = wavread('test.wav');
% Fs is 44100
% assuming data is a single-channel recording
N = length(data);
% total duration
totaldur = N/Fs;
% create a time vector
t = linspace(0,totaldur,N);
% I'm using logical indexing here
seg1 = data(t>0.2 & t<0.4); % get the data between 0.2 and 0.4 seconds
Wayne
|
|
0
|
|
|
|
Reply
|
Wayne
|
2/12/2011 11:51:04 AM
|
|
Lok :
If you just want to clip wav files manually, and don't care how it's
done (by MATLAB or some other program), then you should use Audacity.
It's probably the most-used free audio waveform editor out there:
http://en.wikipedia.org/wiki/Audacity
http://audacity.sourceforge.net/
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
2/12/2011 2:41:46 PM
|
|
Hi ImageAnalyst,
Thank you for the suggestion. Can Audacity clip the wav file systematically into sections if given specific timestamps to clip? Any suggestions or pointers on this would be great as well.
Thanks,
Lok
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <03e44b45-dbbc-481c-9da6-5164464e9b19@b8g2000vbi.googlegroups.com>...
> Lok :
> If you just want to clip wav files manually, and don't care how it's
> done (by MATLAB or some other program), then you should use Audacity.
> It's probably the most-used free audio waveform editor out there:
>
> http://en.wikipedia.org/wiki/Audacity
> http://audacity.sourceforge.net/
>
|
|
0
|
|
|
|
Reply
|
channlh
|
2/16/2011 6:34:04 PM
|
|
On Feb 16, 1:34=A0pm, "Lok " <chan...@umich.edu> wrote:
> Hi ImageAnalyst,
>
> Thank you for the suggestion. Can Audacity clip the wav file systematical=
ly into sections if given specific timestamps to clip? Any suggestions or p=
ointers on this would be great as well.
>
> Thanks,
> Lok
>
> ImageAnalyst <imageanal...@mailinator.com> wrote in message <03e44b45-dbb=
c-481c-9da6-5164464e9...@b8g2000vbi.googlegroups.com>...
> > Lok :
> > If you just want to clip wav files manually, and don't care how it's
> > done (by MATLAB or some other program), then you should use Audacity.
> > It's probably the most-used free audio waveform editor out there:
>
> >http://en.wikipedia.org/wiki/Audacity
> >http://audacity.sourceforge.net/
---------------------------------------------------------------------------=
---------------
Try it and see, but I don't think so because I don't think it has a
programming environment that can read in a file with start and stop
times. I think you have to clip/extract the waveform segment manually
by setting their locations in its GUI.
|
|
0
|
|
|
|
Reply
|
imageanalyst (7590)
|
2/16/2011 6:39:54 PM
|
|
Hi Wayne,
Thank you for your help.
If I have a vector indicating multiple timestamps of where I want to cut, is there a way that I can avoid using 'for loop' and directly index the matrix segments that I want through the data array. Then later save it into a wav file thus cutting out the unwanted portion similar to what you did.
Thanks again,
Lok
"Wayne King" <wmkingty@gmail.com> wrote in message <ij5s78$ku2$1@fred.mathworks.com>...
> "Lok" wrote in message <ij49uh$36e$1@fred.mathworks.com>...
> > Hi everybody,
> >
> > I'm rather new to Matlab and I have a question as to how to proceed on cutting out several clips of certain time and duration from an original wav file into a new wav file with the original timestamps preserved. I've done some searching around online and the common consensus seems to be the Matlab functions wavread and wavwrite. I've looked on help for Matlab but I am still rather confused as to how to go about in doing this task. Can anybody provide advice as to what I should do?
> >
> > Thank you,
> >
> > -Lok
>
> Hi Lok, Once you use wavread to import the data into MATLAB, it is a vector (If it is a two-channel recording, it will be a Nx2 matrix, but you can just work on one of the columns). You have to use the sampling frequency, which is an optional output of wavread() to create a time vector to serve as your "time stamps".
>
> Once you know the sampling interval in seconds (fractions thereof..) between the elements of your vector, you can extract whatever portions you need. At that point it's MATLAB indexing.
>
> For example:
>
> Assume the sampling frequency of test.wav is 44.1 kHz
>
> [data,Fs] = wavread('test.wav');
> % Fs is 44100
> % assuming data is a single-channel recording
> N = length(data);
> % total duration
> totaldur = N/Fs;
> % create a time vector
> t = linspace(0,totaldur,N);
> % I'm using logical indexing here
> seg1 = data(t>0.2 & t<0.4); % get the data between 0.2 and 0.4 seconds
>
>
> Wayne
|
|
0
|
|
|
|
Reply
|
channlh
|
2/16/2011 6:48:04 PM
|
|
Hi Wayne,
Thank you for your help.
If I have a vector indicating multiple timestamps of where I want to cut, is there a way that I can avoid using 'for loop' and directly index the matrix segments that I want through the data array, then later save it into a wav file thus cutting out the unwanted portion similar to what you did?
Thanks again,
Lok
"Wayne King" <wmkingty@gmail.com> wrote in message <ij5s78$ku2$1@fred.mathworks.com>...
> "Lok" wrote in message <ij49uh$36e$1@fred.mathworks.com>...
> > Hi everybody,
> >
> > I'm rather new to Matlab and I have a question as to how to proceed on cutting out several clips of certain time and duration from an original wav file into a new wav file with the original timestamps preserved. I've done some searching around online and the common consensus seems to be the Matlab functions wavread and wavwrite. I've looked on help for Matlab but I am still rather confused as to how to go about in doing this task. Can anybody provide advice as to what I should do?
> >
> > Thank you,
> >
> > -Lok
>
> Hi Lok, Once you use wavread to import the data into MATLAB, it is a vector (If it is a two-channel recording, it will be a Nx2 matrix, but you can just work on one of the columns). You have to use the sampling frequency, which is an optional output of wavread() to create a time vector to serve as your "time stamps".
>
> Once you know the sampling interval in seconds (fractions thereof..) between the elements of your vector, you can extract whatever portions you need. At that point it's MATLAB indexing.
>
> For example:
>
> Assume the sampling frequency of test.wav is 44.1 kHz
>
> [data,Fs] = wavread('test.wav');
> % Fs is 44100
> % assuming data is a single-channel recording
> N = length(data);
> % total duration
> totaldur = N/Fs;
> % create a time vector
> t = linspace(0,totaldur,N);
> % I'm using logical indexing here
> seg1 = data(t>0.2 & t<0.4); % get the data between 0.2 and 0.4 seconds
>
>
> Wayne
|
|
0
|
|
|
|
Reply
|
channlh
|
2/21/2011 6:38:04 PM
|
|
"Lok" wrote in message <ijubec$n15$1@fred.mathworks.com>...
> Hi Wayne,
>
> Thank you for your help.
> If I have a vector indicating multiple timestamps of where I want to cut, is there a way that I can avoid using 'for loop' and directly index the matrix segments that I want through the data array, then later save it into a wav file thus cutting out the unwanted portion similar to what you did?
>
> Thanks again,
> Lok
>
> "Wayne King" <wmkingty@gmail.com> wrote in message <ij5s78$ku2$1@fred.mathworks.com>...
> > "Lok" wrote in message <ij49uh$36e$1@fred.mathworks.com>...
> > > Hi everybody,
> > >
> > > I'm rather new to Matlab and I have a question as to how to proceed on cutting out several clips of certain time and duration from an original wav file into a new wav file with the original timestamps preserved. I've done some searching around online and the common consensus seems to be the Matlab functions wavread and wavwrite. I've looked on help for Matlab but I am still rather confused as to how to go about in doing this task. Can anybody provide advice as to what I should do?
> > >
> > > Thank you,
> > >
> > > -Lok
> >
> > Hi Lok, Once you use wavread to import the data into MATLAB, it is a vector (If it is a two-channel recording, it will be a Nx2 matrix, but you can just work on one of the columns). You have to use the sampling frequency, which is an optional output of wavread() to create a time vector to serve as your "time stamps".
> >
> > Once you know the sampling interval in seconds (fractions thereof..) between the elements of your vector, you can extract whatever portions you need. At that point it's MATLAB indexing.
> >
> > For example:
> >
> > Assume the sampling frequency of test.wav is 44.1 kHz
> >
> > [data,Fs] = wavread('test.wav');
> > % Fs is 44100
> > % assuming data is a single-channel recording
> > N = length(data);
> > % total duration
> > totaldur = N/Fs;
> > % create a time vector
> > t = linspace(0,totaldur,N);
> > % I'm using logical indexing here
> > seg1 = data(t>0.2 & t<0.4); % get the data between 0.2 and 0.4 seconds
> >
> >
> > Wayne
Hi Lok, In general MATLAB is efficient at indexing an array or vector, but it's hard for me to say for sure in the abstract. Perhaps you can give us a concrete example of what you mean.
Wayne
|
|
0
|
|
|
|
Reply
|
wmkingty (1429)
|
2/21/2011 7:52:04 PM
|
|
Hi Wayne,
Instead of running a "for loop" through the vector of multiple timestamps, is there a way such that I can directly index the matrix elements? So more concretely, my question has to do with "seg1 = data(t>0.2 & t<0.4);". You are manually referencing the part of the vector between 0.2 and 0.4 but is there a way to continually change these parameters without running a for loop?
Thanks,
Lok
"Wayne King" <wmkingty@gmail.com> wrote in message <ijufp4$kdn$1@fred.mathworks.com>...
> "Lok" wrote in message <ijubec$n15$1@fred.mathworks.com>...
> > Hi Wayne,
> >
> > Thank you for your help.
> > If I have a vector indicating multiple timestamps of where I want to cut, is there a way that I can avoid using 'for loop' and directly index the matrix segments that I want through the data array, then later save it into a wav file thus cutting out the unwanted portion similar to what you did?
> >
> > Thanks again,
> > Lok
> >
> > "Wayne King" <wmkingty@gmail.com> wrote in message <ij5s78$ku2$1@fred.mathworks.com>...
> > > "Lok" wrote in message <ij49uh$36e$1@fred.mathworks.com>...
> > > > Hi everybody,
> > > >
> > > > I'm rather new to Matlab and I have a question as to how to proceed on cutting out several clips of certain time and duration from an original wav file into a new wav file with the original timestamps preserved. I've done some searching around online and the common consensus seems to be the Matlab functions wavread and wavwrite. I've looked on help for Matlab but I am still rather confused as to how to go about in doing this task. Can anybody provide advice as to what I should do?
> > > >
> > > > Thank you,
> > > >
> > > > -Lok
> > >
> > > Hi Lok, Once you use wavread to import the data into MATLAB, it is a vector (If it is a two-channel recording, it will be a Nx2 matrix, but you can just work on one of the columns). You have to use the sampling frequency, which is an optional output of wavread() to create a time vector to serve as your "time stamps".
> > >
> > > Once you know the sampling interval in seconds (fractions thereof..) between the elements of your vector, you can extract whatever portions you need. At that point it's MATLAB indexing.
> > >
> > > For example:
> > >
> > > Assume the sampling frequency of test.wav is 44.1 kHz
> > >
> > > [data,Fs] = wavread('test.wav');
> > > % Fs is 44100
> > > % assuming data is a single-channel recording
> > > N = length(data);
> > > % total duration
> > > totaldur = N/Fs;
> > > % create a time vector
> > > t = linspace(0,totaldur,N);
> > > % I'm using logical indexing here
> > > seg1 = data(t>0.2 & t<0.4); % get the data between 0.2 and 0.4 seconds
> > >
> > >
> > > Wayne
>
> Hi Lok, In general MATLAB is efficient at indexing an array or vector, but it's hard for me to say for sure in the abstract. Perhaps you can give us a concrete example of what you mean.
>
> Wayne
|
|
0
|
|
|
|
Reply
|
Lok
|
2/24/2011 12:58:05 AM
|
|
|
8 Replies
209 Views
(page loaded in 2.719 seconds)
Similiar Articles: Removing silent from .wav file using matlab. - comp.soft-sys ...separating speech and music in a sound file - comp.soft-sys.matlab ... i want to separate the speech/voice from the background music in a sound file(.wav file) using ... separating speech and music in a sound file - comp.soft-sys.matlab ...i want to separate the speech/voice from the background music in a sound file(.wav file) using fourier transform. i tried to modify my sound signal by... Read wav file from a path name - comp.soft-sys.matlabHello, I'm building a GUI for a listening project.And I have a textfile which contains all the pathname for a group of wav files. But I need to rea... G726 codec support with .wav files - comp.dspHi All, I want to create and play a G726 (16 kbps) encoded .wav file with Windows Media Player (WMP). I have modified the normal wave header to a... Importing Audio Files - comp.soft-sys.matlabImporting Audio Files - comp.soft-sys.matlab How To Clip ... ... to use it it analyse audio files ... does not recognise the MP3 file ... double> (with WAV and ... Import .m file to simulink or export microphone to .m file - comp ...Hi all, Can i know ho can i import my .m file to simulink? I have done my algorithm with .m file and so far it only works with .wav file. I wish t... Listbox GUI - comp.soft-sys.matlabHow would I make my code, so that the wav files from the current directory load onto the listbox for the gui? ... Creating a Music Player in Matlab - comp.soft-sys.matlab ...I have to create a music player that reads .wav files in matlab. I started off by creating the push buttons in the gui and the listbox as the place t... comp.soft-sys.matlab - page 16How to do a rectangular window on input wav. file 5 8 (10/16/2003 8:44:32 AM) Hi Everyone here, Could anyone of you kindly enlighten me how to do a rectangular window on ... WAV file in dB's - comp.soft-sys.matlabGenerate noise with specific crest factor - comp.dsp WAV file in dB's - comp.soft-sys.matlab Pick the value and do the next: corr_factor=10^(94-V ... wav header in C: A ... How to Cut a WAV File | eHow.comWAV files, designated by a ".wav" extension, are audio files associated with IBM and Microsoft. Users of such files often want to cut them down for use as soundbites ... How to Create WAV Clips | eHow.comWAV clips are lossless files, meaning they are full quality audio. They are native to PC Windows, but are supported by Macs. Fortunately, both PC and Mac users can ... 7/25/2012 6:30:04 AM
|