Class: GBTiles::GBT::Export::ASM::Channels::Pulse

Inherits:
GBTiles::GBT::Export::ASM::Channel show all
Defined in:
lib/gbtiles/gbt/export/asm/channels/pulse.rb

Constant Summary

Constants inherited from GBTiles::GBT::Export::ASM::Channel

GBTiles::GBT::Export::ASM::Channel::NOTES

Instance Attribute Summary

Attributes inherited from GBTiles::GBT::Export::ASM::Channel

#channel_number

Instance Method Summary collapse

Methods inherited from GBTiles::GBT::Export::ASM::Channel

#convert_effect, #convert_speed, #convert_volume, #data, #data=, #effect_number, #effect_param, #effect_param_1, #effect_param_2, #effect_param_as_bcd, #is_empty_effect?, #is_noise?, #is_wav?, #note_index, #sample_number, #sample_period

Methods included from Effects

#effect_arpeggio, #effect_break_and_set_step, #effect_cut_note, #effect_jump, #effect_pan, #effect_speed, #effect_volume

Constructor Details

#initialize(channel_number) ⇒ Pulse

Returns a new instance of Pulse.



13
14
15
# File 'lib/gbtiles/gbt/export/asm/channels/pulse.rb', line 13

def initialize(channel_number)
  super(channel_number)
end

Instance Method Details

#convertObject



21
22
23
24
25
26
27
# File 'lib/gbtiles/gbt/export/asm/channels/pulse.rb', line 21

def convert
  if sample_period == 0 then
    convert_note_not_new
  else
    convert_note_new
  end
end

#convert_note_newObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/gbtiles/gbt/export/asm/channels/pulse.rb', line 58

def convert_note_new
  instrument = sample_number & 3

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

  # Other effects
  begin
    converted = convert_effect

    return [
        (1 << 7) | note_index,
        (1 << 7) | (instrument << 4) | converted[:number],
        converted[:params]
    ]
  rescue Exception => e
    throw "Pulse - Invalid command: #{e}"
  end

end

#convert_note_not_newObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gbtiles/gbt/export/asm/channels/pulse.rb', line 29

def convert_note_not_new
  instrument = sample_number & 3

  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) | (instrument << 4) | converted[:number],
        converted[:params]
    ]
  rescue Exception => e
    # Silence
  end

  return [0]
end

#is_pulse?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/gbtiles/gbt/export/asm/channels/pulse.rb', line 17

def is_pulse?
  true
end