Log In  

the new instrument system does that, but only from the tracker...

P#45963 2017-11-07 08:16 ( Edited 2017-11-10 00:27)

Now that the API is apparently feature-complete as of 0.1.11d, I'm guessing we will not get a method for this. However, you could always use poke()s to change pitch of an SFX in-place so that next time you play it, the pitch will be different, e.g.:

--- Add to the pitch of all notes in a SFX
-- @param sfxindex index of the sfx which will be modified
-- @param n number of semitones to add to the existing pitch of the notes
function add_to_pitch(sfxindex, n)
  local sfxaddr = 0x3200 + (68 * sfxindex)

  for i = 0, 31 do
    local noteoffset = (i * 2)
    local byte1 = peek(sfxaddr + noteoffset)
    local pitch = band(byte1, 63)

    pitch += n

    -- zero the pitch in our copy of the byte
    byte1 = band(byte1, 64)

    -- put the new pitch back in the byte
    byte1 = bor(byte1, pitch)

    -- write the modified byte back to the sfx
    poke(sfxaddr + noteoffset, byte1)
  end
end
P#46073 2017-11-09 15:05 ( Edited 2017-11-09 20:20)

I was thinking along those lines, plus copy/modify to a free slot to keep the original data. though I guess I'd have to keep track of what's playing and when, to avoid poking in live data? anyway I'm already past the compression limit and nearing the token one...

actually I went another route, I have 4 8-notes-long sound effects with slight variations in the same sfx slot. then I play them with the offset & length parameters.

still, that wouldn't be a far fetched addition to the API. also it's already there, mostly...

P#46084 2017-11-09 19:27 ( Edited 2017-11-10 00:28)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 05:57:50 | 0.061s | Q:12