Now the 2 solutions available for CC don't seem to be available in CC so I tried around a bit with events... Didn't work as intended and even got a crashing computer out of it...
Here's my code:
local component = require("component")
local counter = 1
local noteblocks = {}
for address, componentType in component.list("music") do
print(tostring(address) .. "," .. componentType)
noteblocks[counter] = component.proxy(address)
counter = counter + 1;
end
for _,nb in pairs(noteblocks) do
nb.trigger(10)
end
local computer = require("computer")
local event = require("event")
function trigger()
component.musicblock.trigger(15)
end
event.listen("note", trigger)
for i=1, 10 do
computer.pushSignal("note")
end
event.pull()
print("finish")
To replicate my issue, just place an adapter anywhere with one or more noteblocks connected to it.
If you run the program you'll hear a clear delay between each note, music will need multiple notes at once...
Preferably I want multiple notes to play instantly out of one single noteblock, but if that's impossible then I guess multiple will have to do...
As for the memory leak:
Running this part of the code
local computer = require("computer")
local event = require("event")
function trigger()
component.musicblock.trigger(15)
end
event.listen("note", trigger)
for i=1, 10 do
computer.pushSignal("note")
end
event.pull()
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.
Hi,
I am new to OC, coming from CC and I want to make my music player in OC...
The issue I had with CC was that it was not possible to play multiple notes at the same time, but this was fixed with the information here:
http://www.computercraft.info/forums2/index.php?/topic/18995-openperipherals-play-2-or-more-noteblocks-at-the-same-time/
Now the 2 solutions available for CC don't seem to be available in CC so I tried around a bit with events... Didn't work as intended and even got a crashing computer out of it...
Here's my code:
To replicate my issue, just place an adapter anywhere with one or more noteblocks connected to it.
If you run the program you'll hear a clear delay between each note, music will need multiple notes at once...
Preferably I want multiple notes to play instantly out of one single noteblock, but if that's impossible then I guess multiple will have to do...
As for the memory leak:
Running this part of the code
Multiple times it will:
1. keep playing more and more notes at the end.
2. eventually crash, saying it ran out of memory.
Link to post
Share on other sites