Returns a FoscContainer.
A container
An iterable container of components.
| components | Get components in container. |
| identifier | Get bracket comment. |
| identifier_ | Set bracket comment. |
| isSimultaneous | Is true when container is simultaneous. |
| isSimultaneous_ | Set isSimultaneous flag. |
| name | Get name of container. |
| name_ | Set name of container. |
| do | Iterates components. Non-recursive. |
| iter | Iterates container. |
| isEmpty | |
| lastIndex | |
| notEmpty | |
| reverseDo | Iterates components in reverse. Non-recursive. |
| size | Gets number of items in container. |
| storeArgs |
| add | Adds component to container. |
| addAll | Adds all components to container. |
| at | Gets item at index in container. Traverses top-level items only. |
| copySeries | Gets item at indices in container. Traverses top-level items only. |
| includes | Is true when expr appears in container. Otherwise false. |
| includesAny | |
| indexOf | Returns index of component in container. |
| insert | Inserts component at index in container. |
| leafAt | Gets leaf at index in container. |
| put | Puts component at index in container. |
| remove | Remove component from container. |
| removeAt | Remove component at index in container. |
Get components in container.
Get bracket comment.
Set bracket comment.
Is true when container is simultaneous.
Set isSimultaneous flag.
Get name of container.
Set name of container.
Iterates components. Non-recursive.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.do { |each| each.postln };FoscStaff([ ], 'Staff', false)Iterates container.
Returns a Routine.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
b = a.iter;
a.size.do { b.next.postln };2Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.isEmpty;false
a.prEjectContents;
a.isEmpty;trueExample
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.lastIndex;1Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.notEmpty;true
a.prEjectContents;
a.notEmpty;falseIterates components in reverse. Non-recursive.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.reverseDo { |each| each.postln };FoscStaff([ ], 'Staff', false)Gets number of items in container.
Returns integer.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.size;2Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
a.storeArgs;[ [ ], 'Staff', false, nil, nil ]Adds component to container.
Add a note to end of container
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.add(FoscNote(67, 1/4));
a.show;
Add a new container to end of container
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.add(FoscTuplet(2/3, [FoscNote(67, 1/4), FoscNote(69, 1/8)]));
a.show;
Add a selection to end of container
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.add(FoscLeafMaker().(#[67,69], [1/4]));
a.show;
Adds all components to container.
Add notes to end of container
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.addAll([FoscNote(67, 1/4), FoscNote(69, 1/4)]);
a.show;
Add tuplet containers to end of container
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
b = FoscTuplet(2/3, [FoscNote(67, 1/4), FoscNote(69, 1/8)]);
c = FoscTuplet(4/5, [FoscNote(71, 1/16), FoscNote(72, 1/4)]);
a.addAll([b, c]);
a.show;
Add selections to end of container
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
b = FoscLeafMaker().(#[67,69], [1/4]);
c = FoscLeafMaker().(#[71,72], [1/4]);
a.addAll([b, c]);
a.show;
Gets item at index in container. Traverses top-level items only.
Returns component or selection.
Get by index. Returns component.
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a[2];FoscNote('E4', 1/4)Get by indices. Returns selection.
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
b = a[0..2];
b.items;[ FoscNote(FoscPitch("C4"), FoscDuration(1, 4)), FoscNote(FoscPitch("D4"), FoscDuration(1, 4)), FoscNote(FoscPitch("E4"), FoscDuration(1, 4)) ]Gets item at indices in container. Traverses top-level items only.
Returns component or selection.
Example
a = FoscVoice();
a.addAll({ |i| FoscNote(60 + i, 1/4) } ! 8);
a[1..2].do { |each| each.writtenPitch.str.postln };FoscSelection([ FoscNote(FoscPitch("C#4"), FoscDuration(1, 4)), FoscNote(FoscPitch("D4"), FoscDuration(1, 4)) ])
a[1..].do { |each| each.writtenPitch.str.postln };FoscSelection([ FoscNote(FoscPitch("C#4"), FoscDuration(1, 4)), FoscNote(FoscPitch("D4"), FoscDuration(1, 4)), FoscNote(FoscPitch("Eb4"), FoscDuration(1, 4)), FoscNote(FoscPitch("E4"), FoscDuration(1, 4)), FoscNote(FoscPitch("F4"), FoscDuration(1, 4)), FoscNote(FoscPitch("F#4"), FoscDuration(1, 4)), FoscNote(FoscPitch("G4"), FoscDuration(1, 4)) ])
a[..2].do { |each| each.writtenPitch.str.postln };FoscSelection([ FoscNote(FoscPitch("C4"), FoscDuration(1, 4)), FoscNote(FoscPitch("C#4"), FoscDuration(1, 4)), FoscNote(FoscPitch("D4"), FoscDuration(1, 4)) ])
a[1, 3 ..].do { |each| each.writtenPitch.str.postln };FoscSelection([ FoscNote(FoscPitch("C#4"), FoscDuration(1, 4)), FoscNote(FoscPitch("Eb4"), FoscDuration(1, 4)), FoscNote(FoscPitch("F4"), FoscDuration(1, 4)), FoscNote(FoscPitch("G4"), FoscDuration(1, 4)) ])
a[1, 3 .. 5].do { |each| each.writtenPitch.str.postln };FoscSelection([ FoscNote(FoscPitch("C#4"), FoscDuration(1, 4)), FoscNote(FoscPitch("Eb4"), FoscDuration(1, 4)), FoscNote(FoscPitch("F4"), FoscDuration(1, 4)) ])Is true when expr appears in container. Otherwise false.
Returns true or false.
Returns index of component in container.
Returns nonnegative integer.
Example
a = FoscStaff([FoscNote(60, 1/4), FoscNote(62, 1/4)]);
b = a.leafAt(1);
a.indexOf(b);1Inserts component at index in container.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.insert(1, FoscNote(72, 1/4));
a.show;
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.insert(1, [FoscNote(72, 1/4), FoscNote(74, 1/4)]);
a.show;
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.insert(1, FoscTuplet(2/3, [FoscNote(72, 1/4), FoscNote(74, 1/8)]));
a.show;
Grow container if index is greater than size.
a = FoscStaff([FoscNote(60, 1/4)]);
a.insert(1, FoscNote(61, 1/4));
a.components;[ FoscNote(FoscPitch("C4"), FoscDuration(1, 4)), FoscNote(FoscPitch("C#4"), FoscDuration(1, 4)) ]Gets leaf at index in container.
Get leaf at index 1.
a = FoscStaff([FoscNote(60, 1/4), FoscNote(62, 1/4)]);
a.leafAt(1).str;d'4Get pitched leaf at index 1.
a = FoscStaff([FoscRest(1/4), FoscNote(60, 1/4), FoscNote(62, 1/4)]);
a.leafAt(0, pitched: true).str;c'4Puts component at index in container.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a[1] = FoscNote(72, 1/4);
a.show;
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a[1] = [FoscNote(72, 1/4), FoscNote(74, 1/4)];
a.show;
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a[1] = FoscTuplet(2/3, [FoscNote(72, 1/4), FoscNote(74, 1/8)]);
a.show;
Remove component from container.
Return removed component.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
b = a.leafAt(1);
a.remove(b);FoscSelection([ FoscNote(FoscPitch("D4"), FoscDuration(1, 4)) ])
a.format;\new Staff {
c'4
e'4
f'4
}Remove component at index in container.
Return removed component.
Example
a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
a.removeAt(1);FoscSelection([ FoscNote(FoscPitch("D4"), FoscDuration(1, 4)) ])
a.format;\new Staff {
c'4
e'4
f'4
}