Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Vexatos

Song API (play whole songs using computer.beep)

Recommended Posts

Basically, this API provides a single function:

song.play(notes: table or string,shortest: number)

Input being either a table or a string. Using a table, each note-duration combination is a string in a table value. The function will iterate through every entry of the table and play all the notes with their specified duration. Using a string, every note-duration combination is seperated by a free space " ".

Regarding the special syntax used, this is copied from the header of the song API:

Examples:
  "E5": Plays the note "E5" for the duration specified in the second parameter (default 0.125, equaling 120 bpm)
  "-E5": Plays the note "E5" with double the specified duration
  "E5_4": Plays the note "E5" with 4 times the specified duration, change "4" to any number x to play the note x times the duration specified
  "P_4": Plays a pause with 4 times the specified duration, change "4" to any number x to play the note x times the duration specified
  For note names, use the syntax of the strings of the Note API

If you haven't already guessed, you require the note API for this to work, just run "pastebin get XwLD0xa8 note" inside the folder you are going to have the song API in. This method utilizes the Note API which is now natively included in OpenComputers. To get the song API, install it via OPPM using "oppm install song" or run "pastebin get R88y1eD2 song". Find the song API on OpenPrograms, at https://github.com/OpenPrograms/Vexatos-Programs/tree/master/song.

 

For an example song, check out the github folder linked, or, alternatively, run "pastebin get i1YC56vJ example" in your computer console and run "example" then.

 

I hope you have fun with the API. Feel free to post any songs you make in the section below!

Sincerely,

Vexatos

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.