public IEnumerable <IDuratedItem <Cell> > Intersecting(Duration duration) => MeterSignatures.Intersecting_children(duration);
public RhythmTrack( StorageObjectID storageobjectID, EditorFile file ) : base( storageobjectID, file, null //TOOD ) { obj = this.Object(); binder_timesignatures = TimeSignatures.Bind( obj.GetOrMake("time-signatures").ID, file ); binder_timesignatures.Deserializer = timesig_obj => { using (var stream = timesig_obj.OpenRead()) { using (var br = new BinaryReader(stream)) { var simples = new Simple[br.ReadInt32()]; for (int i = 0; i < simples.Length; i++) { var upper = br.ReadInt32(); var lower = br.ReadInt32(); simples[i] = new Simple(upper, lower); } return(new TimeSignature(simples)); } } }; binder_timesignatures.Serializer = (timesig_obj, timesig) => { using (var stream = timesig_obj.OpenWrite()) { using (var bw = new BinaryWriter(stream)) { bw.Write(timesig.Simples.Count); for (int i = 0; i < timesig.Simples.Count; i++) { var simple = timesig.Simples[i]; bw.Write(simple.Upper); bw.Write(simple.Lower); } } } }; binder_metersignatures = MeterSignatures.Bind( obj.GetOrMake("meter-signatures").ID, file ); binder_metersignatures.Deserializer = metersig_obj => { using (var stream = metersig_obj.OpenRead()) { using (var br = new BinaryReader(stream)) { var cells = new Cell[br.ReadInt32()]; for (int i = 0; i < cells.Length; i++) { var length = Time.FromTicks(br.ReadInt32()); var stress = br.ReadSingle(); cells[i] = new Cell { Length = length, Stress = stress }; } var totallength = cells.Aggregate( Time.Zero, (acc, cell) => acc + cell.Length ); return(new MeterSignature(totallength, cells)); } } }; binder_metersignatures.Serializer = (metersig_obj, metersig) => { using (var stream = metersig_obj.OpenWrite()) { using (var bw = new BinaryWriter(stream)) { bw.Write(metersig.Cells.Count); for (int i = 0; i < metersig.Cells.Count; i++) { var cell = metersig.Cells[i]; bw.Write(cell.Length.Ticks); bw.Write(cell.Stress); } } } }; }
public IEnumerable <IDuratedItem <Cell> > Intersecting(Time point) => MeterSignatures.Intersecting_children(point);