This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MysticT's profile picture

NoteBlock API & NoteBlock Player

Started by MysticT, 03 July 2012 - 04:58 PM
MysticT #1
Posted 03 July 2012 - 06:58 PM
Ever wanted to make some music with noteblocks but you don't want or know how to setup the redstone? Then this is what you need.
This apis and programs allows you to play music from your computer using noteblocks. Using RP bundled cables and just 3 computers, you can play all the notes and instruments available in noteblocks.
You need to setup some players (2 should be enough) that send the redstone pulses to the noteblocks, and a controller that sends the data to them.

NoteBlock API
The api has the functions needed to send the data to the players.
It splits the notes and sends them to the corresponding computer.
Functions:
Spoiler

nb.playNote(instrument, note)
-- plays a note in an instrument.
-- instrument: number (1-5)
-- note: number (0-24)
nb.playChord(instrument, notes)
-- plays some notes in an instrument.
-- instrument: number (1-5)
-- notes: table/array of notes
nb.play(t)
-- play some notes on some instruments
-- t: table (see the api file for the format)
nb.playSong(t)
-- play a song
-- t: table (see the api file for the format)

Download: pastebin (code: U0r5Hj38)
Code:
Spoiler

-- NoteBlock Controller API
-- by MysticT

-- Config

-- id of the players
local tIds = {}
-- number of notes per player
local nNotes = 0

-- Instruments
piano = 1
bass = 2
bass_drum = 3
snare_drum = 4
click = 5

local function send(id, t)
	rednet.send(id, "<PLAY> "..textutils.serialize(t))
end

--[[
i: instrument (1-5)
n: note (0-24)
--]]
function playNote(i, n)
	local t = {}
	t[i] = { n }
	local id = tIds[math.floor(n / nNotes) + 1]
	send(id, t)
end

--[[
i: instrument (1-5)
notes: { n1, n2, n3, ..., nN}

n: note (0-24)
--]]
function playChord(i, notes)
	local ts = {}
	for _,n in ipairs(notes) do
		local id = tIds[math.floor(n / nNotes) + 1]
		if not ts[id] then
			ts[id] = {}
		end
		if not ts[id][i] then
			ts[id][i] = {}
		end
		table.insert(ts[id][i], n)
	end
	for id, v in pairs(ts) do
		send(id, v)
	end
end

--[[
Table format:
t = {
[i1] = { n1, n2, n3, ..., nN },
[i2] = { n1, n2, n3, ..., nN },
...
[iN] = { n1, n2, n3, ..., nN }
}

i: instrument (1-5)
n: note (0-24)
--]]
function play(t)
	local ts = {}
	for i, notes in pairs(t) do
		for _,n in ipairs(notes) do
			local id = tIds[math.floor(n / nNotes) + 1]
			if not ts[id] then
				ts[id] = {}
			end
			if not ts[id][i] then
				ts[id][i] = {}
			end
			table.insert(ts[id][i], n)
		end
	end
	for id, v in pairs(ts) do
		send(id, v)
	end
end

--[[
Table format:
t = {
[1] = n,
[2] = n,
[3] = n,
...
[N] = n,
["delay"] = d,
}

d: delay (in seconds), default 0.5
n: instrument-notes table (play() format, see above)
--]]
function playSong(t)
	local nDelay = t.delay or 0.5
	for _,n in ipairs(t) do
		play(n)
		sleep(nDelay)
	end
end

NoteBlock Player
This is what actually plays the noteblocks, by sending redstone pulses to the corresponding noteblock.
It receives messages over rednet from the controller, then decodes the message and plays the corresponding notes and instruments.

Download: pastebin (code: PdG4imtY)
Code:
Spoiler

-- NoteBlock Player
-- by MysticT

-- Config

-- id of the controller computer
local nControllerID = 0
-- sides corresponding to each instrument
-- order: piano, bass, bass drum, snare drum, click
local tSides = {}
-- colors corresponding to each note
local tColors = {}
-- pulse sleep time
local nPulse = 0.1

-- Functions

-- clear the screen
local function clear()
	term.clear()
	term.setCursorPos(1, 1)
end

-- detect modem and connect
local function connect()
	for _,s in ipairs(rs.getSides()) do
		if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
			rednet.open(s)
			return true
		end
	end
	return false
end

-- send a pulse
--[[
table format:
t = {
[side1] = colors,
[side2] = colors,
...
[sideN] = colors,
}
--]]
local function pulse(t)
	for side, c in pairs(t) do
		rs.setBundledOutput(side, c)
	end
	sleep(nPulse)
	for side,_ in pairs(t) do
		rs.setBundledOutput(side, 0)
	end
	sleep(nPulse)
end

-- play the given notes on the given instruments
--[[
table format:
t = {
[i1] = { n1, n2, ..., nN },
[i2] = { n1, n2, ..., nN },
...
[iN] = { n1, n2, ..., nN }
}

i: instrument number (range defined by the sides table)
n: notes (range defined by the colors table)
--]]
local function play(t)
	print("Playing...")
	local tPulse = {}
	for i, notes in pairs(t) do
		print("Instrument: ", i)
		local side = tSides[i]
		if side then
			if type(notes) == "table" then
				print("Notes: ", unpack(notes))
				local c = 0
				for _,n in ipairs(notes) do
					local k = tColors[n]
					if k then
						c = colors.combine(c, k)
					else
						print("Unknown note: ", n)
					end
				end
				tPulse[side] = c
			else
				print("Wrong format. table expected, got ", type(notes))
			end
		else
			print("Unknown Instrument")
		end
	end
	pulse(tPulse)
end

-- Start Program

-- try to connect to rednet
if not connect() then
	print("No modem found")
	return
end

clear()
print("Waiting for messages...")

-- start receiving
while true do
	local id, msg = rednet.receive()
	if id == nControllerID then
		local t = string.match(msg, "<PLAY> (.+)")
		if t then
			local notes = textutils.unserialize(t)
			if notes then
				play(notes)
			end
		end
	end
end

Setup
SpoilerOk, this is the hardest part. You need to setup the noteblocks, players and the controller.
Noteblock setup:
This is just placing the noteblocks in the different types of terrain to have all the instruments and then setting each of them to the correct note (by right-clicking them). It can be time consuming, but it should be easy to do.
Players setup:
Now you need to put the computers and wire them to the noteblocks. You will need to connect the computer to each noteblock with a different cable color, that's why you need at least 2 computers (16 colors, 25 notes, 5 instruments). Each computer can have 5 bundled cables attached (the other side is used by the modem), and each cable can have 16 different color cables. So the best way is to use a bundled cable for each instrument, and use one computer for the first 16 notes and another one for the last 9.
Once you'r done with that, copy the NoteBlock Player program to the computers startup. Now you have to set the config for each computer, it's at the top of the player program (wich should be in the startup file now):
Controller ID:
local nControllerID = 0
If you already know wich will be the controller computer, write it's id here.
Cable sides:
local tSides = {}
Add the sides you use for the bundled cables, ordered by instrument: piano, bass, bass drum, snare drum, click.
Colors:
local tColors = {}
Set the colors corresponding to each note. It has to be like: [note number] = color
Pulse time:
local nPulse = 0.1
This is the time used for the pulses (turn on, sleep, turn off, sleep). 0.1 is a good value, you can change it, but it might cause troubles like skiping notes if it's too low or too high.
Controller setup:
Just place a computer with a modem, and copy the NoteBlock API to the root of the computer (save it as "nb", or it won't load it). You need to configure the api to work for your setup:
Id of the players:
local tIds = {}
This is the list of player's ids, ordered by the notes they play (the first one in the list plays the first n notes, the second the next n notes, etc.).
Notes per player:
local nNotes = 0
This is the amount of notes for each player. The last player can have less than this value, but the rest should have that value, or it won't work.

Here's an example of a setup (this is the setup I used to test):
SpoilerPictures:
Spoiler







Player 1 (right computer) Configuration (id 18):

-- id of the controller computer
local nControllerID = 19
-- sides corresponding to each instrument
-- order: piano, bass, bass drum, snare drum, click
local tSides = { "top", "left", "back", "right", "bottom" }
-- colors corresponding to each note
local tColors = {}
-- from 0 to 15, the first 16 notes, the first 16 colors
for i = 0, 15 do
	tColors[i] = 2 ^ i
end
-- pulse sleep time
local nPulse = 0.1
Player 2 (left computer) Configuration (id 17):

-- id of the controller computer
local nControllerID = 19
-- sides corresponding to each instrument
-- order: piano, bass, bass drum, snare drum, click
local tSides = { "bottom", "right", "back", "left", "top" }
-- colors corresponding to each note
local tColors = {}
-- from 16 to 24, the last 9 notes, the first 9 colors
for i = 0, 8 do
	tColors[i + 16] = 2 ^ i
end
-- pulse sleep time
local nPulse = 0.1
API Configuration (id 19):

-- id of the players
local tIds = { 18, 17 }
-- number of notes per player
local nNotes = 16

NBPlayer
With this program you can play songs stored in files. The format of the files is a serialized table, wich is sent to the nb api to decode and send to the players.

Usage:
NBPlayer <song file>
<song file>: the file to play. It must be a path to a file with the player format.

Download: pastebin (code: WZWVS5Fz)
Code:
Spoiler

-- NBPlayer
-- by MysticT

-- load the nb api
if not nb then
	os.loadAPI("nb")
	if not nb then
		print("Couldn't load nb api. Check if you installed it correctly.")
		return
	end
end

-- detect a modem and connect
local function connect()
	for _,s in ipairs(rs.getSides()) do
		if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
			rednet.open(s)
			return true
		end
	end
	return false
end

-- try to connect to rednet
if not connect() then
	print("No modem found")
	return
end

-- play a song file
local function playFile(sPath)
	local file = fs.open(sPath, "r")
	if file then
		local s = file.readAll()
		file.close()
		local tSong = textutils.unserialize(s)
		if tSong and type(tSong) == "table" then
			local title = tSong.name
			if not title or title == "" then
				title = "Untitled"
			end
			local author = tSong.author
			if not author or author == "" then
				author = "Unknown"
			end
			print("Playing: ", title, " - by ", author)
			if tSong.original_author and tSong.original_author ~= "" then
				print("Original Author: ", tSong.original_author)
			end
			if tSong.lenght then
				print("Lenght: ", tSong.lenght)
			end
			nb.playSong(tSong)
			return true
		end
		return false, "Unknown file format."
	end
	return false, "Error opening file "..sPath
end

-- Start Program

-- get arguments
local tArgs = { ... }
if #tArgs ~= 1 then
	print("Usage: nbplay <file>")
	return
end

-- load and play the file
local ok, err = playFile(tArgs[1])
if not ok then
	return false, err
end

And if that's not enough, you can grab your favourite song in nbs (NoteBlock Song, from NoteBlock Studio) format and convert it or play it directly using this programs. So you can take a midi file, use NoteBlock Studio to convert it to nbs and then play it with this, no need to export to schematic files.

NBS API
This api provides functions to load nbs files and save them in the format used by the NBPlayer.
Functions:
Spoiler

nbs.load(path, verbose)
-- load an nbs file
-- path: the path to the nbs file
-- verbose: boolean, true to print information during load process
-- return value: the loaded song in a table format.
nbs.saveSong(song, path)
-- save a converted song to a file
-- song: a song table loaded using the load function
-- path: the path to save the song

Installation: save it to the root of the computer (or to /rom/apis) as "nbs".

Download: pastebin (code: 0SN5Tftz)
Code:
Spoiler

-- NoteBlock Song API
-- by MysticT

-- yield to avoid error
local function yield()
	os.queueEvent("fake")
	os.pullEvent("fake")
end

-- read short integer (16-bit) from file
local function readShort(file)
	return file.read() + file.read() * 256
end

-- read integer (32-bit) from file
local function readInt(file)
	return file.read() + file.read() * 256 + file.read() * 65536 + file.read() * 16777216
end

-- read string from file
local function readString(file)
	local s = ""
	local len = readInt(file)
	for i = 1, len do
		local c = file.read()
		if not c then
			break
		end
		s = s..string.char(c)
	end
	return s
end

-- read nbs file header
local function readNBSHeader(file)
	local header = {}
	header.lenght = readShort(file)
	header.height = readShort(file)
	header.name = readString(file)
	if header.name == "" then
		header.name = "Untitled"
	end
	header.author = readString(file)
	if header.author == "" then
		header.author = "Unknown"
	end
	header.original_author = readString(file)
	if header.original_author == "" then
		header.original_author = "Unknown"
	end
	header.description = readString(file)
	header.tempo = readShort(file) / 100
	header.autosave = file.read()
	header.autosave_duration = file.read()
	header.time_signature = file.read()
	header.minutes_spent = readInt(file)
	header.left_clicks = readInt(file)
	header.right_clicks = readInt(file)
	header.blocks_added = readInt(file)
	header.blocks_removed = readInt(file)
	header.filename = readString(file)
	return header
end

-- empty table, for empty ticks
local tEmpty = {}

-- jump to the next tick in the file
local function nextTick(file, tSong)
	local jump = readShort(file)
	for i = 1, jump - 1 do
		table.insert(tSong, tEmpty)
	end
	return jump > 0
end

-- read the notes in a tick
local function readTick(file)
	local t = {}
	local jump = readShort(file)
	while jump > 0 do
		local instrument = file.read() + 1
		if instrument > 5 then
			return nil, "Can't convert custom instruments"
		end
		local note = file.read() - 33
		if note < 0 or note > 24 then
			return nil, "Notes must be in Minecraft's 2 octaves"
		end
		if not t[instrument] then
			t[instrument] = {}
		end
		table.insert(t[instrument], note)
		jump = readShort(file)
	end
	return t
end

-- API functions

-- save a converted song to a file
function saveSong(tSong, sPath)
	local file = fs.open(sPath, "w")
	if file then
		file.write(textutils.serialize(tSong))
		file.close()
		return true
	end
	return false, "Error opening file "..sPath
end

-- load and convert an .nbs file and save it
function load(sPath, bVerbose)
	local file = fs.open(sPath, "rb")
	if file then
		if bVerbose then
			print("Reading header...")
		end
		local tSong = {}
		local header = readNBSHeader(file)
		tSong.name = header.name
		tSong.author = header.author
		tSong.original_author = header.original_author
		tSong.lenght = header.lenght / header.tempo
		tSong.delay = 1 / header.tempo
		if bVerbose then
			print("Reading ticks...")
		end
		while nextTick(file) do
			local tick, err = readTick(file, tSong)
			if tick then
				table.insert(tSong, tick)
			else
				file.close()
				return nil, err
			end
			yield()
		end
		file.close()
		return tSong
	end
	return nil, "Error opening file "..sPath
end

NBS Player
Loads an nbs file and then it plays it. It's recommended to use the NBSConverter and NBPlayer, since the loading can take a while for long songs.

Usage:
NBSPlayer <nbs file>
<nbs file>: the nbs file to play

Example:
NBSPlayer MySong.nbs

Download: pastebin (code: aBWwUsWe)
Code:
Spoiler

-- NoteBlock Song Player
-- by MysticT

-- load the nb and nbs apis
if not nb then
	os.loadAPI("nb")
	if not nb then
		print("Couldn't load nb api. Check if you installed it correctly.")
		return
	end
end
if not nbs then
	os.loadAPI("nbs")
	if not nbs then
		print("Error loading nbs api. Check you installed it correctly.")
		return
	end
end

-- detect a modem and connect
local function connect()
	for _,s in ipairs(rs.getSides()) do
		if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
			rednet.open(s)
			return true
		end
	end
	return false
end

-- try to connect to rednet
if not connect() then
	print("No modem found")
	return
end

-- load and play an nbs file
local function playFile(sPath)
	local tSong, err = nbs.load(sPath)
	if tSong then
		print("Playing: ", tSong.name, " - by ", tSong.author)
		if tSong.original_author ~= "" then
			print("Original Author: ", tSong.original_author)
		end
		print("Lenght: ", tSong.lenght)
		nb.playSong(tSong)
		return true
	end
	return false, err
end

-- Start Program

-- get arguments
local tArgs = { ... }
if #tArgs ~= 1 then
	print("Usage: nbsplay <file>")
	return
end

-- play the file
local ok, err = playFile(tArgs[1])
if not ok then
	return false, err
end

NBSConverter
Converts a nbs file to the format used by NBPlayer. This format loads faster than nbs, so it's recommended to use it, specially for long songs.

Usage:
NBSConverter <nbs file> <output name>
<nbs file>: the path to the nbs file to convert.
<output name>: the name to use when saving the converted song.

Example:
NBSConverter MySong.nbs MySong
It will convert the file MySong.nbs and save it as MySong

Download: pastebin (code: 9cCAJtgm)
Code:
Spoiler

-- NBS File Converter
-- by MysticT

-- load nbs api
if not nbs then
	os.loadAPI("nbs")
	if not nbs then
		print("Error loading nbs api. Check you installed it correctly.")
		return
	end
end

-- Start program

-- get arguments
local tArgs = { ... }
if #tArgs ~= 2 then
	print("Usage: nbsconvert <file path> <save path>")
	return
end

-- load the song from the nbs file
print("Converting...")
local tSong, err = nbs.load(tArgs[1], true)
if tSong then
	print("File loaded")
	print("Title: ", tSong.name)
	print("Author: ", tSong.author)
	print("Original Author: ", tSong.original_author)
	print("Lenght: ", tSong.lenght)
else
	print("Error: ", err)
	return
end

-- save the converted song to a file
local ok, err = nbs.save(tSong, tArgs[2])
if ok then
	print("nFile saved to", tArgs[2])
else
	print("Error: ", err)
end

Ok, hope you enjoy it :P/>/>
Any feedback is welcome.
cant_delete_account #2
Posted 03 July 2012 - 09:35 PM
This is awesome! Especially the nbs converter.
CAHbl4 #3
Posted 05 July 2012 - 01:01 AM
NBS API line 129:
while nextTick(file) do
should be:
while nextTick(file, tSong) do

NBSconvert line 37:
local ok, err = nbs.save(tSong, tArgs[2])
should be:
local ok, err = nbs.saveSong(tSong, tArgs[2])

And when i try to convert nbs to nb i receive error message:
textutils:112: Cannot serialize table with recursive entries

ComputerCraft v1.33
CraftOS 1.3
MysticT #4
Posted 05 July 2012 - 02:14 AM
NBS API line 129:
while nextTick(file) do
should be:
while nextTick(file, tSong) do

NBSconvert line 37:
local ok, err = nbs.save(tSong, tArgs[2])
should be:
local ok, err = nbs.saveSong(tSong, tArgs[2])

And when i try to convert nbs to nb i receive error message:
textutils:112: Cannot serialize table with recursive entries

ComputerCraft v1.33
CraftOS 1.3
Thanks, already fixed. It was due to some last minute changes to the code. The serialization problem was because I tested it with another serialization function, wich can handle recursive tables and makes the result smaller than the one used in CraftOS, it should be fixed now.
Theking4562 #5
Posted 01 August 2012 - 06:58 AM
You did a Great job explaing how to set up the system but when i load a program exp:"NoteBlockStudio converter" it gives me [attachment=357:2012-08-01_01.55.02.png] and i'am using tekkit and a offcial note block studio song

Ps: my tilte speaks the truth
MysticT #6
Posted 01 August 2012 - 03:35 PM
You did a Great job explaing how to set up the system but when i load a program exp:"NoteBlockStudio converter" it gives me [attachment=357:2012-08-01_01.55.02.png] and i'am using tekkit and a offcial note block studio song

Ps: my tilte speaks the truth
It looks like the nbs file is missing, check that you placed it in the root folder and it's named nbs, it won't find it otherwise. Also, reboot the computer so it can reload the api.
Theking4562 #7
Posted 01 August 2012 - 10:23 PM
what do you mean my root folder , put it directly in lua or make sure the folders exp:/rom/Nbs exist or the extension is .nbs
Ps: the api you made shows up when i lanch command: apis
Pss: can you make a detail written/vidio tututriol on the setup in your world
MysticT #8
Posted 01 August 2012 - 10:54 PM
The api files must be named nb and nbs (in lowercase). If you put them inside rom/apis, they should be loaded at startup and you'll see them when using the "apis" program. If you see them (and the names are right), then the programs should work.
I'll try to make a more detailed tutorial (maybe a video), but I'm bussy now, so it will take some time.
Theking4562 #9
Posted 02 August 2012 - 12:51 AM
Thanks the api are working
and i hope i'am not troubling you to much
but where the root to put the songs for conversions (without the file path nonsense) exp:/rom/ or /lua/ because i'am now getting error cannot open file while converting
Ps: you set the beats left-right lowest to highest , correct?
MysticT #10
Posted 02 August 2012 - 02:04 AM
but where the root to put the songs for conversions (without the file path nonsense) exp:/rom/ or /lua/ because i'am now getting error cannot open file while converting
The root of the computer is the directory where all the computer files are. To put a file there (outside the game) you need to go to .minecraft/saves/<YourWorld>/computer/<Computer ID> and copy it there.

Ps: you set the beats left-right lowest to highest , correct?
I have them right-left (looking from the front) lowest to highest, but you can change that in the config.
Leonardoas111 #11
Posted 05 August 2012 - 06:27 PM
When I try to use the NBSConverter it says:
nbs:72: bad argument: table expected, got nil

Which is weird, since there's only an 'end' there

EDIT: Nevermind. I used the pastebin version and restarted the server


The player skips some notes on fast songs. It's a little bit annoying. Is there a way to fix this?
MysticT #12
Posted 05 August 2012 - 09:38 PM
The player skips some notes on fast songs. It's a little bit annoying. Is there a way to fix this?
The problem is that redstone pulses can't be too short, or the noteblock won't play the note. You can try to lower the pulse duration in the config, but it may skip more notes or just don't play. If it doesn't work, you'll have to increase the tempo of the song, it will play slower but won't skip any notes.
Leonardoas111 #13
Posted 07 August 2012 - 12:00 AM
The player skips some notes on fast songs. It's a little bit annoying. Is there a way to fix this?
The problem is that redstone pulses can't be too short, or the noteblock won't play the note. You can try to lower the pulse duration in the config, but it may skip more notes or just don't play. If it doesn't work, you'll have to increase the tempo of the song, it will play slower but won't skip any notes.

The weird thing is that when I lower the pulse duration, the piano works perfectly, but the bass doesn't play if the piano is playing too many notes.

EDIT: Can I make one computer for each instrument?
MysticT #14
Posted 07 August 2012 - 01:27 AM
Hmm, that's weird. I'll look into it.

EDIT: Can I make one computer for each instrument?
Yes, but it would require some changes to the code. It should work better that way, so I'll try to make it an option in the config.
turkeygiblets #15
Posted 08 August 2012 - 02:27 PM
Awesome stuff here.

I did have issues with missing notes for fast songs though, so I had to tweak it a bit, first I tried splitting the pulse durations for on and off, which helped a bit(only needs to be off for 0.01 it seems and it still works ok), then I split the computers based on instruments, which helped a bit on slow songs with lots of notes, but it still didnt help on fast songs. Finally, I managed to make it play even challenging songs like the Turkish March included with NBS almost perfectly by connecting each computer to 2 of the same instrument (even more wiring :/), and changing the clients to alternate between which they play the notes on (when it plays a note, it also turns the other set of notes off, so you dont need to wait to turn off again in each tick). Only problem now, is it tends to cause my sister on a dodgy internet connection to disconnect ;)/>/>
master39 #16
Posted 11 August 2012 - 10:47 PM
very awesome work, i made a video song using your program, and I put the link to this thread, can I put the save for download? in the save there are all your programs and a player like your's.
can you add a video section to the post and add my video?
http://www.youtube.com/watch?v=XHk-rCY_uk8
TomasJAnderson #17
Posted 16 August 2012 - 07:36 PM
Great job I must say the notes are playing flawlessly unfortunately I'm having issues with the tempo. All the songs are playing very slowly, not too sure if anybody else is experiencing this problem.
Cranium #18
Posted 25 September 2012 - 10:51 PM
I have been working on something like this for a while. I have not even come close to what you have. Well done.
killavirus #19
Posted 12 October 2012 - 04:07 AM
Hi there,

I have built it to the best of my understanding but just get


Unknown Note: 17
playing instrument: 2 
Notes: 17 
Unknown note: 17

the format for naming the notes i am using

local tColors = {[1] = white, [2] = orange, [3] = magenta, [4] = lightBlue, [5] = yellow, [6] = lime, [7] = pink, [8] =  gray, [9] = lightGray, [10] = cyan, [11] = purple, [12] = blue, [13] = brown, [14] = green, [15] = red, [16] = black }

Many thanks
Cranium #20
Posted 12 October 2012 - 05:26 AM
I am trying to set this up on a server, but the server does not have redpower. How would I convert this to be used with regular redstone pulses?
killavirus #21
Posted 12 October 2012 - 12:49 PM
ok got the syntax sussed i thought i had tried it already but i guess i had done typo/or something! and was being stooopid !!

local tColors = { [1] = colors.white, [2] = colors.orange, [3] = colors.magenta, [4] = colors.lightBlue, [5] = colors.yellow, [6] = colors.lime, [7] = colors.pink, [8] = colors.gray, [9] = colors.lightGray, [10] = colors.cyan, [11] = colors.purple, [12] = colors.blue, [13] = colors.brown, [14] = colors.green, [15] = colors.red, [16] = colors.black }

^^ that works for me :)/>/>


Many thanks Your API is awesome.

If anybody else has trouble on this feel free to contact me to take a look at a working version on our server.
killavirus #22
Posted 12 October 2012 - 02:02 PM
I am trying to set this up on a server, but the server does not have redpower. How would I convert this to be used with regular redstone pulses?
Sorry just having a ponder about this and would suggest going down the route of attaching noteblocks to the computers and leaving redstone out of this.
This would increase the size somewhat and confuse the hell out of you trying to keep track of which computer is doing which instrument &amp; note :)/>/>
only way i can see you can do it without bundled cables
Cranium #23
Posted 12 October 2012 - 03:02 PM
Sorry just having a ponder about this and would suggest going down the route of attaching noteblocks to the computers and leaving redstone out of this.
This would increase the size somewhat and confuse the hell out of you trying to keep track of which computer is doing which instrument &amp; note :)/>/>
only way i can see you can do it without bundled cables
Well, I do have that set up so far, with two noteblocks, one on left,, and one on right, I was just wondering how I set up the code?
Cranium #24
Posted 23 October 2012 - 03:13 AM
Now I'm having trouble with the notes. I keep getting errors saying each note is an unknown note….. What did I do wrong?

Edit: I do have RP2 on the server now, and everything should be set up the same way on the example, except for positioning.
Edited on 23 October 2012 - 02:36 AM
Cranium #25
Posted 15 November 2012 - 06:32 AM
Alright. This is the best ever. It is a huge lag machine for some servers, but it still works. My favorite song so far? Ghostbusters. Here is the converted table for those of youwho want to play it:
http://pastebin.com/iVwVHX32
I'll also include most of the songs I converted as well. Enjoy the fruits of my labor!
https://www.dropbox.com/sh/qor2qq0iujkxsbr/T2ztVkGLip
Edited on 15 November 2012 - 05:51 AM
Cranium #26
Posted 25 November 2012 - 03:09 PM
I have been getting obsessed with this the last few months, and have been converting .nbs songs like mad. However, Noteblock Studio is a very poor means to make Minecraft music. It's always slow, and skips notes. It also does not like converting MIDIs like it should. Would there be a way for you to make a MIDI converter?
Geforce Fan #27
Posted 01 December 2012 - 06:37 PM
Can I have the world download so I don't have to set it up?
omnislash772 #28
Posted 18 December 2012 - 02:56 AM
i keep getting this every time no matter what i do i have used the pastebin version but no matter what i always get this
it appears to be an issue with the nb api line 74 but i cant code in lua so i have no clue whats going on this is on a server running tekkit i will also attach the file its attempting to play http://pastebin.com/K71BzTb3

can someone please tell me what i am doing wrong?
Yobi #29
Posted 29 December 2012 - 09:17 AM
Is there any way to get this to work with the iron note blocks from RichardG's miscperipherals addon? It would be perfect for this.
Cranium #30
Posted 29 December 2012 - 09:37 AM
i keep getting this every time no matter what i do i have used the pastebin version but no matter what i always get this
it appears to be an issue with the nb api line 74 but i cant code in lua so i have no clue whats going on this is on a server running tekkit i will also attach the file its attempting to play http://pastebin.com/K71BzTb3

can someone please tell me what i am doing wrong?
Try using the converter to convert the files from .nbs format to a CC file, that way it sees the table it needs. If you have already converted it, remove the .nbs extension.
Yobi #31
Posted 30 December 2012 - 08:49 AM
Never mind, I figured out how to.
zenith123138 #32
Posted 18 January 2013 - 03:16 PM
when i try to play nbs files i just get no modem detected or somesuch and when i try to converter nbs files to nb files it just tells me how to do it and nothing else. could someone who is totally new to this tell me what to do please.
ManIkWeet #33
Posted 27 January 2013 - 03:20 PM
I totally edited this to work with Miscperipheral's iron noteblocks! :)/>
Only the file that actually plays the notes had to be edited, also the Miscperipheral's instruments have different numbers :(/>
The program needs 2 iron noteblocks, because they can only play 5 notes/tick.
omnislash772 #34
Posted 04 February 2013 - 03:36 PM
i keep getting this every time no matter what i do i have used the pastebin version but no matter what i always get this
it appears to be an issue with the nb api line 74 but i cant code in lua so i have no clue whats going on this is on a server running tekkit i will also attach the file its attempting to play http://pastebin.com/K71BzTb3

can someone please tell me what i am doing wrong?
Try using the converter to convert the files from .nbs format to a CC file, that way it sees the table it needs. If you have already converted it, remove the .nbs extension.
i tried that (several times) but it didn't work
WeaponMaster #35
Posted 08 February 2013 - 02:40 AM
I totally edited this to work with Miscperipheral's iron noteblocks! :)/>
Only the file that actually plays the notes had to be edited, also the Miscperipheral's instruments have different numbers :(/>
The program needs 2 iron noteblocks, because they can only play 5 notes/tick.
how? can you post the script? i am a complete idiot in coding :/ but i really want to make this setup. i also can't fully get how to use the OP :(/>
omnislash772 #36
Posted 10 February 2013 - 05:49 AM
i wouldnt mind the lua files in a zipped format so i can just throw it into the server to make sure it isnt coppying weird
also yes iron noteblocks version!
Shady1765 #37
Posted 10 February 2013 - 05:06 PM
could someone post the scripts for the iron noteblock version? i've tried to edit the files but havnt has much success.
Left4Cake #38
Posted 15 February 2013 - 04:51 AM
I made a programe that plays the convrted NBS files, with iron note blocks.

http://www.computercraft.info/forums2/index.php?/topic/10449-iron-note-block-player/page__pid__87058#entry87058
roughy #39
Posted 25 February 2013 - 02:49 AM
after i made the startup program following your tutorial i get waiting for messages when i entered startup in the computer is this supposed to happen because i can't even do anything with that computer anymore right after i reset the computer it prompts again. i am very new to this so some help would be appriciated
Slaughtz #40
Posted 01 June 2013 - 02:59 AM
This is amazing. I plan to do a video tutorial on it when I build it again on a multiplayer server.

However, I was wondering if someone could help explain to me how to split the work between more than 2 players because the melody (grass block notes) are constantly jammed with signals and I want to split the playback between two rows of them so they aren't congested and I can get the full sound.
reububble #41
Posted 16 July 2013 - 06:03 AM
I'd like to add valuable input here. I have a video of my composition software [media]http://www.youtube.com/watch?v=edvU0OsZITA[/media].
Basically I allow you to edit the files inside the terminal. I added my own file format to shrink down the size.
I show you how to convert music from MIDI files in the video, be assured I have made a converter for NBS files too, they're a lot easier to parse than MIDI is.

EDIT: There's a new version out now which uses command blocks rather than iron noteblocks
Edited on 17 August 2013 - 06:18 PM