Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18318

Re: Generating sin/square waves sound

Newsgroups comp.lang.python
From Peter Billam <peter@www.pjb.com.au>
Subject Re: Generating sin/square waves sound
References <jdjohn$ttr$1@speranza.aioe.org> <jdk706$2qi$1@news.albasani.net> <jdrmg0$m62$2@speranza.aioe.org>
Message-ID <slrnjg30bn.55d.peter@box8.pjb.com.au> (permalink)
Date 2012-01-02 10:05 +0000
Organization Unlimited download news at news.astraweb.com

Show all headers | View raw


On 2012-01-02, Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> wrote:
> Em 30-12-2011 11:23, mblume escreveu:
>> Am Fri, 30 Dec 2011 07:17:13 +0000 schrieb Paulo da Silva:
>> Alternatively you might just generate (t,signal) samples, write
>> them to a file and convert them using "sox" (under Linux, might
>> also be available under Windows) to another format.

That's how I'd do it.
 
Sox can cope with raw samples, provided you tell it stuff like
the sample-rate, sample-size, channels etc.  E.g. from "man sox"
  sox -r 16k -e signed -b 8 -c 1 voice-memo.raw voice-memo.wav
(Once it's in wav form the wav header contains that information.)

> As much as I could understand at a 1st look you are
> writing to a wav file and then play the file.
> It would be nice if I could play directly the samples.

"-d" as an output-file means the "default" output,
which means it plays to your sound card. E.g.:

  sox -r 48k -e float -b 32 -c 2 input.raw -d

The input file can be "-" so you can pipe directly to it:

  sox -r 44100 -e float -b 32 -c 2 - -d

It should also run under windows and macos, and can generate lots
of formats, see "man soxformat".  It also has a "synth" effect
which can generate simple waveforms easily. Sox is useful.

Regards,  Peter

-- 
Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Generating sin/square waves sound Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> - 2011-12-30 07:17 +0000
  Re: Generating sin/square waves sound 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-30 01:51 -0800
  Re: Generating sin/square waves sound Dave Angel <d@davea.name> - 2011-12-30 05:05 -0500
    Re: Generating sin/square waves sound Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> - 2012-01-02 07:24 +0000
      Re: Generating sin/square waves sound Dave Angel <d@davea.name> - 2012-01-02 12:12 -0500
  Re: Generating sin/square waves sound mblume <foobar@invalid.invalid> - 2011-12-30 11:23 +0000
    Re: Generating sin/square waves sound Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> - 2012-01-02 07:31 +0000
      Re: Generating sin/square waves sound Peter Billam <peter@www.pjb.com.au> - 2012-01-02 10:05 +0000
  Re: Generating sin/square waves sound K Richard Pixley <rich@noir.com> - 2011-12-30 17:19 -0800
    Re: Generating sin/square waves sound Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> - 2012-01-02 07:34 +0000
  Re: Generating sin/square waves sound Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> - 2012-01-02 18:09 +0000

csiph-web