Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:20:17+00:00 2026-06-17T09:20:17+00:00

I’d like to play a little bit with making melodies programmatically. I don’t really

  • 0

I’d like to play a little bit with making melodies programmatically.

I don’t really care about the timbre, although if I could get it to sound like old-school 8-bit music that would be cool.

I would like to be able to play music by simply specifying for each note how long it is, when it is played (starting from the beginning of the song), and its pitch.

I want to use it in the following manner:

from awesomeMelodyLibrary import play

# Perhaps play accepts an iterable of 3-tuples where 
# the items of the tuple are (pitch, duration_of_note, when_to_play)
# and then it would play those notes.
play([ (440, 200, 0),    # A4
       (440, 200, 200),
       (660, 200, 400),  # E5
       (660, 200, 600),
       (740, 200, 800),  # F#5
       (740, 200,1000),
       (660, 400,1200) ])

And it would play the beginning of the alphabet song.

It does not have to be exactly that way, and I’d be fine with some limitations (e.g. be able to play up to only three notes at the same time) but the point is that I don’t want to get dirty with raw sound data, handle details of mixing different sound clips in order to play chords, sound clips, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:20:18+00:00Added an answer on June 17, 2026 at 9:20 am

    Try RTcmix with the Python front-end.

    It works best on OS X, though I use it on Ubuntu. It wasn’t an easy build process, but you can see my post to their discussion list about my installation process on Ubuntu 12.04.

    They have a variety of instruments available. One of my favorites is STRUM2, a plucked string instrument.

    Here’s how you would play a few notes in Python.

    from rtcmix import *
    rtsetparams(44100, 2)
    load("STRUM2")
    noteOnset = 0 #in seconds
    duration = 1.0 # in seconds
    amplitude = 10000
    pitch = 440 # specified in hertz
    squish = 1
    decay = 1.0
    pan = .5 
    STRUM2(noteOnset, duration, amplitude, pitch, squish, decay, pan)
    

    It takes pitches in hertz by default, but this function can convert from MIDI key numbers to hertz.

    def keynumToHertz(keynum):
      lowestfreq = 8.175 #C-1
      return lowestfreq * math.pow(2.0, float(keynum)/12.0)
    

    If you want to specify the notes in standard notation ('Bb6', 'G#8', 'F-1', 'A4') then you could use the nameToNum function I wrote. Find it here.

    Check out the documentation on their site for more complex examples, or my Github repo with implementations of several chapters of Notes from the Metalevel, a text on algorithmic composition. If you’re interested in doing more than just playing hand-specified notes, I highly recommend a reading of that book. It’s written for Lisp/Common Music, but my repo has the Python/RTcmix translations for a lot of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.