Triplet Calculator

General discussion about tracking, help and support.
User avatar
MrKyurem
Posts: 199
Joined: Mon Apr 27, 2015 7:11 pm

Re: Triplet Calculator

Postby MrKyurem » Sat Aug 08, 2015 9:56 pm

If you can't take criticism, don't do anything where you'll get criticism.

User avatar
James_S
Posts: 339
Joined: Tue Apr 21, 2015 12:37 am
Location: Chicago, IL

Re: Triplet Calculator

Postby James_S » Sat Aug 08, 2015 9:56 pm

SALTSALTSALTSALT

ye, this isnt really helpful. placing G effects isnteven the slightest of problems when tracking, just divide the speed by 2.
AKA FamicomForever
click for BEPIS!!!!

User avatar
HertzDevil
Posts: 475
Joined: Thu Apr 23, 2015 7:39 pm
Location: Hong Kong SAR
Contact:

Re: Triplet Calculator

Postby HertzDevil » Sat Aug 08, 2015 10:03 pm

This is a calculator, converted from a pseudocode I posted earlier into Lua:

Code: Select all

local REFRESH = 60
local SPEED = {6}
local TEMPO = 150

local tick = function (row) return REFRESH * SPEED[(row - 1) % #SPEED + 1] * 2.5 / TEMPO end

local tuplet = function (R, T)
  local count = {0}
  local final = {}
  for i = 1, R do count[i + 1] = count[i] + tick(i) end
  for i = 1, T do
    local p = 1
    local Offset = count[R + 1] * (i - 1) / T
    while count[p + 1] and Offset >= count[p + 1] do p = p + 1 end
    final[i] = {Row = p, Gxx = Offset - count[p]}
  end
  for i = 1, T - 1 do if final[i].Row == final[i + 1].Row then
    if final[i].Gxx == 0 then
      final[i].Row = final[i].Row - 1
      final[i].Gxx = final[i].Gxx + tick(i - 1)
      if i > 1 and final[i - 1].Row == final[i].Row then return false end
    else return false end
  end end
  for i = 1, T do if final[i].Gxx > 0xFF then return false end end
  return final
end

local test = function (R, T)
  print("Refresh rate: " .. REFRESH .. " Hz")
  print("Tempo: " .. TEMPO .. " BPM")
  print("Speed: " .. table.concat(SPEED, " "))
  local x = tuplet(R, T)
  if not x then
    print("No possible Gxx sequences for " .. T .. "-tuplet in " .. R .. " rows")
  else
    print("Closest Gxx sequence for " .. T .. "-tuplet in " .. R .. " rows:")
    local offset = 1 - math.min(x[1].Row, 1)
    local pat = {}
    for _, v in ipairs(x) do
      v.Row = v.Row + offset
      assert(pat[v.Row] == nil)
      pat[v.Row] = v.Gxx
    end
    local str = {}
    for i = 1, R + offset do
      local note = pat[i] and "C-3 00 ." or "... .. ."
      local f = SPEED[(i - offset - 1) % #SPEED + 1]
      local speed = (i == 1 or f ~= SPEED[(i - offset - 2) % #SPEED + 1]) and string.format("F%02X", f) or "..."
      local g = math.floor((pat[i] or 0) + .5)
      local delay = g > 0 and string.format("G%02X", g) or "..."
      local err = pat[i] and string.format("; error = %+.2f ticks", g - pat[i]) or ""
      str[#str + 1] = string.format("ROW %02X: ... .. . %s    %s %s    %s", i, speed, note, delay, err)
    end
    print(table.concat(str, "\n"))
  end
end

local desc = [[
Tuplet calculator
Usage: lua tuplet.lua [rows] [notes] {option}
Options:
  -Tx: Set tempo to x (default 150)
  -Sx: Set speed to x (default 6); use multiple times for groove
  -Rx: Set refresh rate to x (default 60)]]

local main = function (arg)
  if #arg < 2 then
    print(desc)
  else
    local groove = false
    for i = 3, #arg do
      local type, param = string.sub(arg[i], 1, 2), tonumber(string.sub(arg[i], 3))
      if param and param > 0 then
        if type == "-T" then TEMPO = param
        elseif type == "-S" then
          if not groove then
            groove = true
            SPEED = {param}
          else SPEED[#SPEED + 1] = param end
        elseif type == "-R" then REFRESH = param
        end
      end
    end
    local R, T = tonumber(arg[1]), tonumber(arg[2])
    local natural = function (x) return x and x % 1 == 0 and x > 0 end
    if natural(R) and natural(T) then
      test(R, T)
    else
      print("Invalid argument")
    end
  end
end

main(arg)
refactoring 0cc-famitracker

User avatar
ollaxe
Posts: 736
Joined: Mon Apr 20, 2015 7:07 pm
Location: Sweden
Contact:

Re: Triplet Calculator

Postby ollaxe » Sat Aug 08, 2015 10:23 pm

Wow. You just flipped the bird to all of us, bragged about how smart you are, AND made a triple-post in the process. That's one way to instantly gain a bad reputation from everyone on these forums. Good job. I hope you're proud of yourself.

Note to self: Shut your mouth whenever posting on any of Scomo's thread, otherwise he'll get mad as shit.
Hi! I'm not really active here anymore but I still make music. Nowadays I mostly make dubstep with emphasis on good melodies and chord progressions.
SoundCloud: soundcloud.com/ollaxe
Twitter: twitter.com/ollaxe
Discord server: dis.gd/tK7uRnc
I'm also on Spotify. Search "OllAxe" and you'll find me.

Threxx
Posts: 343
Joined: Wed Apr 22, 2015 2:34 pm
Location: Brooklyn, NY
Contact:

Re: Triplet Calculator

Postby Threxx » Sat Aug 08, 2015 10:31 pm

Scomo wrote:
ollaxe wrote:Thanks but no thanks, I can do math in my head whenever I'd need it. I even have an A in math... So yah.


And I have a double-Masters in Applied Mathematics and Statistics from UC Berkeley but if you decide put a tool up that isn't helpful to ME I'll just keep my mouth shut.


Does this somehow give your useless "calculator" more legitimacy?

User avatar
Ultimate_Xeallar
Posts: 7
Joined: Fri May 22, 2015 12:10 am
Location: sbgerahagv
Contact:

Re: Triplet Calculator

Postby Ultimate_Xeallar » Sat Aug 08, 2015 10:35 pm

And I have a double-Masters in Applied Mathematics and Statistics from UC Berkeley but if you decide put a tool up that isn't helpful to ME I'll just keep my mouth shut.

w0t

User avatar
Scomo
Posts: 21
Joined: Wed Aug 05, 2015 5:12 am
Location: Austin, TX
Contact:

Re: Triplet Calculator

Postby Scomo » Sun Aug 09, 2015 12:48 am

Threxx wrote:
Scomo wrote:
ollaxe wrote:Thanks but no thanks, I can do math in my head whenever I'd need it. I even have an A in math... So yah.


And I have a double-Masters in Applied Mathematics and Statistics from UC Berkeley but if you decide put a tool up that isn't helpful to ME I'll just keep my mouth shut.


Does this somehow give your useless "calculator" more legitimacy?


No, no - I was just responding to your hidden and passive aggressive "I even have an A in math" comment that you feel gives your initial comment legitimacy. Coward. But seriously, WHY all the hostility on these forums? We're all creative types - why so toxic??
There will forever be a special place in my heart for that 8-bit sound.

Threxx
Posts: 343
Joined: Wed Apr 22, 2015 2:34 pm
Location: Brooklyn, NY
Contact:

Re: Triplet Calculator

Postby Threxx » Sun Aug 09, 2015 12:55 am

Scomo wrote:No, no - I was just responding to your hidden and passive aggressive "I even have an A in math" comment that you feel gives your initial comment legitimacy. Coward. But seriously, WHY all the hostility on these forums? We're all creative types - why so toxic??


I believe you are confusing me with ollaxe.

Regardless, we were not the ones who reacted by insulting and belittling those who pointed out the low utility of their spreadsheet. Your degree means nothing. The spreadsheet is very limited and not useful to most of the users here. That was made clear. Your reaction was unwarranted.

User avatar
Ultimate_Xeallar
Posts: 7
Joined: Fri May 22, 2015 12:10 am
Location: sbgerahagv
Contact:

Re: Triplet Calculator

Postby Ultimate_Xeallar » Sun Aug 09, 2015 12:56 am

No, no - I was just responding to your hidden and passive aggressive "I even have an A in math" comment that you feel gives your initial comment legitimacy. Coward. But seriously, WHY all the hostility on these forums? We're all creative types - why so toxic??

I think the thing you need to learn here is the old axiom "Treat others as you want to be treated". Because you know, it's totally not being toxic by saying "I have a degree with whatever I am a god for creating this program worship me". Or for a more close to home example, The reply i'm quoting makes people go on the defensive. Calling someone a "Coward" and then asking "why so toxic??" is, for lack of a better word, NOT a smart move on your part.

Overlord99
Posts: 609
Joined: Sat May 09, 2015 4:31 am

Re: Triplet Calculator

Postby Overlord99 » Sun Aug 09, 2015 4:19 am

It's great that you made this, but there's really no need to be a jerk to those who don't want to use it...


Return to “General Talk”

Who is online

Users browsing this forum: No registered users and 1 guest