def format_datagram(cls, datagram): result = [] result.append('size {}'.format(len(datagram))) index = 0 while index < len(datagram): chunk = datagram[index:index + 16] line = '{: >4} '.format(index) hex_blocks = [] ascii_block = '' for chunk in utils.group_iterable_by_count(chunk, 4): hex_block = [] for byte in chunk: char = int(byte) if 31 < char < 127: char = chr(char) else: char = '.' ascii_block += char hexed = hex(byte)[2:].zfill(2) hex_block.append(hexed) hex_block = ' '.join(hex_block) hex_blocks.append(hex_block) hex_blocks = ' '.join(hex_blocks) ascii_block = '|{}|'.format(ascii_block) hex_blocks = '{: <53}'.format(hex_blocks) line += hex_blocks line += ascii_block result.append(line) index += 16 result = '\n'.join(result) return result
def format_datagram(datagram): result = [] result.append("size {}".format(len(datagram))) index = 0 while index < len(datagram): chunk = datagram[index : index + 16] line = "{: >4} ".format(index) hex_blocks = [] ascii_block = "" for chunk in utils.group_iterable_by_count(chunk, 4): hex_block = [] for byte in chunk: char = int(byte) if 31 < char < 127: char = chr(char) else: char = "." ascii_block += char hexed = hex(byte)[2:].zfill(2) hex_block.append(hexed) hex_block = " ".join(hex_block) hex_blocks.append(hex_block) hex_blocks = " ".join(hex_blocks) ascii_block = "|{}|".format(ascii_block) hex_blocks = "{: <53}".format(hex_blocks) line += hex_blocks line += ascii_block result.append(line) index += 16 result = "\n".join(result) return result
def _handle_input_levels(self, message): contents = message.contents[2:] peak_levels = [] rms_levels = [] for peak, rms in utils.group_iterable_by_count(contents, 2): peak_levels.append(peak) rms_levels.append(rms) self._input_meter_peak_levels = tuple(peak_levels) self._input_meter_rms_levels = tuple(rms_levels)
def _handle_output_levels(self, message): contents = message.contents[2:] peak_levels = [] rms_levels = [] for peak, rms in utils.group_iterable_by_count(contents, 2): peak_levels.append(peak) rms_levels.append(rms) self._output_meter_peak_levels = tuple(peak_levels) self._output_meter_rms_levels = tuple(rms_levels) supriya.system.PubSub.notify( "server-meters", { "input_meter_peak_levels": self._input_meter_peak_levels, "input_meter_rms_levels": self._input_meter_rms_levels, "output_meter_peak_levels": self._output_meter_peak_levels, "output_meter_rms_levels": self._output_meter_rms_levels, }, )
def new(cls, sources): import supriya.synthdefs import supriya.ugens sources = cls._flatten_sources(sources) summed_sources = [] for part in utils.group_iterable_by_count(sources, 4): if len(part) == 4: summed_sources.append(supriya.ugens.Sum4(*part)) elif len(part) == 3: summed_sources.append(supriya.ugens.Sum3(*part)) elif len(part) == 2: summed_sources.append(part[0] + part[1]) else: summed_sources.append(part[0]) if len(summed_sources) == 1: return summed_sources[0] return Mix.new(summed_sources)
def new(cls, sources): import supriya.synthdefs import supriya.ugens sources = cls._flatten_sources(sources) summed_sources = [] for part in utils.group_iterable_by_count(sources, 4): if len(part) == 4: summed_sources.append(supriya.ugens.Sum4(*part)) elif len(part) == 3: summed_sources.append(supriya.ugens.Sum3(*part)) elif len(part) == 2: summed_sources.append(part[0] + part[1]) else: summed_sources.append(part[0]) if len(summed_sources) == 1: return summed_sources[0] return Mix.new(summed_sources)
def new(cls, sources): import supriya.synthdefs import supriya.ugens flattened_sources = [] for source in sources: if isinstance(source, supriya.synthdefs.UGenArray): flattened_sources.extend(source) else: flattened_sources.append(source) sources = supriya.synthdefs.UGenArray(flattened_sources) summed_sources = [] for part in utils.group_iterable_by_count(sources, 4): if len(part) == 4: summed_sources.append(supriya.ugens.Sum4(*part)) elif len(part) == 3: summed_sources.append(supriya.ugens.Sum3(*part)) elif len(part) == 2: summed_sources.append(part[0] + part[1]) else: summed_sources.append(part[0]) if len(summed_sources) == 1: return summed_sources[0] return Mix.new(summed_sources)