FoscContainer

Returns a FoscContainer.


Description

A container

An iterable container of components.


Attributes Summary

Instance Properties

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.

Instance Methods: Special Methods

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

Instance Methods

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.


Instance Properties


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.


Instance Methods: Special Methods


do

Iterates components. Non-recursive.

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.do { |each| each.postln };
    FoscStaff([  ], 'Staff', false)


iter

Iterates container.

Returns a Routine.

  1. 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 };
    2


isEmpty

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.isEmpty;
    false
    a.prEjectContents;
    a.isEmpty;
    true


lastIndex

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.lastIndex;
    1


notEmpty

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.notEmpty;
    true
    a.prEjectContents;
    a.notEmpty;
    false


reverseDo

Iterates components in reverse. Non-recursive.

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.reverseDo { |each| each.postln };
    FoscStaff([  ], 'Staff', false)


size

Gets number of items in container.

Returns integer.

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.size;
    2


storeArgs

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/12,1/12,1/12,1/4]));
    a.storeArgs;
    [ [  ], 'Staff', false, nil, nil ]


Instance Methods


add

Adds component to container.

  1. Add a note to end of container

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
    a.add(FoscNote(67, 1/4));
    a.show;

  2. 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;

  3. 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;


addAll

Adds all components to container.

  1. 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;

  2. 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;

  3. 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;


at

Gets item at index in container. Traverses top-level items only.

Returns component or selection.

  1. Get by index. Returns component.

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
    a[2];
    FoscNote('E4', 1/4)
  2. 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)) ]


copySeries

Gets item at indices in container. Traverses top-level items only.

Returns component or selection.

  1. 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)) ])


includes

Is true when expr appears in container. Otherwise false.

Returns true or false.


includesAny


indexOf

Returns index of component in container.

Returns nonnegative integer.

  1. Example

    a = FoscStaff([FoscNote(60, 1/4), FoscNote(62, 1/4)]);
    b = a.leafAt(1);
    a.indexOf(b);
    1


insert

Inserts component at index in container.

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
    a.insert(1, FoscNote(72, 1/4));
    a.show;

  2. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
    a.insert(1, [FoscNote(72, 1/4), FoscNote(74, 1/4)]);
    a.show;

  3. 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;

  4. 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)) ]


leafAt

Gets leaf at index in container.

  1. Get leaf at index 1.

    a = FoscStaff([FoscNote(60, 1/4), FoscNote(62, 1/4)]);
    a.leafAt(1).str;
    d'4
  2. Get 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'4


put

Puts component at index in container.

  1. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
    a[1] = FoscNote(72, 1/4);
    a.show;

  2. Example

    a = FoscStaff(FoscLeafMaker().(#[60,62,64,65], [1/4]));
    a[1] = [FoscNote(72, 1/4), FoscNote(74, 1/4)];
    a.show;

  3. 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

Remove component from container.

Return removed component.

  1. 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
    }


removeAt

Remove component at index in container.

Return removed component.

  1. 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
    }