From: Willie Wong <wwong@Princeton.EDU>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] tone generator
Date: Thu, 24 Jan 2008 18:44:58 -0500 [thread overview]
Message-ID: <20080124234458.GA21767@princeton.edu> (raw)
In-Reply-To: <196017.20128.qm@web31715.mail.mud.yahoo.com>
On Thu, Jan 24, 2008 at 03:06:38PM -0800, Penguin Lover maxim wexler squawked:
> >
> > compile it, run it like
> >
> > ./a.out | play -t raw -s l -f s -c 1 -r 30000 -
> >
>
>
> This works, sort of. Sounds like a dentist drill going
> in an out.
>
> heathen@localhost ~/docs/c-prog $ ./a.out | aplay -t
> raw -f cdr
> Playing raw data 'stdin' : Signed 16 bit Big Endian,
> Rate 44100 Hz, Stereo
This is because the code outputs it as 32 bit signed with 30000 Hz
rate. The defaults of aplay is sampling it incorrectly, which is why
the file sounds off.
Now, I think I know what the problem is with sox:
1) the commandline syntax changed between 12.* and 14.0, the switches
I need should be
play -t raw -s -4 -c 1 -r 30000
(c.f. man play).
2) Despite what the man pages say, the '-' switch for reading from
stdin seems to be broken. Probably a bug. I'll test more and possibly
file a bug report.
On the other hand, since you have aplay installed, the right syntax
should be
./a.out | aplay -t raw -f S32_LE -c 1 -r 30000
Which says to use 32 bit little endian with 1 channel at a sample rate
of 30000.
Unfortunately, if you do that, you won't hear a thing. Why? I got my
multiplier wrong in the testing program that I send you. I missed half
a byte. Change the definition for coramp (which controls the
amplification) to
int coramp = 0xCFFFFFFF;
(The reason that I missed half a byte was that I was messing around
with harmonics and multiple voicing... so each harmonic needs to be
suitably rescaled in amplitude.)
Hope that helps,
W
--
When my cats aren't happy, I'm not happy. Not because I care about their mood
but because I know they're just sitting there thinking up ways to get even.
~Penny Ward Moser
Sortir en Pantoufles: up 412 days, 22:00
--
gentoo-user@lists.gentoo.org mailing list
next prev parent reply other threads:[~2008-01-24 23:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-24 19:41 [gentoo-user] tone generator maxim wexler
2008-01-24 20:21 ` Willie Wong
2008-01-24 22:27 ` maxim wexler
2008-01-24 23:15 ` Willie Wong
2008-01-24 23:06 ` maxim wexler
2008-01-24 23:44 ` Willie Wong [this message]
2008-01-24 23:22 ` maxim wexler
2008-01-24 23:54 ` Willie Wong
2008-01-24 20:30 ` Etaoin Shrdlu
2008-01-24 20:41 ` Liviu Andronic
2008-01-24 23:26 ` Hemmann, Volker Armin
2008-01-24 23:29 ` maxim wexler
2008-01-24 23:31 ` Iain Buchanan
2008-01-24 23:45 ` maxim wexler
2008-01-25 0:58 ` Iain Buchanan
2008-01-25 1:06 ` Iain Buchanan
2008-01-25 2:13 ` maxim wexler
2008-01-25 3:29 ` Iain Buchanan
2008-01-25 4:15 ` maxim wexler
2008-01-25 5:15 ` Michael Higgins
2008-01-25 2:00 ` maxim wexler
2008-01-25 2:29 ` Iain Buchanan
2008-01-25 6:44 ` Jan Seeger
2008-01-25 18:59 ` maxim wexler
2008-01-25 20:33 ` Michael Higgins
2008-01-25 9:44 ` csound " Ralf Stephan
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=20080124234458.GA21767@princeton.edu \
--to=wwong@princeton.edu \
--cc=gentoo-user@lists.gentoo.org \
/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