Posted 10 February 2016 - 09:25 PM
Computercraft comes with many APIs for text and graphics but there are no native APIs for sound. Now, there happens to be command computers that can run commands like /playsound and while that is good and all, you can only do it on those computers and there are lots of unnecessary options if you only want to play a sound and be able of adjusting the volume and pitch.
I have made an API (my first posted one) that allows you to connect any computer to a command computer via wired modems and use that to play sounds or notes. I have also made a pitch and note API so that you don't have to remember that for example: pitch 0.7 is a C or that note-type 4 is the harp sound.
Usage:
Next you need to download the sound API, and optionally the pitch and note APIs as well, to the host computer (in this case the one to the right), then, download the sound card program to the command computer and run it.
API usage:
Plays a specified sound. If given it will be played in a specified volume and pitch. Defaults for these are vol: 100% and pitch: 1 .
sound.playNote(integer type [, integer volume] [, integer pitch])
Plays a note sound. If given it will be played in a specified volume and pitch. Defaults for these are vol: 100% and pitch: 1 .
Example:
Sound API: pastebin get YnYCcMRG sound
Pitch API: pastebin get eJcMZYP5 pitch
Note API: pastebin get MLDzwYnG note
Sound Card Program: pastebin get e3DUPzrd soundCard
I have made an API (my first posted one) that allows you to connect any computer to a command computer via wired modems and use that to play sounds or notes. I have also made a pitch and note API so that you don't have to remember that for example: pitch 0.7 is a C or that note-type 4 is the harp sound.
Usage:
Spoiler
First of all you need to set up your sound card (command computer) and your host computer by connecting them with wired modems and networking cables like this or similarly:Spoiler
Next you need to download the sound API, and optionally the pitch and note APIs as well, to the host computer (in this case the one to the right), then, download the sound card program to the command computer and run it.
API usage:
Spoiler
sound.playSound(string sound [, integer volume] [, integer pitch])Plays a specified sound. If given it will be played in a specified volume and pitch. Defaults for these are vol: 100% and pitch: 1 .
sound.playNote(integer type [, integer volume] [, integer pitch])
Plays a note sound. If given it will be played in a specified volume and pitch. Defaults for these are vol: 100% and pitch: 1 .
Example:
Spoiler
os.loadAPI("sound")
os.loadAPI("pitch")
os.loadAPI("note")
sound.playSound("[color=#000000]mob.wolf.bark[/color]",0.7)
sleep(2)
sound.playNote(note.pling,1,pitch.gb0)
Spoiler
Sound API: pastebin get YnYCcMRG sound
Pitch API: pastebin get eJcMZYP5 pitch
Note API: pastebin get MLDzwYnG note
Sound Card Program: pastebin get e3DUPzrd soundCard