Sha256: 787bf6621f2f168d3d2c1593dd4884f816fbab5d37dc05ed485f52b03e30921b

Contents?: true

Size: 688 Bytes

Versions: 6

Compression:

Stored size: 688 Bytes

Contents

module Music
module Transcription

class Part
  def pack
    packed_notes = notes.map {|n| n.to_s }.join(" ")
    packed_dcs = Hash[ dynamic_changes.map do |offset,change|
      [ offset, change.pack ]
    end ]
      
    {
      'notes' => packed_notes,
      'start_dynamic' => start_dynamic,
      'dynamic_changes' => packed_dcs
    }
  end
  
  def self.unpack packing
    unpacked_notes = Parsing::notes(packing["notes"])
    unpacked_dcs = Hash[ packing["dynamic_changes"].map do |offset,change|
      [ offset,Change.unpack(change) ]
    end ]
    
    new(
      packing["start_dynamic"],
      notes: unpacked_notes,
      dynamic_changes: unpacked_dcs
    )
  end
end

end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
music-transcription-0.17.1 lib/music-transcription/packing/part_packing.rb
music-transcription-0.17.0 lib/music-transcription/packing/part_packing.rb
music-transcription-0.16.0 lib/music-transcription/packing/part_packing.rb
music-transcription-0.15.0 lib/music-transcription/packing/part_packing.rb
music-transcription-0.14.0 lib/music-transcription/packing/part_packing.rb
music-transcription-0.13.0 lib/music-transcription/packing/part_packing.rb