Module: Seriamp::Yamaha::Protocol::Methods

Includes:
Constants
Included in:
Client
Defined in:
lib/seriamp/yamaha/protocol/methods.rb

Instance Method Summary collapse

Instance Method Details

#get_main_volume_textObject



104
105
106
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 104

def get_main_volume_text
  extract_text(system_command("2001"))[3...].strip
end

#get_zone2_volume_textObject



108
109
110
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 108

def get_zone2_volume_text
  extract_text(system_command("2002"))[3...].strip
end

#get_zone3_volume_textObject



112
113
114
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 112

def get_zone3_volume_text
  extract_text(system_command("2005"))[3...].strip
end

#main_volume_downObject



73
74
75
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 73

def main_volume_down
  remote_command('7A1B')
end

#main_volume_upObject



69
70
71
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 69

def main_volume_up
  remote_command('7A1A')
end

#set_bass_out(v) ⇒ Object



183
184
185
186
187
188
189
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 183

def set_bass_out(v)
  value = BASS_OUTS[v.to_s]
  unless value
    raise ArgumentError, "Invalid bass out value: #{v}; valid values: #{BASS_OUTS.keys.join(', ')}"
  end
  system_command("75#{value}")
end

#set_center_speaker_layout(layout) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 143

def set_center_speaker_layout(layout)
  value = CENTER_SPEAKER_LAYOUTS[layout.to_s]
  unless value
    raise ArgumentError, "Invalid center speaker layout: #{layout}; valid layouts: #{CENTER_SPEAKER_LAYOUTS.keys.join(', ')}"
  end
  system_command("70#{value}")
end

#set_front_speaker_layout(layout) ⇒ Object



151
152
153
154
155
156
157
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 151

def set_front_speaker_layout(layout)
  value = FRONT_SPEAKER_LAYOUTS[layout.to_s]
  unless value
    raise ArgumentError, "Invalid front speaker layout: #{layout}; valid layouts: #{FRONT_SPEAKER_LAYOUTS.keys.join(', ')}"
  end
  system_command("71#{value}")
end

#set_main_input(source) ⇒ Object



128
129
130
131
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 128

def set_main_input(source)
  source_code = MAIN_INPUTS_SET.fetch(source.downcase.gsub(/[^a-z]/, '_'))
  remote_command("7A#{source_code}")
end

#set_main_power(state) ⇒ Object

Turns main zone power on or off.

Parameters:

  • state (true | false)

    Desired power state.



21
22
23
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 21

def set_main_power(state)
  remote_command("7E7#{state ? 'E' : 'F'}")
end

#set_main_volume(value) ⇒ Object

Sets main zone volume.

Parameters:

  • value (Integer)

    The raw volume value.



42
43
44
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 42

def set_main_volume(value)
  system_command("30#{'%02x' % value}")
end

#set_main_volume_db(volume) ⇒ Object

Sets main zone volume.

Parameters:

  • volume (Float)

    The volume in decibels.



49
50
51
52
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 49

def set_main_volume_db(volume)
  value = Integer((volume + 80) * 2 + 39)
  set_main_volume(value)
end

#set_power(state) ⇒ Object

Turns the receiver on or off.

Parameters:

  • state (true | false)

    Desired power state.



14
15
16
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 14

def set_power(state)
  remote_command("7A1#{state ? 'D' : 'E'}")
end

#set_presence_speaker_layout(layout) ⇒ Object



175
176
177
178
179
180
181
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 175

def set_presence_speaker_layout(layout)
  value = PRESENCE_SPEAKER_LAYOUTS[layout.to_s]
  unless value
    raise ArgumentError, "Invalid presence speaker layout: #{layout}; valid layouts: #{PRESENCE_SPEAKER_LAYOUTS.keys.join(', ')}"
  end
  system_command("74#{value}")
end

#set_program(value) ⇒ Object



123
124
125
126
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 123

def set_program(value)
  program_code = PROGRAM_SET.fetch(value.downcase.gsub(/[^a-z]/, '_'))
  remote_command("7E#{program_code}")
end

#set_pure_direct(state) ⇒ Object

Turns pure direct mode on or off.

Parameters:

  • state (true | false)

    Desired state.



119
120
121
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 119

def set_pure_direct(state)
  remote_command("7E8#{state ? '0' : '2'}")
end

#set_subwoofer_crossover(v) ⇒ Object



199
200
201
202
203
204
205
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 199

def set_subwoofer_crossover(v)
  value = SUBWOOFER_CROSSOVERS[v]
  unless value
    raise ArgumentError, "Invalid subwoofer crossover frequency: #{v}; valid freuencies: #{SUBWOOFER_CROSSOVERS.keys.join(', ')}"
  end
  system_command("7E#{value}")
end

#set_subwoofer_level(level) ⇒ Object



100
101
102
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 100

def set_subwoofer_level(level)
  system_command("49#{'%02x' % level}")
end

#set_subwoofer_phase(v) ⇒ Object



191
192
193
194
195
196
197
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 191

def set_subwoofer_phase(v)
  value = SUBWOOFER_PHASES[v.to_s]
  unless value
    raise ArgumentError, "Invalid subwoofer phase value: #{v}; valid values: #{SUBWOOFER_PHASES.keys.join(', ')}"
  end
  system_command("76#{value}")
end

#set_surround_back_speaker_layout(layout) ⇒ Object



167
168
169
170
171
172
173
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 167

def set_surround_back_speaker_layout(layout)
  value = SURROUND_BACK_SPEAKER_LAYOUTS[layout.to_s]
  unless value
    raise ArgumentError, "Invalid surround back speaker layout: #{layout}; valid layouts: #{SURROUND_BACK_SPEAKER_LAYOUTS.keys.join(', ')}"
  end
  system_command("73#{value}")
end

#set_surround_speaker_layout(layout) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 159

def set_surround_speaker_layout(layout)
  value = SURROUND_SPEAKER_LAYOUTS[layout.to_s]
  unless value
    raise ArgumentError, "Invalid surround speaker layout: #{layout}; valid layouts: #{SURROUND_SPEAKER_LAYOUTS.keys.join(', ')}"
  end
  system_command("72#{value}")
end

#set_zone2_input(source) ⇒ Object



133
134
135
136
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 133

def set_zone2_input(source)
  source_code = ZONE2_INPUTS_SET.fetch(source.downcase.gsub(/[^a-z]/, '_'))
  remote_command("7A#{source_code}")
end

#set_zone2_power(state) ⇒ Object

Turns zone 2 power on or off.

Parameters:

  • state (true | false)

    Desired power state.



28
29
30
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 28

def set_zone2_power(state)
  remote_command("7EB#{state ? 'A' : 'B'}")
end

#set_zone2_volume(value) ⇒ Object

Sets zone 2 volume.

Parameters:

  • value (Integer)

    The raw volume value.



57
58
59
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 57

def set_zone2_volume(value)
  system_command("31#{'%02x' % value}")
end

#set_zone2_volume_db(volume) ⇒ Object

Sets zone 2 volume.

Parameters:

  • volume (Float)

    The volume in decibels.



64
65
66
67
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 64

def set_zone2_volume_db(volume)
  value = Integer(volume + 33 + 39)
  set_zone2_volume(value)
end

#set_zone3_input(source) ⇒ Object



138
139
140
141
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 138

def set_zone3_input(source)
  source_code = ZONE3_INPUTS_SET.fetch(source.downcase.gsub(/[^a-z]/, '_'))
  remote_command("7A#{source_code}")
end

#set_zone3_power(state) ⇒ Object

Turns zone 3 power on or off.

Parameters:

  • state (true | false)

    Desired power state.



35
36
37
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 35

def set_zone3_power(state)
  remote_command("7AE#{state ? 'D' : 'E'}")
end

#set_zone3_volume(volume) ⇒ Object

Sets zone 3 volume.

Parameters:

  • volume (Integer)

    The raw volume value.



88
89
90
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 88

def set_zone3_volume(volume)
  remote_command("234#{'%02x' % value}")
end

#zone2_volume_downObject



81
82
83
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 81

def zone2_volume_down
  remote_command('7ADB')
end

#zone2_volume_upObject



77
78
79
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 77

def zone2_volume_up
  remote_command('7ADA')
end

#zone3_volume_downObject



96
97
98
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 96

def zone3_volume_down
  remote_command('7AFE')
end

#zone3_volume_upObject



92
93
94
# File 'lib/seriamp/yamaha/protocol/methods.rb', line 92

def zone3_volume_up
  remote_command('7AFD')
end