Function File Submission: deinterleave (deinterleaver of audio channels)
Himanshu Singh Chauhan <[email protected]> Tue, 06 Jun 2006 07:29:50 +0530
| Newsgroups | gmane.comp.gnu.octave.sources |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --------------060705030102020405030601 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit The deinterleave function file deinterleaves the interleaved audio channels from the given buffer and returns a matrix with each row corresponding to a channel. Regards --Himanshu -- ---------------------------------------- Himanshu Chauhan MCA (Final Year) I.G. National Open University Jaipur (India) Mobile:(+91)-(98292)-(92757) Web: http://members.lycos.co.uk/hschauhan Email: [email protected] "Education is what remains after one has forgotten everything he learned in school." -- A. Einstein. ---------------------------------------- --------------060705030102020405030601 Content-Type: text/x-objcsrc; name="deinterleave.m" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="deinterleave.m" ## Copyright (C) 2006 Himanshu S. Chauhan ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## -*- texinfo -*- ## @deftypefn {Function File} {@var{deinterlace_matrix}} deinterleave (@var{buffer}, @var{nchannels}, @var{nsamples}) ## ## Deinterleaves the audio data provided in the buffer and returns a matrix ## with @var{nchannels} row and @var{nsamples}/@var{nchannels} columns. This ## way each row is a deinterlaced channel. ## ## Example: ## intr_mat = deinterleave(audiodata, numchannel, numsamples) ## ## Please note that argument @var{nsamples} should be at boundary of the ## provided channels,i.e., if 3 channels @var{nsamples} should be a multiple of 3. ## @end deftypefn ## ## @seealso{loadaudio, saveaudio} ## Author: Himanshu S. Chauhan ## Created: June 4, 2006 function deinterlace_matrix = deinterleave(buffer, nchannels, nsamples) # check for valid number of arguments. if (nargin < 3) error('Invalid number of arguments.'); endif # The buffer should be at the channels boundary. if (mod(nsamples, nchannels)) error('The provided signal buffer is not on the channels boundary.'); endif sample_frames = nsamples / nchannels; deinterlace_matrix = zeros(nchannels, sample_frames); frame_count = 1; # Iterate through all sample frames. # At one time, we are processing all channels present # in the sample frame. for i=1:nchannels:nsamples for j=0:nchannels-1 # Each row of the matrix corresponds an input channel in the # input buffer. As at one time, we are procesing all channels # present in the frame, the row changes quite frequently then # the number of columns. deinterlace_matrix((j + 1), frame_count) = buffer(i+j); endfor # Point to the next sample frame. frame_count = frame_count + 1; endfor endfunction --------------060705030102020405030601 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Octave-sources mailing list [email protected] https://www.cae.wisc.edu/mailman/listinfo/octave-sources --------------060705030102020405030601--