class GBTiles::GBT::Export::ASM::Channels::Noise

Public Class Methods

new() click to toggle source
Calls superclass method GBTiles::GBT::Export::ASM::Channel::new
# File lib/gbtiles/gbt/export/asm/channels/noise.rb, line 12
def initialize
  super(4)
end

Public Instance Methods

convert() click to toggle source
# File lib/gbtiles/gbt/export/asm/channels/noise.rb, line 20
def convert
  if sample_period == 0 then
    convert_note_not_new
  else
    convert_note_new
  end
end
convert_note_new() click to toggle source
# File lib/gbtiles/gbt/export/asm/channels/noise.rb, line 55
def convert_note_new
  instrument = (sample_number - 16) & 0x1F

  # Volume effect
  if effect_number == 0xC then
    return [
        (1 << 7) | instrument,
        convert_volume
    ]
  end

  # Other effects
  begin
    converted = convert_effect

    return [
        (1 << 7) | instrument,
        (1 << 7) | converted[:number],
        converted[:params]
    ]
  rescue Exception => e
    throw "Noise - Invalid command: #{e}"
  end
end
convert_note_not_new() click to toggle source
# File lib/gbtiles/gbt/export/asm/channels/noise.rb, line 28
def convert_note_not_new
  if is_empty_effect? then
    return [0]
  end

  # Volume effect
  if effect_number == 0xC then
    return [
        (1 << 5) | convert_volume
    ]
  end

  # Other effects
  begin
    converted = convert_effect

    return [
        (1 << 6) | converted[:number],
        converted[:params]
    ]
  rescue Exception => e
    # Silence
  end

  return [0]
end
is_noise?() click to toggle source
# File lib/gbtiles/gbt/export/asm/channels/noise.rb, line 16
def is_noise?
  true
end