9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] An acid-question
Date: Sat, 15 Jul 2006 07:15:41 -0500	[thread overview]
Message-ID: <dbe56955b746c9a0e9b294149b1d5d70@quanstro.net> (raw)
In-Reply-To: <556331fdcd517d6b61d38f6c14ee3f88@mail.gmx.net>

your loop test has an obiwan error:

		for(i=0;i <= inbyterate;i++) {

should be
		for(i = 0; i < inbyterate; i++);

- erik

On Sat Jul 15 06:42:57 CDT 2006, sretzki@gmx.de wrote:
> Okay, I will never write pseudo-like code to demonstrate what I mean :/
>
> fmt is a structure holding all meta-data of the audio-input. convertchannels() is called by a function which reads fmt->byterate audio-data from stdin, and provides another array big enough to hold a copy of the input-data (datacopy).
>
> void
> convertchannels(short *data, short *datacopy)
> {
> 	int i, j = 0;
> 	int inbyterate = fmt->samplerate * fmt->channels * 2;
>
>
> 	memcpy(datacopy,data,inbyterate * sizeof(short));
>
>
> 	if(fmt->channels == 1) {
>
> 		for(i=0;i <= inbyterate;i++) {
>
> 			/* mono to left ... */
> 			data[j++] = datacopy[i];
>
> 			/* mono to right ... */
> 			data[j++] = datacopy[i];
>
> 		}
> 	}
> 	else
> 		sysfatal("convertchannels(): I can just convert from mono to stereo :-/\n");


  reply	other threads:[~2006-07-15 12:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-15 10:55 Sascha Retzki
2006-07-15 11:22 ` erik quanstrom
2006-07-15 15:28   ` Sascha Retzki
2006-07-15 12:15     ` erik quanstrom [this message]
2006-07-15 12:36       ` Sascha Retzki
2006-07-15 12:39         ` erik quanstrom
2006-07-15 17:02         ` jmk
2006-07-15 17:09           ` Sascha Retzki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbe56955b746c9a0e9b294149b1d5d70@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).