Drawing sound

Discussion in 'Python' started by Chris, Sep 24, 2004.

  1. Chris

    Chris Guest

    I want a program that can "draw" sound.

    Imagine drawing a graph of frequency against time -
    and then being able to play it over the computer speakers.

    Can this be done in Python?

    As a start, consider this simple QBASIC program that generates random
    frequencies:

    10 frequency = 40 + 400 * RND
    20 SOUND frequency, 7
    30 GOTO 10

    That's fine - except that it plays over the PC speaker - the one that's
    just there for the happy beep - and not through the sound card and
    proper speakers.

    Can that be done in Python?
    Or in any other language?
    --
    Chris
     
    Chris, Sep 24, 2004
    #1
    1. Advertising

  2. Chris

    Peter Hansen Guest

    Chris wrote:
    > I want a program that can "draw" sound.
    >
    > Imagine drawing a graph of frequency against time -
    > and then being able to play it over the computer speakers.
    >
    > Can this be done in Python?
    >
    > As a start, consider this simple QBASIC program that generates random
    > frequencies:
    >
    > 10 frequency = 40 + 400 * RND
    > 20 SOUND frequency, 7
    > 30 GOTO 10
    >
    > That's fine - except that it plays over the PC speaker - the one that's
    > just there for the happy beep - and not through the sound card and
    > proper speakers.
    >
    > Can that be done in Python?
    > Or in any other language?


    Certainly. Python or any other decent general-purpose language
    can do this.

    In Python, you'd want to look into PyGame, or perhaps wxPython
    or one of the other GUI frameworks (provided it has adequate
    sound support... wxPython has the wx.Sound class but I don't know
    whether it's up to the job in this case).

    -Peter
     
    Peter Hansen, Sep 24, 2004
    #2
    1. Advertising

  3. Chris

    fee Guest

    Chris wrote:
    > I want a program that can "draw" sound.
    >
    > Imagine drawing a graph of frequency against time -
    > and then being able to play it over the computer speakers.
    >


    >
    > Can that be done in Python?
    > Or in any other language?


    Using programs to create sound through a soundcard is
    a quite popular activity. What you describe may be
    best done with the program csound (http://www.csounds.com/).

    If you want to do it with python, you might try looking here
    first:

    http://docs.python.org/lib/mmedia.html

    Tobiah
     
    fee, Sep 24, 2004
    #3
  4. It sounds like you are looking for something along the following lines:

    <QUOTE>
    The Snack Sound Toolkit is designed to be used with a scripting language such as
    Tcl/Tk or Python. Using Snack you can create powerful multi-platform audio
    applications with just a few lines of code. Snack has commands for basic sound
    handling, such as playback, recording, file and socket I/O. Snack also provides
    primitives for sound visualization, e.g. waveforms and spectrograms. It was
    developed mainly to handle digital recordings of speech, but is just as useful
    for general audio. Snack has also successfully been applied to other
    one-dimensional signals.
    </QUOTE>

    If so, you can download it from here:

    http://www.speech.kth.se/snack/

    HTH

    "Chris" <nospam@[127.0.0.1]> wrote in message
    news:ttNMvZB0zGVBFwRQ@[127.0.0.1]...
    | I want a program that can "draw" sound.
    |
    | Imagine drawing a graph of frequency against time -
    | and then being able to play it over the computer speakers.
    |
    | Can this be done in Python?
    |
    | As a start, consider this simple QBASIC program that generates random
    | frequencies:
    |
    | 10 frequency = 40 + 400 * RND
    | 20 SOUND frequency, 7
    | 30 GOTO 10
    |
    | That's fine - except that it plays over the PC speaker - the one that's
    | just there for the happy beep - and not through the sound card and
    | proper speakers.
    |
    | Can that be done in Python?
    | Or in any other language?
    | --
    | Chris
     
    Elaine Jackson, Sep 25, 2004
    #4
  5. Chris

    Jeff Sandys Guest

    If you want to play specific notes there are several
    Python Midi packages available.

    Here is a neat article on how to do a power spectral
    density diagram (draw sound):

    http://www.onlamp.com/pub/a/python/2001/01/31/numerically.html

    I think what you are asking is to drag the mouse on a
    canvas and then 'play' the canvas as though it were a
    piano roll? Something like what the MIT Media Lab
    program 'Hyperscore' does.

    Because Python is soooo cross platform there is no one
    way to generate tones on all these platforms, like in
    qbasic. Tinker for the graphics and PyMidi or Snack
    would be your best bet on windows. Pygame has graphics
    and sound capabilities. Other ways are available.

    Thanks,
    Jeff Sandys

    Chris wrote:
    >
    > I want a program that can "draw" sound.
    >
    > Imagine drawing a graph of frequency against time -
    > and then being able to play it over the computer speakers.
    >
    > Can this be done in Python?
    >
    > As a start, consider this simple QBASIC program that
    > generates random frequencies:
    >
    > 10 frequency = 40 + 400 * RND
    > 20 SOUND frequency, 7
    > 30 GOTO 10
    >
    > That's fine - except that it plays over the PC speaker -
    > the one that's just there for the happy beep - and not
    > through the sound card and proper speakers.
    >
    > Can that be done in Python?
    > Or in any other language?
    > --
    > Chris
     
    Jeff Sandys, Sep 25, 2004
    #5
  6. Chris

    M.E.Farmer Guest

    Chris <nospam@[127.0.0.1]> wrote in message news:<ttNMvZB0zGVBFwRQ@[127.0.0.1]>...
    > I want a program that can "draw" sound.
    >
    > Imagine drawing a graph of frequency against time -
    > and then being able to play it over the computer speakers.
    >
    > Can this be done in Python?
    > Or in any other language?

    Hello Chris,
    This may be of intrest to you.
    'http://hem.passagen.se/rasmuse/Coagula.htm'
     
    M.E.Farmer, Sep 25, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sergio Dinis

    How to Serialize System.Drawing.Pen

    Sergio Dinis, Oct 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,464
    Jay B. Harlow [MVP - Outlook]
    Oct 3, 2003
  2. Replies:
    1
    Views:
    646
    Kevin Spencer
    Jan 9, 2006
  3. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,490
    Andrew Thompson
    Oct 31, 2005
  4. Replies:
    0
    Views:
    507
  5. defn noob
    Replies:
    1
    Views:
    403
    Mark Space
    Jun 28, 2008
Loading...

Share This Page