Sha256: f4eec799a8948a3edee052621943b6f26305047adcbfb0aa7565815a48b3fb65

Contents?: true

Size: 690 Bytes

Versions: 3

Compression:

Stored size: 690 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 = Note.split_parse(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

3 entries across 3 versions & 1 rubygems

Version Path
music-transcription-0.21.0 lib/music-transcription/packing/part_packing.rb
music-transcription-0.20.0 lib/music-transcription/packing/part_packing.rb
music-transcription-0.19.0 lib/music-transcription/packing/part_packing.rb