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

Bored? Time the music for us plox..

Started by libraryaddict, 06 July 2012 - 12:42 PM
libraryaddict #1
Posted 06 July 2012 - 02:42 PM
Well dan200, genius as he is. He cannot determine when the music stops.
As for me, I don't really want to listen to all this.
So this is where you come in!

Just run this program next to a disk drive with a music disk in it.
And time it with the spacebar!
Then make a note for each music disk.

Then when you are sure you have the exact times for each music disk, Just post back in here with it :P/>/>
I'm more then happy to make a API which would use this.
But you can do it easily as well.

Just have

getAudioTime(Title)
if Title == mellohi then return 40
elseif Title == 13 then return 20
end
You get the idea :)/>/>
Except the titles will have the be the same as the ones that computer fetches with disk.getAudioTitle(side)



--Time music
function Clear()
  term.clear()
  term.setCursorPos(1,1)
end

function Check()
  for _,side in ipairs(rs.getSides()) do
    if disk.hasAudio(side) then
	  return side
    end
  end
end

function Time(Side)
  local Timed = nil
  Clear()
  print("Press spacebar to start timing, I will play the disk "..disk.getAudioTitle(Side).." at "..Side)
  while true do
    event,param1,param2 = os.pullEvent()
    if event == "key" then
	  if param1 == 57 then
	    if Timed == nil then
		  print("Recording")
		  Timed = 0
		  Tenth = os.startTimer(0.1)
		  disk.playAudio(Side)
	    else
		  print("Stopped recording, disk "..disk.getAudioTitle(Side).." was "..Timed.." seconds long")
		  Tenth = os.startTimer(0)
	    end
	  end
    elseif event == "timer" and param1 == Tenth then
	  Timed = (Timed+.1)
	  Tenth = os.startTimer(0.1)
    end
  end
end
	    
local Status = "Go"
repeat
  if Check() then
    Side = Check()
    Clear()
    for n=1,5 do -- Dont judge me!
	  print()
    end
    print(string.rep("-", 49))
    print("Music disk \""..disk.getAudioTitle(Side).."\" found at side "..Side)
    print(string.rep("-", 49))
    print("Do you want to play and time this disk? Press \"T\"")
    print(string.rep("-", 49))
    print("You can always check again with \"C\"")
    print(string.rep("-", 49))
    print("\"Q\" to quit")
    print(string.rep("-", 49))
    while true do
	  event,param1 = os.pullEvent()
	  if event == "char" then
	    if param1 == "t" then
		  Time(Side)
	    elseif param1 == "q" then
		  Status = "Stop"
		  break
	    elseif param1 == "c" then
		  break
	    end
	  end
    end
  else
    Clear()
    print("No music disk found")
    os.pullEvent()
  end
until Status == "Stop"
Lyqyd #2
Posted 06 July 2012 - 06:28 PM
This really belongs in General, not in the Program Library.

And aren't all of the songs someplace? It shouldn't be too difficult to just look up the lengths of each one.
libraryaddict #3
Posted 06 July 2012 - 08:07 PM
This really belongs in General, not in the Program Library.

And aren't all of the songs someplace? It shouldn't be too difficult to just look up the lengths of each one.

About it being moved, Agreed.
And nope :|
Lyqyd #4
Posted 07 July 2012 - 07:34 PM
This really belongs in General, not in the Program Library.

And aren't all of the songs someplace? It shouldn't be too difficult to just look up the lengths of each one.

About it being moved, Agreed.
And nope :|

Wrong. I have no idea why you couldn't just find them all yourself.
libraryaddict #5
Posted 07 July 2012 - 09:05 PM
:|
Thanks

To be fair this is one of my stupider posts..
And programs