├── Std ├── Tool │ ├── Repeat2.cal │ ├── Silence.cal │ ├── Repeat10.cal │ ├── Repeat3.cal │ ├── Repeat4.cal │ ├── Repeat5.cal │ ├── Repeat6.cal │ ├── Repeat7.cal │ ├── Repeat8.cal │ ├── Repeat9.cal │ ├── Chord2.cal │ ├── Silence10.cal │ ├── Silence2.cal │ ├── Silence3.cal │ ├── Silence4.cal │ ├── Silence5.cal │ ├── Silence6.cal │ ├── Silence7.cal │ ├── Silence8.cal │ ├── Silence9.cal │ ├── Empty.cal │ ├── Chord3.cal │ ├── LetRing2.cal │ ├── Chord4.cal │ ├── Chord5.cal │ ├── LetRing3.cal │ ├── LetRing4.cal │ └── LetRing5.cal ├── Pitch12 │ ├── Up2.cal │ ├── Down.cal │ ├── Up.cal │ ├── Up10.cal │ ├── Up11.cal │ ├── Up3.cal │ ├── Up4.cal │ ├── Up5.cal │ ├── Up6.cal │ ├── Up7.cal │ ├── Up8.cal │ ├── Up9.cal │ ├── PentatonicMajor.cal │ ├── PentatonicMinor.cal │ ├── Ryukyu.cal │ ├── Hirajoshi.cal │ ├── WholeTone.cal │ ├── Lydian.cal │ ├── Phrygian.cal │ ├── NaturalMajor.cal │ ├── NaturalMinor.cal │ ├── HarmonicMinor.cal │ └── PhrygianMajor.cal ├── Pitch19 │ ├── Up2.cal │ ├── Up.cal │ ├── Up10.cal │ ├── Up11.cal │ ├── Up12.cal │ ├── Up13.cal │ ├── Up14.cal │ ├── Up15.cal │ ├── Up16.cal │ ├── Up17.cal │ ├── Up18.cal │ ├── Up3.cal │ ├── Up4.cal │ ├── Up5.cal │ ├── Up6.cal │ ├── Up7.cal │ ├── Up8.cal │ ├── Up9.cal │ └── 32223322.cal ├── Shape │ ├── Curve.cal │ ├── Rectangle.cal │ ├── Trapezoid.cal │ ├── Initial.cal │ └── Hump.cal ├── Random │ ├── Choose2.cal │ ├── Choose4.cal │ └── Choose8.cal ├── Effect │ ├── MediumDetune.cal │ ├── SlightDetune.cal │ ├── StrongDetune.cal │ ├── BassOctaver.cal │ ├── HighOctaver.cal │ ├── Delay250.cal │ ├── Delay500.cal │ └── Double125.cal ├── Synth │ ├── BrownToad.cal │ ├── GreySmoke.cal │ ├── SpicyLight.cal │ ├── WetWood.cal │ ├── DarkGlass.cal │ ├── SteamPlant.cal │ ├── EveningFlight.cal │ ├── FreshMorning.cal │ ├── NiceMonster.cal │ ├── NightStation.cal │ ├── WindyAfternoon.cal │ └── SpringBird.cal └── Timbre │ ├── OldBottle.cal │ ├── BurntRubber.cal │ ├── BlackPepper.cal │ ├── ThinLamella.cal │ ├── FrozenDrop.cal │ ├── FastTrain.cal │ ├── Membrane.cal │ ├── MovingLava.cal │ ├── CoarseLinen.cal │ └── CrispyWind.cal ├── Stdlib ├── Tool │ ├── Repeat2.cal │ ├── Silence.cal │ ├── Repeat10.cal │ ├── Repeat3.cal │ ├── Repeat4.cal │ ├── Repeat5.cal │ ├── Repeat6.cal │ ├── Repeat7.cal │ ├── Repeat8.cal │ ├── Repeat9.cal │ ├── Silence2.cal │ ├── Silence3.cal │ ├── Silence4.cal │ ├── Silence5.cal │ ├── Silence6.cal │ ├── Silence7.cal │ ├── Silence8.cal │ ├── Silence9.cal │ ├── Chord2.cal │ ├── Silence10.cal │ ├── Empty.cal │ ├── Chord3.cal │ ├── LetRing2.cal │ ├── Chord4.cal │ ├── Chord5.cal │ ├── LetRing3.cal │ ├── LetRing4.cal │ └── LetRing5.cal ├── Pitch12 │ ├── Up.cal │ ├── Up2.cal │ ├── Down.cal │ ├── Up10.cal │ ├── Up3.cal │ ├── Up4.cal │ ├── Up5.cal │ ├── Up6.cal │ ├── Up7.cal │ ├── Up8.cal │ ├── Up9.cal │ ├── Up11.cal │ ├── PentatonicMajor.cal │ ├── PentatonicMinor.cal │ ├── Ryukyu.cal │ ├── Hirajoshi.cal │ ├── WholeTone.cal │ ├── Lydian.cal │ ├── Phrygian.cal │ ├── NaturalMajor.cal │ ├── NaturalMinor.cal │ ├── HarmonicMinor.cal │ └── PhrygianMajor.cal ├── Pitch19 │ ├── Up.cal │ ├── Up2.cal │ ├── Up10.cal │ ├── Up3.cal │ ├── Up4.cal │ ├── Up5.cal │ ├── Up6.cal │ ├── Up7.cal │ ├── Up8.cal │ ├── Up9.cal │ ├── Up11.cal │ ├── Up12.cal │ ├── Up13.cal │ ├── Up14.cal │ ├── Up15.cal │ ├── Up16.cal │ ├── Up17.cal │ ├── Up18.cal │ └── 32223322.cal ├── Shape │ ├── Curve.cal │ ├── Rectangle.cal │ ├── Trapezoid.cal │ ├── Initial.cal │ └── Hump.cal ├── Random │ ├── Choose2.cal │ ├── Choose4.cal │ └── Choose8.cal ├── Effect │ ├── MediumDetune.cal │ ├── SlightDetune.cal │ ├── StrongDetune.cal │ ├── BassOctaver.cal │ ├── HighOctaver.cal │ ├── Delay250.cal │ ├── Delay500.cal │ └── Double125.cal ├── Synth │ ├── BrownToad.cal │ ├── GreySmoke.cal │ ├── SpicyLight.cal │ ├── WetWood.cal │ ├── SteamPlant.cal │ ├── DarkGlass.cal │ ├── NiceMonster.cal │ ├── EveningFlight.cal │ ├── FreshMorning.cal │ ├── NightStation.cal │ ├── WindyAfternoon.cal │ └── SpringBird.cal └── Timbre │ ├── OldBottle.cal │ ├── Test.cal │ ├── BurntRubber.cal │ ├── BlackPepper.cal │ ├── ThinLamella.cal │ ├── FrozenDrop.cal │ ├── FastTrain.cal │ ├── Membrane.cal │ ├── MovingLava.cal │ ├── CoarseLinen.cal │ └── CrispyWind.cal ├── Vim ├── ftdetect │ └── cal.vim └── syntax │ └── cal.vim ├── Sources ├── Lists.ml ├── Beats.ml ├── Options.ml ├── Information.ml ├── FilePositions.ml ├── Strings.ml ├── Bunches.ml ├── Flags.ml ├── Scalars.ml ├── Properties.ml ├── Paths.ml ├── Evaluations.ml ├── Sounds.ml ├── Arguments.ml ├── Expressions.ml ├── Outputs.ml ├── Lexer.mll ├── Processings.ml ├── Files.ml ├── Calimba.ml ├── Parser.mly ├── Buffers.ml ├── Resolutions.ml ├── Errors.ml └── Statistics.ml ├── Makefile ├── Versions.md ├── Examples ├── Example1.cal └── Example2.cal └── README.md /Std/Tool/Repeat2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | %1 * %1 10 | 11 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | %1 * %1 10 | 11 | -------------------------------------------------------------------------------- /Std/Tool/Silence.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale vertical 0 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale vertical 0 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Std/Pitch12/Up2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | 11 | up[up] 12 | 13 | -------------------------------------------------------------------------------- /Std/Pitch19/Up2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | 11 | up[up] 12 | 13 | -------------------------------------------------------------------------------- /Std/Pitch12/Down.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale cycles 0.943874312681693 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Std/Pitch12/Up.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale cycles 1.05946309435930 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Std/Pitch19/Up.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale cycles 1.03715504444619 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale cycles 1.05946309435930 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | 11 | up[up] 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale cycles 1.03715504444619 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | 11 | up[up] 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r9 = put Repeat9 in 10 | 11 | r9 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r2 = put Repeat2 in 10 | 11 | r2 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r3 = put Repeat3 in 10 | 11 | r3 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r4 = put Repeat4 in 10 | 11 | r4 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r5 = put Repeat5 in 10 | 11 | r5 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r6 = put Repeat6 in 10 | 11 | r6 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r7 = put Repeat7 in 10 | 11 | r7 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Repeat9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r8 = put Repeat8 in 10 | 11 | r8 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Down.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | scale cycles 0.943874312681693 in 10 | %1 11 | 12 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r9 = put Repeat9 in 10 | 11 | r9 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r2 = put Repeat2 in 10 | 11 | r2 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r3 = put Repeat3 in 10 | 11 | r3 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r4 = put Repeat4 in 10 | 11 | r4 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r5 = put Repeat5 in 10 | 11 | r5 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r6 = put Repeat6 in 10 | 11 | r6 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r7 = put Repeat7 in 10 | 11 | r7 * %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Repeat9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let r8 = put Repeat8 in 10 | 11 | r8 * %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Shape/Curve.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | reset cycles in 10 | scale cycles 0.5 in 11 | %1 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Shape/Curve.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | reset cycles in 10 | scale cycles 0.5 in 11 | %1 12 | 13 | -------------------------------------------------------------------------------- /Std/Random/Choose2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | if random $dummy then 10 | %1 11 | else 12 | %2 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Random/Choose2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | if random $dummy then 10 | %1 11 | else 12 | %2 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up9 = put Up9 in 11 | 12 | up[up9] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up11.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up10 = put Up10 in 11 | 12 | up[up10] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up2 = put Up2 in 11 | 12 | up[up2] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up3 = put Up3 in 11 | 12 | up[up3] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up4 = put Up4 in 11 | 12 | up[up4] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up5 = put Up5 in 11 | 12 | up[up5] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up6 = put Up6 in 11 | 12 | up[up6] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up7 = put Up7 in 11 | 12 | up[up7] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch12/Up9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up8 = put Up8 in 11 | 12 | up[up8] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up9 = put Up9 in 11 | 12 | up[up9] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up11.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up10 = put Up10 in 11 | 12 | up[up10] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up12.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up11 = put Up11 in 11 | 12 | up[up11] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up13.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up12 = put Up12 in 11 | 12 | up[up12] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up14.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up13 = put Up13 in 11 | 12 | up[up13] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up15.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up14 = put Up14 in 11 | 12 | up[up14] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up16.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up15 = put Up15 in 11 | 12 | up[up15] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up17.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up16 = put Up16 in 11 | 12 | up[up16] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up18.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up17 = put Up17 in 11 | 12 | up[up17] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up2 = put Up2 in 11 | 12 | up[up2] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up3 = put Up3 in 11 | 12 | up[up3] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up4 = put Up4 in 11 | 12 | up[up4] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up5 = put Up5 in 11 | 12 | up[up5] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up6 = put Up6 in 11 | 12 | up[up6] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up7 = put Up7 in 11 | 12 | up[up7] 13 | 14 | -------------------------------------------------------------------------------- /Std/Pitch19/Up9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up8 = put Up8 in 11 | 12 | up[up8] 13 | 14 | -------------------------------------------------------------------------------- /Std/Shape/Rectangle.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let cur = put Curve in 10 | 11 | cur[scale vertical 32 in %1] 12 | 13 | -------------------------------------------------------------------------------- /Std/Shape/Trapezoid.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let cur = put Curve in 10 | 11 | cur[scale vertical 4 in %1] 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Chord2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.5 in %1) 10 | + 11 | (scale vertical 0.5 in %2) 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Silence10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 10 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 2 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 3 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 4 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 5 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 6 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 7 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 8 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Silence9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 9 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up9 = put Up9 in 11 | 12 | up[up9] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up2 = put Up2 in 11 | 12 | up[up2] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up3 = put Up3 in 11 | 12 | up[up3] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up4 = put Up4 in 11 | 12 | up[up4] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up5 = put Up5 in 11 | 12 | up[up5] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up6 = put Up6 in 11 | 12 | up[up6] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up7 = put Up7 in 11 | 12 | up[up7] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up8 = put Up8 in 11 | 12 | up[up8] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up9 = put Up9 in 11 | 12 | up[up9] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up2 = put Up2 in 11 | 12 | up[up2] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up3 = put Up3 in 11 | 12 | up[up3] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up4 = put Up4 in 11 | 12 | up[up4] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up5 = put Up5 in 11 | 12 | up[up5] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up6 = put Up6 in 11 | 12 | up[up6] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up7 = put Up7 in 11 | 12 | up[up7] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up8 = put Up8 in 11 | 12 | up[up8] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 2 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 3 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 4 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 5 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence6.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 6 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence7.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 7 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 8 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence9.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 9 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Random/Choose4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let ch2 = put Choose2 in 10 | 11 | ch2[ch2[%1; %2]; ch2[%3; %4]] 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Up11.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up10 = put Up10 in 11 | 12 | up[up10] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up11.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up10 = put Up10 in 11 | 12 | up[up10] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up12.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up11 = put Up11 in 11 | 12 | up[up11] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up13.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up12 = put Up12 in 11 | 12 | up[up12] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up14.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up13 = put Up13 in 11 | 12 | up[up13] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up15.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up14 = put Up14 in 11 | 12 | up[up14] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up16.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up15 = put Up15 in 11 | 12 | up[up15] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up17.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up16 = put Up16 in 11 | 12 | up[up16] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/Up18.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let up = put Up in 10 | let up17 = put Up17 in 11 | 12 | up[up17] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Random/Choose4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let ch2 = put Choose2 in 10 | 11 | ch2[ch2[%1; %2]; ch2[%3; %4]] 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Shape/Rectangle.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let cur = put Curve in 10 | 11 | cur[scale vertical 32 in %1] 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Shape/Trapezoid.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let cur = put Curve in 10 | 11 | cur[scale vertical 4 in %1] 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Chord2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.5 in %1) 10 | + 11 | (scale vertical 0.5 in %2) 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Tool/Silence10.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale horizontal 10 in 12 | s 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Empty.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale cycles 0 in 12 | scale horizontal 0 in 13 | s 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Tool/Empty.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | 11 | scale cycles 0 in 12 | scale horizontal 0 in 13 | s 14 | 15 | -------------------------------------------------------------------------------- /Vim/ftdetect/cal.vim: -------------------------------------------------------------------------------- 1 | " Author: Samuele Giraudo 2 | " Creation: aug. 2022 3 | " Modifications: aug. 2022 4 | 5 | " Part of the syntax file of the Calimba language. 6 | " This file has to be at ~/.vim/fdetect/cal.vim 7 | 8 | au BufRead,BufNewFile *.cal set filetype=cal 9 | 10 | -------------------------------------------------------------------------------- /Std/Effect/MediumDetune.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.65 in %1) 10 | + 11 | (scale vertical 0.35 in scale cycles 1.01 in %1) 12 | 13 | -------------------------------------------------------------------------------- /Std/Effect/SlightDetune.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.700 in %1) 10 | + 11 | (scale vertical 0.300 in scale cycles 1.005 in %1) 12 | 13 | -------------------------------------------------------------------------------- /Std/Effect/StrongDetune.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.600 in %1) 10 | + 11 | (scale vertical 0.400 in scale cycles 1.015 in %1) 12 | 13 | -------------------------------------------------------------------------------- /Std/Synth/BrownToad.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Initial in 10 | let timb = put ../Timbre/BurntRubber in 11 | 12 | sh ^ timb 13 | 14 | -------------------------------------------------------------------------------- /Std/Synth/GreySmoke.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Initial in 10 | let timb = put ../Timbre/BlackPepper in 11 | 12 | sh ^ timb 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Effect/MediumDetune.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.65 in %1) 10 | + 11 | (scale vertical 0.35 in scale cycles 1.01 in %1) 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Effect/SlightDetune.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.700 in %1) 10 | + 11 | (scale vertical 0.300 in scale cycles 1.005 in %1) 12 | 13 | -------------------------------------------------------------------------------- /Std/Synth/SpicyLight.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let timb = put ../Timbre/MovingLava in 11 | 12 | sh ^ timb 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Effect/StrongDetune.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.600 in %1) 10 | + 11 | (scale vertical 0.400 in scale cycles 1.015 in %1) 12 | 13 | -------------------------------------------------------------------------------- /Stdlib/Synth/BrownToad.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Initial in 10 | let timb = put ../Timbre/BurntRubber in 11 | 12 | sh ^ timb 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Synth/GreySmoke.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Initial in 10 | let timb = put ../Timbre/BlackPepper in 11 | 12 | sh ^ timb 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Synth/SpicyLight.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let timb = put ../Timbre/MovingLava in 11 | 12 | sh ^ timb 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/Chord3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.333 in %1) 10 | + 11 | (scale vertical 0.333 in %2) 12 | + 13 | (scale vertical 0.333 in %3) 14 | 15 | -------------------------------------------------------------------------------- /Std/Effect/BassOctaver.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.60 in %1) 10 | + 11 | (scale vertical 0.25 in %1,) 12 | + 13 | (scale vertical 0.15 in %1,,) 14 | 15 | -------------------------------------------------------------------------------- /Std/Effect/HighOctaver.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.60 in %1) 10 | + 11 | (scale vertical 0.25 in %1') 12 | + 13 | (scale vertical 0.15 in %1'') 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Tool/Chord3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.333 in %1) 10 | + 11 | (scale vertical 0.333 in %2) 12 | + 13 | (scale vertical 0.333 in %3) 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Effect/BassOctaver.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.60 in %1) 10 | + 11 | (scale vertical 0.25 in %1,) 12 | + 13 | (scale vertical 0.15 in %1,,) 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Effect/HighOctaver.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.60 in %1) 10 | + 11 | (scale vertical 0.25 in %1') 12 | + 13 | (scale vertical 0.15 in %1'') 14 | 15 | -------------------------------------------------------------------------------- /Std/Random/Choose8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let ch2 = put Choose2 in 10 | let ch4 = put Choose4 in 11 | 12 | ch4[ch2[%1; %2]; ch2[%3; %4]; ch2[%5; %6]; ch2[%7; %8]] 13 | 14 | -------------------------------------------------------------------------------- /Std/Tool/LetRing2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let c2 = put Chord2 in 11 | 12 | c2[ 13 | scale time 2 in %1; 14 | s[%3] * %2 15 | ] 16 | 17 | -------------------------------------------------------------------------------- /Stdlib/Random/Choose8.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let ch2 = put Choose2 in 10 | let ch4 = put Choose4 in 11 | 12 | ch4[ch2[%1; %2]; ch2[%3; %4]; ch2[%5; %6]; ch2[%7; %8]] 13 | 14 | -------------------------------------------------------------------------------- /Stdlib/Tool/LetRing2.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let c2 = put Chord2 in 11 | 12 | c2[ 13 | scale time 2 in %1; 14 | s[%3] * %2 15 | ] 16 | 17 | -------------------------------------------------------------------------------- /Std/Shape/Initial.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | let cur = put Curve in 11 | 12 | (scale horizontal 0.2 in cur) 13 | * 14 | (scale horizontal 0.9 in s[%1]) 15 | 16 | -------------------------------------------------------------------------------- /Std/Synth/WetWood.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Hump in 10 | let eff = put ../Effect/MediumDetune in 11 | let timb = put ../Timbre/Membrane in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Tool/Chord4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.25 in %1) 10 | + 11 | (scale vertical 0.25 in %2) 12 | + 13 | (scale vertical 0.25 in %3) 14 | + 15 | (scale vertical 0.25 in %4) 16 | 17 | -------------------------------------------------------------------------------- /Stdlib/Synth/WetWood.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Hump in 10 | let eff = put ../Effect/MediumDetune in 11 | let timb = put ../Timbre/Membrane in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Effect/Delay250.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | 11 | (scale vertical 0.80 in %1) 12 | + 13 | ((scale horizontal 0.25 in s[%2]) * (scale vertical 0.20 in %1)) 14 | 15 | -------------------------------------------------------------------------------- /Std/Effect/Delay500.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | 11 | (scale vertical 0.80 in %1) 12 | + 13 | ((scale horizontal 0.50 in s[%2]) * (scale vertical 0.20 in %1)) 14 | 15 | -------------------------------------------------------------------------------- /Std/Synth/DarkGlass.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/OldBottle in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Synth/SteamPlant.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Hump in 10 | let eff = put ../Effect/StrongDetune in 11 | let timb = put ../Timbre/FrozenDrop in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Shape/Initial.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | let cur = put Curve in 11 | 12 | (scale horizontal 0.2 in cur) 13 | * 14 | (scale horizontal 0.9 in s[%1]) 15 | 16 | -------------------------------------------------------------------------------- /Stdlib/Synth/SteamPlant.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Hump in 10 | let eff = put ../Effect/StrongDetune in 11 | let timb = put ../Timbre/FrozenDrop in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Tool/Chord4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.25 in %1) 10 | + 11 | (scale vertical 0.25 in %2) 12 | + 13 | (scale vertical 0.25 in %3) 14 | + 15 | (scale vertical 0.25 in %4) 16 | 17 | -------------------------------------------------------------------------------- /Std/Effect/Double125.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | 11 | (scale vertical 0.500 in %1) 12 | + 13 | ((scale horizontal 0.125 in s[%2]) * (scale vertical 0.500 in %1)) 14 | 15 | -------------------------------------------------------------------------------- /Std/Synth/EveningFlight.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/MediumDetune in 11 | let timb = put ../Timbre/CrispyWind in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Synth/FreshMorning.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/CoarseLinen in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Synth/NiceMonster.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/BassOctaver in 11 | let timb = put ../Timbre/MovingLava in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Synth/NightStation.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Rectangle in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/FastTrain in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Effect/Delay250.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | 11 | (scale vertical 0.80 in %1) 12 | + 13 | ((scale horizontal 0.25 in s[%2]) * (scale vertical 0.20 in %1)) 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Effect/Delay500.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | 11 | (scale vertical 0.80 in %1) 12 | + 13 | ((scale horizontal 0.50 in s[%2]) * (scale vertical 0.20 in %1)) 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Effect/Double125.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put ../Tool/Silence in 10 | 11 | (scale vertical 0.500 in %1) 12 | + 13 | ((scale horizontal 0.125 in s[%2]) * (scale vertical 0.500 in %1)) 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Synth/DarkGlass.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/OldBottle in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Synth/NiceMonster.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/BassOctaver in 11 | let timb = put ../Timbre/MovingLava in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Synth/EveningFlight.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/MediumDetune in 11 | let timb = put ../Timbre/CrispyWind in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Synth/FreshMorning.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Trapezoid in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/CoarseLinen in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Synth/NightStation.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Rectangle in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/FastTrain in 12 | 13 | sh ^ eff[timb] 14 | 15 | -------------------------------------------------------------------------------- /Std/Timbre/OldBottle.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.689 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.069 in scale cycles 3 in %1) 12 | + 13 | (scale vertical 0.242 in scale cycles 5 in %1) 14 | 15 | -------------------------------------------------------------------------------- /Stdlib/Timbre/OldBottle.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.689 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.069 in scale cycles 3 in %1) 12 | + 13 | (scale vertical 0.242 in scale cycles 5 in %1) 14 | 15 | -------------------------------------------------------------------------------- /Sources/Lists.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Returns the prefix of length n of the list lst. *) 7 | let rec prefix lst n = 8 | match lst, n with 9 | |_, n when n <= 0 -> [] 10 | |[], _ -> [] 11 | |x :: lst', n -> x :: (prefix lst' (n - 1)) 12 | 13 | -------------------------------------------------------------------------------- /Std/Tool/Chord5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.2 in %1) 10 | + 11 | (scale vertical 0.2 in %2) 12 | + 13 | (scale vertical 0.2 in %3) 14 | + 15 | (scale vertical 0.2 in %4) 16 | + 17 | (scale vertical 0.2 in %5) 18 | 19 | -------------------------------------------------------------------------------- /Stdlib/Tool/Chord5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.2 in %1) 10 | + 11 | (scale vertical 0.2 in %2) 12 | + 13 | (scale vertical 0.2 in %3) 14 | + 15 | (scale vertical 0.2 in %4) 16 | + 17 | (scale vertical 0.2 in %5) 18 | 19 | -------------------------------------------------------------------------------- /Std/Synth/WindyAfternoon.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Curve in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/ThinLamella in 12 | let c2 = put ../Tool/Chord2 in 13 | 14 | sh ^ c2[timb; eff] 15 | 16 | -------------------------------------------------------------------------------- /Std/Tool/LetRing3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let s2 = put Silence2 in 11 | let c3 = put Chord3 in 12 | 13 | c3[ 14 | scale time 3 in %1; 15 | s[%4] * (scale time 2 in %2); 16 | s2[%4] * %3 17 | ] 18 | 19 | -------------------------------------------------------------------------------- /Stdlib/Tool/LetRing3.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let s2 = put Silence2 in 11 | let c3 = put Chord3 in 12 | 13 | c3[ 14 | scale time 3 in %1; 15 | s[%4] * (scale time 2 in %2); 16 | s2[%4] * %3 17 | ] 18 | 19 | -------------------------------------------------------------------------------- /Stdlib/Synth/WindyAfternoon.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Curve in 10 | let eff = put ../Effect/SlightDetune in 11 | let timb = put ../Timbre/ThinLamella in 12 | let c2 = put ../Tool/Chord2 in 13 | 14 | sh ^ c2[timb; eff] 15 | 16 | -------------------------------------------------------------------------------- /Std/Shape/Hump.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let cur = put Curve in 10 | 11 | cur 12 | + 13 | cur[scale cycles 2 in scale time 0.500 in %1] 14 | + 15 | cur[scale cycles 3 in scale time 0.333 in %1] 16 | + 17 | cur[scale cycles 4 in scale time 0.250 in %1] 18 | 19 | -------------------------------------------------------------------------------- /Stdlib/Shape/Hump.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let cur = put Curve in 10 | 11 | cur 12 | + 13 | cur[scale cycles 2 in scale time 0.500 in %1] 14 | + 15 | cur[scale cycles 3 in scale time 0.333 in %1] 16 | + 17 | cur[scale cycles 4 in scale time 0.250 in %1] 18 | 19 | -------------------------------------------------------------------------------- /Stdlib/Timbre/Test.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: jul. 2023 4 | Modifications: jul. 2023 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.8 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.1 in scale cycles 10 in %1) 12 | + 13 | (scale vertical 0.06 in scale cycles 20 in %1) 14 | + 15 | (scale vertical 0.04 in scale cycles 30 in %1) 16 | 17 | -------------------------------------------------------------------------------- /Sources/Beats.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* A type for beats. *) 7 | type beats = Beat of int 8 | 9 | (* Returns the index of the beat b. *) 10 | let index b = 11 | let Beat index = b in 12 | index 13 | 14 | (* Returns a string representation of the beat b. *) 15 | let to_string b = 16 | Printf.sprintf "%%%d" (index b) 17 | 18 | -------------------------------------------------------------------------------- /Std/Synth/SpringBird.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Rectangle in 10 | let eff_1 = put ../Effect/SlightDetune in 11 | let eff_2 = put ../Effect/MediumDetune in 12 | let eff_3 = put ../Effect/StrongDetune in 13 | let c3 = put ../Tool/Chord3 in 14 | 15 | sh ^ c3[eff_1; eff_2; eff_3] 16 | 17 | -------------------------------------------------------------------------------- /Stdlib/Synth/SpringBird.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let sh = put ../Shape/Rectangle in 10 | let eff_1 = put ../Effect/SlightDetune in 11 | let eff_2 = put ../Effect/MediumDetune in 12 | let eff_3 = put ../Effect/StrongDetune in 13 | let c3 = put ../Tool/Chord3 in 14 | 15 | sh ^ c3[eff_1; eff_2; eff_3] 16 | 17 | -------------------------------------------------------------------------------- /Std/Tool/LetRing4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let s2 = put Silence2 in 11 | let s3 = put Silence3 in 12 | let c4 = put Chord4 in 13 | 14 | c4[ 15 | scale time 4 in %1; 16 | s[%5] * (scale time 3 in %2); 17 | s2[%5] * (scale time 2 in %3); 18 | s3[%5] * %4 19 | ] 20 | 21 | -------------------------------------------------------------------------------- /Stdlib/Tool/LetRing4.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let s2 = put Silence2 in 11 | let s3 = put Silence3 in 12 | let c4 = put Chord4 in 13 | 14 | c4[ 15 | scale time 4 in %1; 16 | s[%5] * (scale time 3 in %2); 17 | s2[%5] * (scale time 2 in %3); 18 | s3[%5] * %4 19 | ] 20 | 21 | -------------------------------------------------------------------------------- /Std/Timbre/BurntRubber.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.28 in scale cycles 1.0 in %1) 10 | + 11 | (scale vertical 0.15 in scale cycles 1.5 in %1) 12 | + 13 | (scale vertical 0.14 in scale cycles 2.0 in %1) 14 | + 15 | (scale vertical 0.22 in scale cycles 2.5 in %1) 16 | + 17 | (scale vertical 0.21 in scale cycles 3.0 in %1) 18 | 19 | -------------------------------------------------------------------------------- /Stdlib/Timbre/BurntRubber.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.28 in scale cycles 1.0 in %1) 10 | + 11 | (scale vertical 0.15 in scale cycles 1.5 in %1) 12 | + 13 | (scale vertical 0.14 in scale cycles 2.0 in %1) 14 | + 15 | (scale vertical 0.22 in scale cycles 2.5 in %1) 16 | + 17 | (scale vertical 0.21 in scale cycles 3.0 in %1) 18 | 19 | -------------------------------------------------------------------------------- /Std/Tool/LetRing5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let s2 = put Silence2 in 11 | let s3 = put Silence3 in 12 | let s4 = put Silence4 in 13 | let c5 = put Chord5 in 14 | 15 | c5[ 16 | scale time 5 in %1; 17 | s[%6] * (scale time 4 in %2); 18 | s2[%6] * (scale time 3 in %3); 19 | s3[%6] * (scale time 2 in %4); 20 | s4[%6] * %3 21 | ] 22 | 23 | -------------------------------------------------------------------------------- /Stdlib/Tool/LetRing5.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let s = put Silence in 10 | let s2 = put Silence2 in 11 | let s3 = put Silence3 in 12 | let s4 = put Silence4 in 13 | let c5 = put Chord5 in 14 | 15 | c5[ 16 | scale time 5 in %1; 17 | s[%6] * (scale time 4 in %2); 18 | s2[%6] * (scale time 3 in %3); 19 | s3[%6] * (scale time 2 in %4); 20 | s4[%6] * %3 21 | ] 22 | 23 | -------------------------------------------------------------------------------- /Std/Timbre/BlackPepper.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.2940 in scale cycles 0.7 in %1) 10 | + 11 | (scale vertical 0.5884 in scale cycles 1.0 in %1) 12 | + 13 | (scale vertical 0.0294 in scale cycles 1.3 in %1) 14 | + 15 | (scale vertical 0.0294 in scale cycles 1.6 in %1) 16 | + 17 | (scale vertical 0.0294 in scale cycles 1.9 in %1) 18 | + 19 | (scale vertical 0.0294 in scale cycles 2.2 in %1) 20 | 21 | -------------------------------------------------------------------------------- /Stdlib/Timbre/BlackPepper.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.2940 in scale cycles 0.7 in %1) 10 | + 11 | (scale vertical 0.5884 in scale cycles 1.0 in %1) 12 | + 13 | (scale vertical 0.0294 in scale cycles 1.3 in %1) 14 | + 15 | (scale vertical 0.0294 in scale cycles 1.6 in %1) 16 | + 17 | (scale vertical 0.0294 in scale cycles 1.9 in %1) 18 | + 19 | (scale vertical 0.0294 in scale cycles 2.2 in %1) 20 | 21 | -------------------------------------------------------------------------------- /Sources/Options.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul. 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Returns def if the optional value opt is None. Otherwise, returns the value carried by 7 | * opt. *) 8 | let value def opt = 9 | match opt with 10 | |Some x -> x 11 | |None -> def 12 | 13 | (* Returns the image by the map f of the value of the optional value of opt if any. None 14 | * is returned otherwise. *) 15 | let bind f opt = 16 | match opt with 17 | |None -> None 18 | |Some x -> f x 19 | 20 | -------------------------------------------------------------------------------- /Std/Timbre/ThinLamella.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.274 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.262 in scale cycles 2 in %1) 12 | + 13 | (scale vertical 0.219 in scale cycles 3 in %1) 14 | + 15 | (scale vertical 0.082 in scale cycles 4 in %1) 16 | + 17 | (scale vertical 0.027 in scale cycles 5 in %1) 18 | + 19 | (scale vertical 0.082 in scale cycles 6 in %1) 20 | + 21 | (scale vertical 0.054 in scale cycles 7 in %1) 22 | 23 | -------------------------------------------------------------------------------- /Stdlib/Timbre/ThinLamella.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.274 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.262 in scale cycles 2 in %1) 12 | + 13 | (scale vertical 0.219 in scale cycles 3 in %1) 14 | + 15 | (scale vertical 0.082 in scale cycles 4 in %1) 16 | + 17 | (scale vertical 0.027 in scale cycles 5 in %1) 18 | + 19 | (scale vertical 0.082 in scale cycles 6 in %1) 20 | + 21 | (scale vertical 0.054 in scale cycles 7 in %1) 22 | 23 | -------------------------------------------------------------------------------- /Std/Timbre/FrozenDrop.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.4519 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.2255 in scale cycles 2 in %1) 12 | + 13 | (scale vertical 0.0451 in scale cycles 3 in %1) 14 | + 15 | (scale vertical 0.1128 in scale cycles 4 in %1) 16 | + 17 | (scale vertical 0.0406 in scale cycles 5 in %1) 18 | + 19 | (scale vertical 0.0361 in scale cycles 6 in %1) 20 | + 21 | (scale vertical 0.0316 in scale cycles 7 in %1) 22 | + 23 | (scale vertical 0.0564 in scale cycles 8 in %1) 24 | 25 | -------------------------------------------------------------------------------- /Stdlib/Timbre/FrozenDrop.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.4519 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.2255 in scale cycles 2 in %1) 12 | + 13 | (scale vertical 0.0451 in scale cycles 3 in %1) 14 | + 15 | (scale vertical 0.1128 in scale cycles 4 in %1) 16 | + 17 | (scale vertical 0.0406 in scale cycles 5 in %1) 18 | + 19 | (scale vertical 0.0361 in scale cycles 6 in %1) 20 | + 21 | (scale vertical 0.0316 in scale cycles 7 in %1) 22 | + 23 | (scale vertical 0.0564 in scale cycles 8 in %1) 24 | 25 | -------------------------------------------------------------------------------- /Std/Timbre/FastTrain.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.2865 in scale cycles 0.25 in %1) 10 | + 11 | (scale vertical 0.1913 in scale cycles 0.50 in %1) 12 | + 13 | (scale vertical 0.3824 in scale cycles 1.00 in %1) 14 | + 15 | (scale vertical 0.1146 in scale cycles 3.00 in %1) 16 | + 17 | (scale vertical 0.0191 in scale cycles 6.00 in %1) 18 | + 19 | (scale vertical 0.0038 in scale cycles 12.00 in %1) 20 | + 21 | (scale vertical 0.0019 in scale cycles 24.00 in %1) 22 | + 23 | (scale vertical 0.0004 in scale cycles 48.00 in %1) 24 | 25 | -------------------------------------------------------------------------------- /Std/Timbre/Membrane.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.0510 in scale cycles 0.250 in %1) 10 | + 11 | (scale vertical 0.0765 in scale cycles 0.333 in %1) 12 | + 13 | (scale vertical 0.1275 in scale cycles 0.500 in %1) 14 | + 15 | (scale vertical 0.5104 in scale cycles 1.000 in %1) 16 | + 17 | (scale vertical 0.1530 in scale cycles 2.000 in %1) 18 | + 19 | (scale vertical 0.0510 in scale cycles 3.000 in %1) 20 | + 21 | (scale vertical 0.0255 in scale cycles 4.000 in %1) 22 | + 23 | (scale vertical 0.0051 in scale cycles 5.000 in %1) 24 | 25 | -------------------------------------------------------------------------------- /Stdlib/Timbre/FastTrain.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.2865 in scale cycles 0.25 in %1) 10 | + 11 | (scale vertical 0.1913 in scale cycles 0.50 in %1) 12 | + 13 | (scale vertical 0.3824 in scale cycles 1.00 in %1) 14 | + 15 | (scale vertical 0.1146 in scale cycles 3.00 in %1) 16 | + 17 | (scale vertical 0.0191 in scale cycles 6.00 in %1) 18 | + 19 | (scale vertical 0.0038 in scale cycles 12.00 in %1) 20 | + 21 | (scale vertical 0.0019 in scale cycles 24.00 in %1) 22 | + 23 | (scale vertical 0.0004 in scale cycles 48.00 in %1) 24 | 25 | -------------------------------------------------------------------------------- /Stdlib/Timbre/Membrane.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.0510 in scale cycles 0.250 in %1) 10 | + 11 | (scale vertical 0.0765 in scale cycles 0.333 in %1) 12 | + 13 | (scale vertical 0.1275 in scale cycles 0.500 in %1) 14 | + 15 | (scale vertical 0.5104 in scale cycles 1.000 in %1) 16 | + 17 | (scale vertical 0.1530 in scale cycles 2.000 in %1) 18 | + 19 | (scale vertical 0.0510 in scale cycles 3.000 in %1) 20 | + 21 | (scale vertical 0.0255 in scale cycles 4.000 in %1) 22 | + 23 | (scale vertical 0.0051 in scale cycles 5.000 in %1) 24 | 25 | -------------------------------------------------------------------------------- /Sources/Information.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: may. 2022 3 | * Modifications: may. 2022, aug. 2022, jul. 2023 4 | *) 5 | 6 | (* The type to add information for each expression (and its subexpressions). *) 7 | type information = { 8 | 9 | (* The position with respect to the file where the subexpression appears. *) 10 | file_position: FilePositions.file_positions 11 | } 12 | 13 | (* Returns the information specified by the file position file_position. *) 14 | let construct file_position = 15 | {file_position = file_position} 16 | 17 | (* Returns a string representation of the information info. *) 18 | let to_string info = 19 | FilePositions.to_string info.file_position 20 | 21 | -------------------------------------------------------------------------------- /Std/Pitch12/PentatonicMajor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | let u3 = put Up3 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u2 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u3 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_0 in 31 | u3 32 | else 33 | set on $deg_1 in 34 | u2 35 | 36 | -------------------------------------------------------------------------------- /Std/Pitch12/PentatonicMinor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | let u3 = put Up3 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u3 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u3 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_0 in 31 | u2 32 | else 33 | set on $deg_1 in 34 | u3 35 | 36 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/PentatonicMajor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | let u3 = put Up3 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u2 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u3 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_0 in 31 | u3 32 | else 33 | set on $deg_1 in 34 | u2 35 | 36 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/PentatonicMinor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | let u3 = put Up3 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u3 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u3 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_0 in 31 | u2 32 | else 33 | set on $deg_1 in 34 | u3 35 | 36 | -------------------------------------------------------------------------------- /Std/Pitch12/Ryukyu.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u4 = put Up4 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u4 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u2 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u4 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_0 in 32 | u 33 | else 34 | set on $deg_1 in 35 | u4 36 | 37 | -------------------------------------------------------------------------------- /Std/Pitch12/Hirajoshi.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u4 = put Up4 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u2 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u4 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_0 in 32 | u4 33 | else 34 | set on $deg_1 in 35 | u2 36 | 37 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Ryukyu.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u4 = put Up4 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u4 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u2 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u4 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_0 in 32 | u 33 | else 34 | set on $deg_1 in 35 | u4 36 | 37 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Hirajoshi.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u4 = put Up4 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u2 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u4 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_0 in 32 | u4 33 | else 34 | set on $deg_1 in 35 | u2 36 | 37 | -------------------------------------------------------------------------------- /Std/Timbre/MovingLava.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.108 in scale cycles 0.125 in %1) 10 | + 11 | (scale vertical 0.139 in scale cycles 0.250 in %1) 12 | + 13 | (scale vertical 0.171 in scale cycles 0.500 in %1) 14 | + 15 | (scale vertical 0.311 in scale cycles 1.000 in %1) 16 | + 17 | (scale vertical 0.031 in scale cycles 2.000 in %1) 18 | + 19 | (scale vertical 0.095 in scale cycles 3.000 in %1) 20 | + 21 | (scale vertical 0.015 in scale cycles 4.000 in %1) 22 | + 23 | (scale vertical 0.093 in scale cycles 5.000 in %1) 24 | + 25 | (scale vertical 0.003 in scale cycles 6.000 in %1) 26 | + 27 | (scale vertical 0.034 in scale cycles 7.000 in %1) 28 | 29 | -------------------------------------------------------------------------------- /Stdlib/Timbre/MovingLava.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.108 in scale cycles 0.125 in %1) 10 | + 11 | (scale vertical 0.139 in scale cycles 0.250 in %1) 12 | + 13 | (scale vertical 0.171 in scale cycles 0.500 in %1) 14 | + 15 | (scale vertical 0.311 in scale cycles 1.000 in %1) 16 | + 17 | (scale vertical 0.031 in scale cycles 2.000 in %1) 18 | + 19 | (scale vertical 0.095 in scale cycles 3.000 in %1) 20 | + 21 | (scale vertical 0.015 in scale cycles 4.000 in %1) 22 | + 23 | (scale vertical 0.093 in scale cycles 5.000 in %1) 24 | + 25 | (scale vertical 0.003 in scale cycles 6.000 in %1) 26 | + 27 | (scale vertical 0.034 in scale cycles 7.000 in %1) 28 | 29 | -------------------------------------------------------------------------------- /Std/Pitch12/WholeTone.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | 11 | if on $deg_0 then 12 | set off $deg_0 in 13 | set on $deg_1 in 14 | u2 15 | else if on $deg_1 then 16 | set off $deg_1 in 17 | set on $deg_2 in 18 | u2 19 | else if on $deg_2 then 20 | set off $deg_2 in 21 | set on $deg_3 in 22 | u2 23 | else if on $deg_3 then 24 | set off $deg_3 in 25 | set on $deg_4 in 26 | u2 27 | else if on $deg_4 then 28 | set off $deg_4 in 29 | set on $deg_5 in 30 | u2 31 | else if on $deg_5 then 32 | set off $deg_5 in 33 | set on $deg_0 in 34 | u2 35 | else 36 | set on $deg_1 in 37 | u2 38 | 39 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/WholeTone.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | 11 | if on $deg_0 then 12 | set off $deg_0 in 13 | set on $deg_1 in 14 | u2 15 | else if on $deg_1 then 16 | set off $deg_1 in 17 | set on $deg_2 in 18 | u2 19 | else if on $deg_2 then 20 | set off $deg_2 in 21 | set on $deg_3 in 22 | u2 23 | else if on $deg_3 then 24 | set off $deg_3 in 25 | set on $deg_4 in 26 | u2 27 | else if on $deg_4 then 28 | set off $deg_4 in 29 | set on $deg_5 in 30 | u2 31 | else if on $deg_5 then 32 | set off $deg_5 in 33 | set on $deg_0 in 34 | u2 35 | else 36 | set on $deg_1 in 37 | u2 38 | 39 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Author: Samuele Giraudo 2 | # Creation: may 2022 3 | # Modifications: may 2022, aug. 2022, nov. 2022, jul. 2023 4 | 5 | CC = ocamlbuild 6 | FLAGS = -r -cflags -w,A-4-70 -menhir "menhir --explain" 7 | #-tag debug -tag "optimize(2)" -tag "optimization_rounds(4)" 8 | LIBS =-package unix -package extlib -tag thread -use-menhir 9 | 10 | SRC_DIR = Sources 11 | 12 | NAME = calimba 13 | EXEC = Calimba.native 14 | 15 | .PHONY: all 16 | all: $(NAME) 17 | 18 | .PHONY: $(NAME) 19 | $(NAME): 20 | $(CC) $(FLAGS) $(LIBS) $(SRC_DIR)/$(EXEC) 21 | mv -f $(EXEC) $(NAME) 22 | 23 | .PHONY: noassert 24 | noassert: FLAGS += -cflag -noassert 25 | noassert: all 26 | 27 | .PHONY: clean 28 | clean: 29 | rm -rf _build 30 | rm -f $(NAME) 31 | 32 | .PHONY: stats 33 | stats: 34 | wc $(SRC_DIR)/*.ml $(SRC_DIR)/*.mly $(SRC_DIR)/*.mll 35 | 36 | -------------------------------------------------------------------------------- /Std/Timbre/CoarseLinen.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.1130 in scale cycles 0.5 in %1) 10 | + 11 | (scale vertical 0.3775 in scale cycles 1.0 in %1) 12 | + 13 | (scale vertical 0.1889 in scale cycles 2.0 in %1) 14 | + 15 | (scale vertical 0.0302 in scale cycles 3.0 in %1) 16 | + 17 | (scale vertical 0.1510 in scale cycles 4.0 in %1) 18 | + 19 | (scale vertical 0.0180 in scale cycles 6.0 in %1) 20 | + 21 | (scale vertical 0.1130 in scale cycles 8.0 in %1) 22 | + 23 | (scale vertical 0.0030 in scale cycles 16.0 in %1) 24 | + 25 | (scale vertical 0.0030 in scale cycles 32.0 in %1) 26 | + 27 | (scale vertical 0.0020 in scale cycles 64.0 in %1) 28 | + 29 | (scale vertical 0.0004 in scale cycles 128.0 in %1) 30 | 31 | -------------------------------------------------------------------------------- /Stdlib/Timbre/CoarseLinen.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.1130 in scale cycles 0.5 in %1) 10 | + 11 | (scale vertical 0.3775 in scale cycles 1.0 in %1) 12 | + 13 | (scale vertical 0.1889 in scale cycles 2.0 in %1) 14 | + 15 | (scale vertical 0.0302 in scale cycles 3.0 in %1) 16 | + 17 | (scale vertical 0.1510 in scale cycles 4.0 in %1) 18 | + 19 | (scale vertical 0.0180 in scale cycles 6.0 in %1) 20 | + 21 | (scale vertical 0.1130 in scale cycles 8.0 in %1) 22 | + 23 | (scale vertical 0.0030 in scale cycles 16.0 in %1) 24 | + 25 | (scale vertical 0.0030 in scale cycles 32.0 in %1) 26 | + 27 | (scale vertical 0.0020 in scale cycles 64.0 in %1) 28 | + 29 | (scale vertical 0.0004 in scale cycles 128.0 in %1) 30 | 31 | -------------------------------------------------------------------------------- /Std/Pitch12/Lydian.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u2 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else 41 | set on $deg_1 in 42 | u 43 | 44 | -------------------------------------------------------------------------------- /Std/Pitch12/Phrygian.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else 41 | set on $deg_1 in 42 | u 43 | 44 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Lydian.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u2 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else 41 | set on $deg_1 in 42 | u 43 | 44 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/Phrygian.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else 41 | set on $deg_1 in 42 | u 43 | 44 | -------------------------------------------------------------------------------- /Std/Pitch12/NaturalMajor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u2 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u2 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u 40 | else 41 | set on $deg_1 in 42 | u2 43 | 44 | -------------------------------------------------------------------------------- /Std/Pitch12/NaturalMinor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u2 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else 41 | set on $deg_1 in 42 | u2 43 | 44 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/NaturalMajor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u2 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u2 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u 40 | else 41 | set on $deg_1 in 42 | u2 43 | 44 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/NaturalMinor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u2 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u2 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else 41 | set on $deg_1 in 42 | u2 43 | 44 | -------------------------------------------------------------------------------- /Std/Pitch12/HarmonicMinor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u3 = put Up3 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u2 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u2 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u2 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_5 in 32 | u 33 | else if on $deg_5 then 34 | set off $deg_5 in 35 | set on $deg_6 in 36 | u3 37 | else if on $deg_6 then 38 | set off $deg_6 in 39 | set on $deg_0 in 40 | u 41 | else 42 | set on $deg_1 in 43 | u2 44 | 45 | -------------------------------------------------------------------------------- /Std/Pitch12/PhrygianMajor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u3 = put Up3 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u3 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u2 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_5 in 32 | u1 33 | else if on $deg_5 then 34 | set off $deg_5 in 35 | set on $deg_6 in 36 | u2 37 | else if on $deg_6 then 38 | set off $deg_6 in 39 | set on $deg_0 in 40 | u2 41 | else 42 | set on $deg_1 in 43 | u 44 | 45 | -------------------------------------------------------------------------------- /Std/Timbre/CrispyWind.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.266 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.231 in scale cycles 2 in %1) 12 | + 13 | (scale vertical 0.190 in scale cycles 3 in %1) 14 | + 15 | (scale vertical 0.112 in scale cycles 4 in %1) 16 | + 17 | (scale vertical 0.075 in scale cycles 5 in %1) 18 | + 19 | (scale vertical 0.055 in scale cycles 6 in %1) 20 | + 21 | (scale vertical 0.033 in scale cycles 7 in %1) 22 | + 23 | (scale vertical 0.011 in scale cycles 8 in %1) 24 | + 25 | (scale vertical 0.011 in scale cycles 9 in %1) 26 | + 27 | (scale vertical 0.007 in scale cycles 10 in %1) 28 | + 29 | (scale vertical 0.003 in scale cycles 11 in %1) 30 | + 31 | (scale vertical 0.003 in scale cycles 12 in %1) 32 | + 33 | (scale vertical 0.003 in scale cycles 13 in %1) 34 | 35 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/HarmonicMinor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u3 = put Up3 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u2 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u2 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u2 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_5 in 32 | u 33 | else if on $deg_5 then 34 | set off $deg_5 in 35 | set on $deg_6 in 36 | u3 37 | else if on $deg_6 then 38 | set off $deg_6 in 39 | set on $deg_0 in 40 | u 41 | else 42 | set on $deg_1 in 43 | u2 44 | 45 | -------------------------------------------------------------------------------- /Stdlib/Pitch12/PhrygianMajor.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u = put Up in 10 | let u2 = put Up2 in 11 | let u3 = put Up3 in 12 | 13 | if on $deg_0 then 14 | set off $deg_0 in 15 | set on $deg_1 in 16 | u 17 | else if on $deg_1 then 18 | set off $deg_1 in 19 | set on $deg_2 in 20 | u3 21 | else if on $deg_2 then 22 | set off $deg_2 in 23 | set on $deg_3 in 24 | u 25 | else if on $deg_3 then 26 | set off $deg_3 in 27 | set on $deg_4 in 28 | u2 29 | else if on $deg_4 then 30 | set off $deg_4 in 31 | set on $deg_5 in 32 | u1 33 | else if on $deg_5 then 34 | set off $deg_5 in 35 | set on $deg_6 in 36 | u2 37 | else if on $deg_6 then 38 | set off $deg_6 in 39 | set on $deg_0 in 40 | u2 41 | else 42 | set on $deg_1 in 43 | u 44 | 45 | -------------------------------------------------------------------------------- /Stdlib/Timbre/CrispyWind.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | (scale vertical 0.266 in scale cycles 1 in %1) 10 | + 11 | (scale vertical 0.231 in scale cycles 2 in %1) 12 | + 13 | (scale vertical 0.190 in scale cycles 3 in %1) 14 | + 15 | (scale vertical 0.112 in scale cycles 4 in %1) 16 | + 17 | (scale vertical 0.075 in scale cycles 5 in %1) 18 | + 19 | (scale vertical 0.055 in scale cycles 6 in %1) 20 | + 21 | (scale vertical 0.033 in scale cycles 7 in %1) 22 | + 23 | (scale vertical 0.011 in scale cycles 8 in %1) 24 | + 25 | (scale vertical 0.011 in scale cycles 9 in %1) 26 | + 27 | (scale vertical 0.007 in scale cycles 10 in %1) 28 | + 29 | (scale vertical 0.003 in scale cycles 11 in %1) 30 | + 31 | (scale vertical 0.003 in scale cycles 12 in %1) 32 | + 33 | (scale vertical 0.003 in scale cycles 13 in %1) 34 | 35 | -------------------------------------------------------------------------------- /Sources/FilePositions.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* A type to represent positions in a file. *) 7 | type file_positions = { 8 | path: string; 9 | line: int; 10 | column: int 11 | } 12 | 13 | (* Returns the file position having path as path, line a line number and column as column 14 | * number. *) 15 | let construct path line column = 16 | assert (path <> ""); 17 | assert (0 <= line); 18 | assert (0 <= column); 19 | {path = path; line = line; column = column} 20 | 21 | (* Returns the file position specified by the lexing position pos. *) 22 | let from_position pos = 23 | {path = pos.Lexing.pos_fname; 24 | line = pos.Lexing.pos_lnum; 25 | column = pos.Lexing.pos_cnum - pos.Lexing.pos_bol + 1} 26 | 27 | (* Returns a string representation of the file position fp. *) 28 | let to_string fp = 29 | Printf.sprintf "@%s L%d C%d" fp.path fp.line fp.column 30 | 31 | -------------------------------------------------------------------------------- /Std/Pitch19/32223322.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | let u3 = put Up3 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u3 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u3 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u3 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else if on $deg_7 then 41 | set off $deg_7 in 42 | set on $deg_0 in 43 | u2 44 | else 45 | set on $deg_1 in 46 | u3 47 | 48 | -------------------------------------------------------------------------------- /Stdlib/Pitch19/32223322.cal: -------------------------------------------------------------------------------- 1 | { 2 | Author: Samuele Giraudo 3 | Creation: aug. 2022 4 | Modifications: aug. 2022 5 | 6 | Part of the Calimba standard library. 7 | } 8 | 9 | let u2 = put Up2 in 10 | let u3 = put Up3 in 11 | 12 | if on $deg_0 then 13 | set off $deg_0 in 14 | set on $deg_1 in 15 | u3 16 | else if on $deg_1 then 17 | set off $deg_1 in 18 | set on $deg_2 in 19 | u2 20 | else if on $deg_2 then 21 | set off $deg_2 in 22 | set on $deg_3 in 23 | u2 24 | else if on $deg_3 then 25 | set off $deg_3 in 26 | set on $deg_4 in 27 | u2 28 | else if on $deg_4 then 29 | set off $deg_4 in 30 | set on $deg_5 in 31 | u3 32 | else if on $deg_5 then 33 | set off $deg_5 in 34 | set on $deg_6 in 35 | u3 36 | else if on $deg_6 then 37 | set off $deg_6 in 38 | set on $deg_0 in 39 | u2 40 | else if on $deg_7 then 41 | set off $deg_7 in 42 | set on $deg_0 in 43 | u2 44 | else 45 | set on $deg_1 in 46 | u3 47 | 48 | -------------------------------------------------------------------------------- /Sources/Strings.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul. 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Returns the string obtained by indenting each line of the string str by k spaces. *) 7 | let indent k str = 8 | assert (k >= 0); 9 | let ind = String.make k ' ' in 10 | str |> String.fold_left 11 | (fun (res, c') c -> 12 | let s = String.make 1 c in 13 | if c' = Some '\n' then (res ^ ind ^ s, Some c) else (res ^ s, Some c)) 14 | (ind, None) 15 | |> fst 16 | 17 | (* Representation of the 8 terminal colors in order to specify colored text to print. *) 18 | type color = 19 | |Black 20 | |Red 21 | |Green 22 | |Yellow 23 | |Blue 24 | |Magenta 25 | |Cyan 26 | |White 27 | 28 | (* Returns the code for each color corresponding to the coloration code in the terminal. *) 29 | let color_code col = 30 | match col with 31 | |Black -> 90 32 | |Red -> 91 33 | |Green -> 92 34 | |Yellow -> 93 35 | |Blue -> 94 36 | |Magenta -> 95 37 | |Cyan -> 96 38 | |White -> 97 39 | 40 | (* Returns the coloration of the string str by the color specified by the color col. *) 41 | let csprintf col str = 42 | Printf.sprintf "\027[%dm%s\027[39m" (color_code col) str 43 | 44 | -------------------------------------------------------------------------------- /Sources/Bunches.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (aug. 2021), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* A type to specify a part (a bunch) of a sound. *) 7 | type bunches = { 8 | (* The starting time of the bunch expressed in seconds. If it is None, then the 9 | * specified starting time is the origin. *) 10 | start: float option; 11 | 12 | (* The length of the bunch expressed in second. If it is None, then the specified length 13 | * is the maximal possible one. *) 14 | length: float option 15 | } 16 | 17 | (* Returns the bunch with the specified attributes. *) 18 | let construct start length = 19 | let start = if start |> Options.value 0.0 < 0.0 then None else start in 20 | let length = if length |> Options.value 0.0 < 0.0 then None else length in 21 | {start = start; length = length} 22 | 23 | (* Returns an option on the starting time of the bunch b. *) 24 | let start b = 25 | b.start 26 | 27 | (* Returns an option on the length of the bunch b. *) 28 | let length b = 29 | b.length 30 | 31 | (* Returns the factor of the sound s specified by the bunch b. *) 32 | let cut_sound s b = 33 | let dur = Sounds.duration s in 34 | let start = max 0.0 (min (start b|> Options.value 0.0) dur) in 35 | let end_time = dur -. start in 36 | let len = max 0.0 (min (length b |> Options.value end_time) end_time) in 37 | Sounds.factor s start len 38 | 39 | -------------------------------------------------------------------------------- /Sources/Flags.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* The type of flags. *) 7 | type flags = Flag of string 8 | 9 | (* The three possible statuses for a flag. *) 10 | type statuses = 11 | |On 12 | |Off 13 | |Random 14 | 15 | (* Returns the name of the flag fl. *) 16 | let name fl = 17 | let Flag name = fl in 18 | name 19 | 20 | (* Returns a string representation of the flag fl. *) 21 | let to_string fl = 22 | Printf.sprintf "$%s" (name fl) 23 | 24 | (* Returns a string representation of the flag status st. *) 25 | let status_to_string st = 26 | match st with 27 | |On -> "on" 28 | |Off -> "off" 29 | |Random -> "random" 30 | 31 | (* Tests if the list of flags flags contains the flag fl when st is On, does not contain fl 32 | * when st is Off, or returns a coin flip if fl is Random. *) 33 | let test flags st fl = 34 | match st with 35 | |On -> List.mem fl flags 36 | |Off -> not (List.mem fl flags) 37 | |Random -> Random.int 2 = 1 38 | 39 | (* Returns the list of flags obtained from the list of flags flags by adding the flag fl 40 | * when st is On, by suppressing fl when st is Off, or by adding or suppressing fl decided 41 | * by a coin flip. *) 42 | let rec modify flags st fl = 43 | match st with 44 | |On -> fl :: flags 45 | |Off -> flags |> List.filter (fun fl' -> fl' <> fl) 46 | |Random -> 47 | if Random.int 2 = 1 then modify flags On fl else modify flags Off fl 48 | 49 | -------------------------------------------------------------------------------- /Sources/Scalars.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul. 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* The type of the scalars. *) 7 | type scalars = Scalar of float 8 | 9 | (* Returns the value of the scalar s. *) 10 | let value s = 11 | let Scalar value = s in 12 | value 13 | 14 | (* Returns the addition of the scalars s and s'. *) 15 | let addition s s' = 16 | Scalar (value s +. value s') 17 | 18 | (* Returns the multiplication of the scalars s and s'. *) 19 | let multiplication s s' = 20 | Scalar (value s *. value s') 21 | 22 | (* Returns the exponentiation of the scalars s and s'. *) 23 | let exponentiation s s' = 24 | Scalar (value s ** value s') 25 | 26 | (* Returns a string representation of the scalar s. *) 27 | let to_string s = 28 | Printf.sprintf "%.8g" (value s) 29 | 30 | (* Returns the scalar specified by the string str. This string starts with ' and by dropping 31 | * this first character, it specifies a signed floating number in decimal. *) 32 | let from_string str = 33 | let v = String.sub str 1 ((String.length str) - 1) |> float_of_string in 34 | Scalar v 35 | 36 | (* Returns the rounded integer version of the float x. *) 37 | let float_to_rounded_int x = 38 | int_of_float (Float.round x) 39 | 40 | (* Returns the integer being the truncation of the float x. If x is too big or to small to 41 | * be converted into an integer, then max_int or min_int is returned. *) 42 | let bounded_int_of_float x = 43 | if x >= float_of_int max_int then 44 | max_int 45 | else if x <= float_of_int min_int then 46 | min_int 47 | else 48 | Float.to_int x 49 | 50 | -------------------------------------------------------------------------------- /Sources/Properties.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (may 2022), nov. 2022 3 | * Modifications: (may 2022, aug. 2022), nov. 2022, jul. 2023 4 | *) 5 | 6 | (* Tests if there are no inclusions in the expression e. *) 7 | let is_inclusion_free e = 8 | let st = Statistics.compute e in 9 | Statistics.nb_puts st = 0 10 | 11 | (* Tests if there are no alias uses in the expression e. This expression has to be inclusion 12 | * free. *) 13 | let is_alias_free e = 14 | assert (is_inclusion_free e); 15 | let st = Statistics.compute e in 16 | Statistics.nb_aliases st = 0 && Statistics.nb_alias_definitions st = 0 17 | 18 | (* Tests if there are no compositions in the expression e. This expression has to be 19 | * inclusion and alias free. *) 20 | let is_composition_free e = 21 | assert (is_inclusion_free e); 22 | assert (is_alias_free e); 23 | let st = Statistics.compute e in 24 | Statistics.nb_compositions st = 0 25 | 26 | (* Tests if there are no flags in the expression e. This expression has to be inclusion, 27 | * alias, and composition free. *) 28 | let is_flag_free e = 29 | assert (is_inclusion_free e); 30 | assert (is_alias_free e); 31 | assert (is_composition_free e); 32 | let st = Statistics.compute e in 33 | Statistics.nb_flag_tests st = 0 && Statistics.nb_flag_modifications st = 0 34 | 35 | (* Tests if the expression e is simple. This is the case if there is no flags, no 36 | * compositions, no aliases, and no inclusions in e. *) 37 | let is_simple e = 38 | is_inclusion_free e && is_alias_free e && is_composition_free e && is_flag_free e 39 | 40 | (* Returns the greatest beat index in the expression e. *) 41 | let greatest_beat_index e = 42 | let st = Statistics.compute e in 43 | Statistics.greatest_beat_index st 44 | 45 | -------------------------------------------------------------------------------- /Vim/syntax/cal.vim: -------------------------------------------------------------------------------- 1 | " Author: Samuele Giraudo 2 | " Creation: mar. 2022 3 | " Modifications: mar. 2022, may 2022, aug. 2022 4 | 5 | " Syntax file of the Calimba language. 6 | " This file has to be at ~/.vim/syntax/cal.vim 7 | 8 | if exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | " Turns off spell checking. 13 | set nospell 14 | 15 | " Structure keywords. 16 | syn keyword Structure begin 17 | syn keyword Structure end 18 | syn keyword Structure let 19 | syn keyword Structure in 20 | syn match Structure "=" 21 | 22 | " Unary operators keywords. 23 | syn keyword Operator scale 24 | syn keyword Operator reset 25 | 26 | " Attributes of unary operators keywords. 27 | syn keyword Special cycles 28 | syn keyword Special vertical 29 | syn keyword Special horizontal 30 | syn keyword Special time 31 | 32 | " Flag management keywords. 33 | syn keyword Structure if 34 | syn keyword Structure then 35 | syn keyword Structure else 36 | syn keyword Structure set 37 | 38 | " Attributes of flag management keywords. 39 | syn keyword Special on 40 | syn keyword Special off 41 | syn keyword Special random 42 | 43 | " Inclusion keyword. 44 | syn keyword Include put 45 | 46 | " Composition symbols. 47 | syn match Macro "\[" 48 | syn match Macro "\]" 49 | syn match Macro ";" 50 | 51 | " Operator symbols. 52 | syn match Operator "+" 53 | syn match Operator "*" 54 | syn match Operator "\^" 55 | syn match Operator "," 56 | syn match Operator "'" 57 | syn match Operator "<" 58 | syn match Operator ">" 59 | 60 | " Variables. 61 | syn match Constant "%\d\+" 62 | 63 | " Numbers. 64 | syn match Number "\d\+\.\?\d*" 65 | 66 | " Flags. 67 | syn match Identifier "$[a-zA-Z]\+[a-zA-Z0-9_]*" 68 | 69 | " Aliases. 70 | syn match Normal "[a-zA-Z]\+[a-zA-Z0-9_]*" 71 | 72 | " Comments. 73 | syn region Comment start="{" end="}" 74 | 75 | -------------------------------------------------------------------------------- /Sources/Paths.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul. 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Returns the extension of the file at path path. *) 7 | let extension path = 8 | let i = String.rindex path '.' in 9 | String.sub path i ((String.length path) - i) 10 | 11 | (* Tests if the file at path path has the extension ext (with the point). *) 12 | let has_extension ext path = 13 | if not (String.contains path '.') then 14 | false 15 | else 16 | extension path = ext 17 | 18 | (* Returns the string obtained from the path path by removing its file extension, including 19 | * the '.'. *) 20 | let remove_extension path = 21 | assert (String.contains path '.'); 22 | let i = String.rindex path '.' in 23 | String.sub path 0 i 24 | 25 | (* Returns the path obtained by suppressing the last part of the path path, by keeping the 26 | * `/`. For instance, if path is "aa/ab/abc", then "aa/ab/" is returned. If path has no 27 | * occurrence of '/', the empty path is returned. *) 28 | let trim path = 29 | try 30 | let i = String.rindex path '/' in 31 | String.sub path 0 (i + 1) 32 | with 33 | |Not_found -> "" 34 | 35 | (* Returns the path obtained from the path path by simplifying the "..". For instance, if 36 | * path is "a/b/c/../../d/e/..", then "a/d" is returned. *) 37 | let simplify path = 38 | let tmp = String.split_on_char '/' path in 39 | tmp |> List.fold_left 40 | (fun res u -> if u = ".." then List.tl res else u :: res) 41 | [] 42 | |> List.rev |> String.concat "/" 43 | 44 | (* Returns a path that does not correspond to any existing file by adding a string "_N" 45 | * just before the extension of the path path, where N is an adequate number. *) 46 | let new_distinct path = 47 | let path' = remove_extension path and ext' = extension path in 48 | let rec aux i = 49 | let res_path = Printf.sprintf "%s_%d%s" path' i ext' in 50 | if Sys.file_exists res_path then 51 | aux (i + 1) 52 | else 53 | res_path 54 | in 55 | aux 0 56 | 57 | -------------------------------------------------------------------------------- /Versions.md: -------------------------------------------------------------------------------- 1 | # Versions 2 | 3 | + `0.`1011` (2023-07-20) 4 | + Complete syntactic and paradigmatic overhaul of the language. 5 | 6 | + `0.1010` (2022-08-27) 7 | + The error management is improved. 8 | + The syntax is updated and improved. 9 | + New outputs of signals as images. 10 | + The possibility to specify bunches in the main command is implemented. 11 | 12 | + `0.1001` (2022-05-30) 13 | + Infix binary composition is removed. 14 | + Important code reorganization is performed. 15 | + Speed optimizations are added. 16 | + A new Makefile is set. 17 | + Standard library is improved. 18 | 19 | + `0.1000` (2022-05-10) 20 | + Infix binary composition is added. 21 | + A different paradigm is adopted: atoms are only sinusoidal waves with a given number 22 | number of cycle and with a duration of 1 sec. 23 | + The vertical and horizontal stretching operations are introduced. 24 | + The syntax is updated. 25 | 26 | + `0.0111` (2022-01-01) 27 | + Flags are introduced. 28 | + Mechanisms to create random music are introduced. 29 | + The syntax is slightly improved. 30 | 31 | + `0.0110` (2021-12-29) 32 | + Attack and decay dimensions are suppressed. 33 | + Modifications of dimensions values are enriched. 34 | 35 | + `0.0101` (2021-08-20) 36 | + The internal representation of musical phrases is improved. 37 | + The syntax of the language is completely redesigned. 38 | + The sound generation process is improved. 39 | + The output messages are improved. 40 | 41 | + `0.0100` (2021-05-30) 42 | + The internal representation of phrases is improved. 43 | + The syntax for introduce effects is improved. 44 | 45 | + `0.0011` (2021-01-01) 46 | + A first [documentation](Help.md) is written. 47 | + A mode to print layout analysis is added. 48 | + Built-in for [transpositions](Help.md#transpositions) are added. 49 | + Built-in for integer insertion is removed. 50 | + The robustness of inputs and outputs is improved. 51 | + Some internal optimizations and reorganizations are added. 52 | 53 | + `0.0010` (2020-12-12) 54 | + Initial version. 55 | 56 | -------------------------------------------------------------------------------- /Sources/Evaluations.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (may 2021), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Returns the sound specified by the expression e. This expression has to be simple. *) 7 | let compute e = 8 | assert (Properties.is_simple e); 9 | let mem = ref PMap.empty in 10 | let rec aux freq e = 11 | let preimage = (freq, e) in 12 | if PMap.exists preimage !mem then 13 | PMap.find preimage !mem 14 | else 15 | let res = 16 | match e with 17 | |Expressions.Beat _ -> Sounds.sinusoidal (Scalars.value freq) 1.0 18 | |Expressions.CycleOperation (_, op, e1) -> begin 19 | match op with 20 | |Expressions.UpdateCycleNumber x -> 21 | aux (Scalars.multiplication freq x) e1 22 | |Expressions.ResetCycleNumber -> aux (Scalars.Scalar 1.0) e1 23 | end 24 | |Expressions.UnaryOperation (_, op, e1) -> begin 25 | match op with 26 | |Expressions.VerticalScaling x -> 27 | Sounds.vertical_scaling (Scalars.value x) (aux freq e1) 28 | |Expressions.HorizontalScaling x -> 29 | Sounds.horizontal_scaling (Scalars.value x) (aux freq e1) 30 | end 31 | |Expressions.BinaryOperation (_, op, e1, e2) -> begin 32 | let s1 = aux freq e1 and s2 = aux freq e2 in 33 | match op with 34 | |Expressions.Concatenation -> Sounds.concatenate s1 s2 35 | |Expressions.Addition -> Sounds.add s1 s2 36 | |Expressions.Multiplication -> Sounds.multiply s1 s2 37 | end 38 | |Expressions.FlagTest _ |Expressions.FlagModification _ 39 | |Expressions.Alias _ |Expressions.AliasDefinition _ 40 | |_ -> Expressions.ValueError (e, "sound") |> raise 41 | in 42 | mem := PMap.add preimage res !mem; 43 | res 44 | in 45 | aux (Scalars.Scalar 1.0) e 46 | 47 | -------------------------------------------------------------------------------- /Examples/Example1.cal: -------------------------------------------------------------------------------- 1 | {Example 1.} 2 | 3 | 4 | {Comments are enclosed into { and }.} 5 | 6 | 7 | {Global setings.} 8 | 9 | {Sets the fundamental frequency to 220 Hz.} 10 | scale cycles 220 in 11 | 12 | {Sets the unit of time to 0.25 s.} 13 | scale time 0.25 in 14 | 15 | 16 | {Global definitions.} 17 | 18 | {Define the seven degrees D0, ..., D6 of the natural minor scale.} 19 | let next = put ../Stdlib/Pitch12/NaturalMinor in 20 | let D0 = %1 in 21 | let D1 = D0[next] in 22 | let D2 = D1[next] in 23 | let D3 = D2[next] in 24 | let D4 = D3[next] in 25 | let D5 = D4[next] in 26 | let D6 = D5[next] in 27 | 28 | {A tool to repeat two times a sound.} 29 | let r2 = put ../Stdlib/Tool/Repeat3 in 30 | 31 | {A tool to superimpose two phrases without distortion.} 32 | let c2 = put ../Stdlib/Tool/Chord2 in 33 | 34 | {A synthesizer.} 35 | let synth = put ../Stdlib/Synth/WetWood in 36 | 37 | {A delay effect.} 38 | let eff = put ../Stdlib/Effect/Delay500 in 39 | 40 | 41 | {Definitions of phrases.} 42 | 43 | {This bounds the new name p1 to the sequence of the notes obtained by concatenating 44 | (operation *) some degrees of the current scale. The operator ' increase the note one 45 | octave up and the operator , decrease the note one octave down.} 46 | let p1 = D0 * D2 * D4 * D2 * D0' * D2 * D0 * D0, in 47 | 48 | {This bounds the new name p2 to the phrase consisting in D0 and D4 played at the same time 49 | (a power chord), one octave down, and slowed down 8 times (the operator < doubles the 50 | duration of the notes). In the same way, the operator > divides by two the duration of the 51 | note (it is not used in this expression).} 52 | let p2 = c2[D0; D4],<<< in 53 | 54 | {This bounds the new name p3 to the superposition of the phrases p1 and p2.} 55 | let p3 = c2[p1; p2] in 56 | 57 | {This bounds the new name p to a new phrase formed from the previous ones. The bracket 58 | operator [...] is for phrase composition. For instance, p3[D2; %2] is the phrase p3 59 | transposed two degrees up (by following the natural minor scale.} 60 | let p = r2[p3 * p3[D1; %2] * p3[D6; %2], * p3[D2; %2] * p3[D5; %2], * p3[D6; %2], * p2] in 61 | 62 | 63 | {Main phrase.} 64 | 65 | {This is the main expression of the program. By composition, this is the phrase p plugged 66 | with the synthesizer synth (defined above). An effect eff is also plugged. This effect 67 | is a delay (defined above).} 68 | eff[p[synth; %2]; %2] 69 | 70 | -------------------------------------------------------------------------------- /Sources/Sounds.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul. 2015), apr. 2020 3 | * Modifications: apr. 2020, may 2020, jul. 2020, aug. 2020, dec. 2020, jan. 2021, may 2021 4 | * jun. 2021, aug. 2021, nov. 2021, dec. 2021, jan. 2022, may 2022, aug. 2022, nov. 2022, 5 | * jul. 2023 6 | *) 7 | 8 | (* Functional representation of a sound. *) 9 | type sounds = { 10 | (* This map encodes the wave of the sound. This associates with each time in seconds a 11 | * value. *) 12 | wave: float -> float; 13 | 14 | (* The duration of the sound in seconds. *) 15 | duration: float 16 | } 17 | 18 | (* Returns the wave of the sound s. *) 19 | let wave s = 20 | s.wave 21 | 22 | (* Returns the duration of the sound s in seconds. *) 23 | let duration s = 24 | s.duration 25 | 26 | (* Returns the value of the wave of the sound s at coordinate x, expressed in seconds. This 27 | * returns 0.0 if x is outside s. *) 28 | let value s x = 29 | if 0.0 <= x && x <= s.duration then s.wave x else 0.0 30 | 31 | (* Returns the factor of the sound s starting at time start in seconds and having as 32 | * duration duration in seconds. *) 33 | let factor s start duration = 34 | assert (start >= 0.0); 35 | assert (start +. duration <= s.duration); 36 | {wave = (fun x -> s.wave (x +. start)); duration = duration} 37 | 38 | (* Returns a sinusoidal sound of frequency freq in Hertz with a duration of duration 39 | * seconds. *) 40 | let sinusoidal freq duration = 41 | assert (0.0 <= duration); 42 | {wave = (fun x -> sin (2.0 *. Float.pi *. freq *. x)); duration = duration} 43 | 44 | (* Returns the sound obtained by reversing the sound s. *) 45 | let reverse s = 46 | {s with wave = (fun x -> s.wave (s.duration -. x))} 47 | 48 | (* Returns the sound obtained by multiplying each point of the sound s by the value c. The 49 | * result is cut. *) 50 | let vertical_scaling c s = 51 | {s with wave = (fun x -> c *. s.wave x)} 52 | 53 | (* Returns the sound obtained by scaling horizontally the sound s by the value c. *) 54 | let rec horizontal_scaling c s = 55 | if c = 0.0 then 56 | {wave = Fun.const 0.0; duration = 0.0} 57 | else if c > 0.0 then 58 | {wave = (fun x -> s.wave (x /. c)); duration = s.duration *. c} 59 | else 60 | horizontal_scaling (Float.abs c) (reverse s) 61 | 62 | (* Returns the sound obtained by performing point by point the binary operation op on the 63 | * waves of the sounds s1 and s2. *) 64 | let pointwise_operation op s1 s2 = 65 | {wave = (fun x -> op (value s1 x) (value s2 x)); duration = max s1.duration s2.duration} 66 | 67 | (* Returns the sound obtained by adding the sounds s1 and s2. They can have different 68 | * sizes. *) 69 | let add s1 s2 = 70 | pointwise_operation (+.) s1 s2 71 | 72 | (* Returns the sound obtained by the pointwise multiplication of the sounds s1 and s2. They 73 | * can have different sizes. *) 74 | let multiply s1 s2 = 75 | pointwise_operation ( *.) s1 s2 76 | 77 | (* Returns the sound obtained by concatenating the sounds s1 and s2. *) 78 | let concatenate s1 s2 = 79 | let wave x = 80 | if x <= s1.duration then s1.wave x else s2.wave (x -. s1.duration) 81 | in 82 | {wave = wave; duration = s1.duration +. s2.duration} 83 | 84 | -------------------------------------------------------------------------------- /Examples/Example2.cal: -------------------------------------------------------------------------------- 1 | {Example 2.} 2 | 3 | 4 | {Global setings.} 5 | 6 | {Sets the fundamental frequency to 110 Hz.} 7 | scale cycles 110 in 8 | 9 | {Sets the unit of time to 0.35 s.} 10 | scale time 0.35 in 11 | 12 | {Reduces the general volume.} 13 | scale vertical 0.3 in 14 | 15 | 16 | {Global definitions.} 17 | 18 | {Define the seven degrees D0, ..., D6 of the Phrygian scale.} 19 | let next = put ../Stdlib/Pitch12/Phrygian in 20 | let D0 = %1 in 21 | let D1 = D0[next] in 22 | let D2 = D1[next] in 23 | let D3 = D2[next] in 24 | let D4 = D3[next] in 25 | let D5 = D4[next] in 26 | let D6 = D5[next] in 27 | 28 | {A tool to create silences.} 29 | let s = put ../Stdlib/Tool/Silence in 30 | 31 | {A tool to create an empty phrase. This is useful to alter a phrase by deleting some of its 32 | notes by compositions.} 33 | let e = put ../Stdlib/Tool/Empty in 34 | 35 | {A tool to repeat two times a sound.} 36 | let r2 = put ../Stdlib/Tool/Repeat2 in 37 | 38 | {A tool to superimpose two phrases without distortion.} 39 | let c2 = put ../Stdlib/Tool/Chord2 in 40 | 41 | {A synthesizer.} 42 | let synth = put ../Stdlib/Synth/EveningFlight in 43 | 44 | 45 | {Definitions of phrases.} 46 | 47 | {This bounds the new name p1 to a sequence of notes. Some of these notes are composed with 48 | %2 or with %3. By default, the notes with no compositions can be seen as composed with %1. 49 | This allows us to have three sorts of notes (those composed with %1, %2, or %3) in order 50 | to be able in the sequel to compose p1 with three arguments. The first argument will 51 | replace the occurrences of %1, the second will replace the occurrences of %2, and the last 52 | will replace the occurrences of %3. Each subexpression %N is called a beat.} 53 | let p1 = 54 | D0 * D0 * D3[%2]< 55 | * 56 | D0 * (D3[%2] * D3[%2])> * D4 * D5 57 | * 58 | (D6[%3] * D6[%3]),> * D0 * D6< 59 | in 60 | 61 | {This bounds the new name p2 to a sequence of notes.} 62 | let p2 = 63 | (D0 * D0),, * D0[%2],< 64 | * 65 | D3,, * (D3[%2], * D3[%2])> * D3,< 66 | * 67 | (D6[%3] * D6),,, * D6,,< 68 | in 69 | 70 | {This bounds the new name p3 to the superposition of the phrases p1 and p2.} 71 | let p3 = c2[p1; p2] in 72 | 73 | 74 | {Main phrase.} 75 | 76 | {This is the main expression of the program. The keywords "begin" and "end" are understood 77 | as parentheses. This phrases uses p1, p2, and p3 and composition involving them. For 78 | instance, nine versions of p3 are used, obtained by considering p3 and various compositions 79 | of the form p3[a1; a2; a3] where a1, a2, and a3 are some other expressions. The final 80 | expression is composed with three synthesizer arguments in order to interpret each %1, %2, 81 | and %3 of the resulting expression as the sound specified by synth.} 82 | begin 83 | (r2[p2] * (D0 * D0),, * D0,< * (D0 * D0)>) 84 | * 85 | p3[D0; e; e]< 86 | * 87 | r2[ 88 | p3[D0; e; e] 89 | * 90 | p3 91 | * 92 | p3[D1; %2; %3] 93 | * 94 | p3[%1; D3; %3] 95 | * 96 | p3[%1; %2; D0<] 97 | * 98 | p3[D6,; %2; %3] 99 | * 100 | p3[%1; %2; D0<] 101 | ] 102 | * 103 | p3[D0; e; e] 104 | end 105 | [synth; synth; synth] 106 | 107 | -------------------------------------------------------------------------------- /Sources/Arguments.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul 2020), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Management of arguments. 7 | * 8 | * Here are some definitions: 9 | * 10 | * - An ARGUMENT is any word following the executable name when the executable is 11 | * launched. 12 | * For instance, if the executable name is x and the executable is launched with 13 | * x -o v1 v2 --opt2 v3 14 | * then -o, v1, v2 , --opt2, and v3 are the arguments. 15 | * 16 | * - A SHORT OPTION is any argument of the form -C where C is a character. 17 | * 18 | * - A LONG OPTION is any argument of the form --STR where STR is a string. 19 | * 20 | * - A VALUE of a (short or long) argument is a word following a (short or long) argument 21 | * or following itself a value. 22 | * For instance in 23 | * -o v1 v2 --opt2 v3 v4 v5 --opt3 24 | * v1 and v2 are values of -o, v3, v4, and v5 are values of --opt2, and --opt3 has no 25 | * values. 26 | *) 27 | 28 | (* Tests if the string arg can be a short option name. *) 29 | let is_short_option_name arg = 30 | String.length arg >= 2 && String.get arg 0 = '-' && String.get arg 1 <> '-' 31 | 32 | (* Tests if the string arg can be a long option name. *) 33 | let is_long_option_name arg = 34 | String.length arg >= 3 && String.get arg 0 = '-' && String.get arg 1 = '-' 35 | && String.get arg 2 <> '-' 36 | 37 | (* Tests if the string arg can be a value name. *) 38 | let is_value_name arg = 39 | String.length arg >= 1 && String.get arg 0 <> '-' 40 | 41 | (* Tests if the string arg can be an argument name. *) 42 | let is_argument_name arg = 43 | is_short_option_name arg || is_long_option_name arg || is_value_name arg 44 | 45 | (* Returns the list of the arguments. *) 46 | let arguments = 47 | let len = Array.length Sys.argv in 48 | let args = List.init (len - 1) (fun i -> Sys.argv.(i + 1)) in 49 | args |> List.filter is_argument_name 50 | 51 | (* Tests if the current execution environment admits the string arg as argument. *) 52 | let exists arg = 53 | assert (is_argument_name arg); 54 | List.mem arg arguments 55 | 56 | (* Returns the list of the arguments following the argument arg. The returned list is empty 57 | * when arg does not appear as an argument. *) 58 | let arguments_after arg = 59 | assert (is_argument_name arg); 60 | let rec search_suffix args = 61 | match args with 62 | |[] -> [] 63 | |x :: args' when x = arg -> args' 64 | |_ :: args' -> search_suffix args' 65 | in 66 | search_suffix arguments 67 | 68 | (* Returns the list of the values of the option opt. The empty list is returned when opt is 69 | * not an option. *) 70 | let option_values opt = 71 | assert (is_short_option_name opt || is_long_option_name opt); 72 | let rec longest_prefix_of_values args = 73 | match args with 74 | |x :: args' when is_value_name x -> x :: longest_prefix_of_values args' 75 | |_ -> [] 76 | in 77 | opt |> arguments_after |> longest_prefix_of_values 78 | 79 | (* Tests if the option name opt is an option and admits the value name v as value. *) 80 | let option_has_value opt v = 81 | assert (is_short_option_name opt || is_long_option_name opt); 82 | assert (is_value_name v); 83 | List.mem v (option_values opt) 84 | 85 | -------------------------------------------------------------------------------- /Sources/Expressions.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (jul. 2020), may 2021 3 | * Modifications: (jul. 2020, aug. 2020, dec. 2020, jan. 2021), may 2021, jun. 2021, 4 | * aug. 2021, nov. 2021, dec. 2021, jan. 2022, mar. 2022, may 2022, aug. 2022, nov. 2022, 5 | * jul. 2023 6 | *) 7 | 8 | (* The type of aliases. *) 9 | type aliases = string 10 | 11 | (* The type of file paths for inclusion. *) 12 | type paths = string 13 | 14 | (* The two operations to control the number of cycles for a beat. *) 15 | type cycle_operations = 16 | |UpdateCycleNumber of Scalars.scalars 17 | |ResetCycleNumber 18 | 19 | (* The two kinds of unary operations. *) 20 | type unary_operations = 21 | |VerticalScaling of Scalars.scalars 22 | |HorizontalScaling of Scalars.scalars 23 | 24 | (* The three kinds of binary operations. *) 25 | type binary_operations = 26 | |Concatenation 27 | |Addition 28 | |Multiplication 29 | 30 | (* A type to represent expressions. *) 31 | type expressions = 32 | (* The leaf. *) 33 | |Beat of (Information.information * Beats.beats) 34 | 35 | (* The control of the number of cycles for a beat. *) 36 | |CycleOperation of (Information.information * cycle_operations * expressions) 37 | 38 | (* The unary operations. *) 39 | |UnaryOperation of (Information.information * unary_operations * expressions) 40 | 41 | (* The binary operations. *) 42 | |BinaryOperation of 43 | (Information.information * binary_operations * expressions * expressions) 44 | 45 | (* The management of flags. *) 46 | |FlagTest of 47 | (Information.information * Flags.statuses * Flags.flags * expressions * expressions) 48 | |FlagModification of 49 | (Information.information * Flags.statuses * Flags.flags * expressions) 50 | 51 | (* The meta-operation of composition. *) 52 | |Composition of (Information.information * expressions * (expressions list)) 53 | 54 | (* The management of aliases. *) 55 | |Alias of (Information.information * aliases) 56 | |AliasDefinition of 57 | (Information.information * aliases * expressions * expressions) 58 | 59 | (* The management of inclusions. *) 60 | |Put of (Information.information * paths) 61 | 62 | (* An exception to handle cases where an expression has a inappropriate form. *) 63 | exception ValueError of expressions * string 64 | 65 | (* Returns a string representation of the cycle operation op. *) 66 | let cycle_operation_to_string op = 67 | match op with 68 | |UpdateCycleNumber x -> Printf.sprintf "scale cycles %s" (Scalars.to_string x) 69 | |ResetCycleNumber -> "reset cycles" 70 | 71 | (* Returns a string representation of the unary operation op. *) 72 | let unary_operation_to_string op = 73 | match op with 74 | |VerticalScaling x -> Printf.sprintf "scale vertical %s" (Scalars.to_string x) 75 | |HorizontalScaling x -> Printf.sprintf "scale horizontal %s" (Scalars.to_string x) 76 | 77 | (* Returns a string representation of the binary operation op. *) 78 | let binary_operation_to_string op = 79 | match op with 80 | |Concatenation -> "*" 81 | |Addition -> "+" 82 | |Multiplication -> "^" 83 | 84 | (* Returns the information data of the root of the expression e. *) 85 | let root_information e = 86 | match e with 87 | |Beat (info, _) 88 | |CycleOperation (info, _, _) 89 | |UnaryOperation (info, _, _) 90 | |BinaryOperation (info, _, _, _) 91 | |FlagTest (info, _, _, _, _) 92 | |FlagModification (info, _, _, _) 93 | |Composition (info, _, _) 94 | |Alias (info, _) 95 | |AliasDefinition (info, _, _, _) 96 | |Put (info, _) -> 97 | info 98 | 99 | -------------------------------------------------------------------------------- /Sources/Outputs.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Prints the string str as an error. *) 7 | let print_error str = 8 | str |> Strings.csprintf Strings.Red |> print_string; 9 | flush stdout 10 | 11 | (* Prints the string str as an information. *) 12 | let print_information_1 str = 13 | str |> Strings.csprintf Strings.Blue |> print_string; 14 | flush stdout 15 | 16 | (* Prints the string str as an information. *) 17 | let print_information_2 str = 18 | str |> Strings.csprintf Strings.Magenta |> print_string; 19 | flush stdout 20 | 21 | (* Prints the string str as an information. *) 22 | let print_information_3 str = 23 | str |> Strings.csprintf Strings.Yellow |> print_string; 24 | flush stdout 25 | 26 | (* Prints the string str as a success. *) 27 | let print_success str = 28 | str |> Strings.csprintf Strings.Green |> print_string; 29 | flush stdout 30 | 31 | (* Returns a buffer containing the string representation of the expression e. *) 32 | let to_buffered_string e = 33 | let buffer = Buffer.create 16 in 34 | let rec aux e = 35 | match e with 36 | |Expressions.Beat (_, b) -> 37 | Beats.to_string b |> Buffer.add_string buffer 38 | |Expressions.CycleOperation (_, op, e1) -> 39 | Printf.sprintf "(%s in " (Expressions.cycle_operation_to_string op) 40 | |> Buffer.add_string buffer; 41 | aux e1; 42 | ")" |> Buffer.add_string buffer 43 | |Expressions.UnaryOperation (_, op, e1) -> 44 | Printf.sprintf "(%s in " (Expressions.unary_operation_to_string op) 45 | |> Buffer.add_string buffer; 46 | aux e1; 47 | ")" |> Buffer.add_string buffer 48 | |Expressions.BinaryOperation (_, op, e1, e2) -> 49 | "(" |> Buffer.add_string buffer; 50 | aux e1; 51 | Printf.sprintf " %s " (Expressions.binary_operation_to_string op) 52 | |> Buffer.add_string buffer; 53 | aux e2; 54 | ")" |> Buffer.add_string buffer 55 | |Expressions.FlagTest (_, st, fl, e1, e2) -> 56 | Printf.sprintf "(if %s %s then " 57 | (Flags.status_to_string st) 58 | (Flags.to_string fl) 59 | |> Buffer.add_string buffer; 60 | aux e1; 61 | " else " |> Buffer.add_string buffer; 62 | aux e2; 63 | ")" |> Buffer.add_string buffer 64 | |Expressions.FlagModification (_, st, fl, e1) -> 65 | Printf.sprintf "(set %s %s in " 66 | (Flags.status_to_string st) 67 | (Flags.to_string fl) 68 | |> Buffer.add_string buffer; 69 | aux e1; 70 | ")" |> Buffer.add_string buffer 71 | |Expressions.Alias (_, alias) -> alias |> Buffer.add_string buffer 72 | |Expressions.AliasDefinition (_, alias, e1, e2) -> 73 | Printf.sprintf "(let %s = " alias |> Buffer.add_string buffer; 74 | aux e1; 75 | " in " |> Buffer.add_string buffer; 76 | aux e2; 77 | ")" |> Buffer.add_string buffer 78 | |Expressions.Composition (_, e1, e_lst) -> 79 | "(" |> Buffer.add_string buffer; 80 | aux e1; 81 | "[" |> Buffer.add_string buffer; 82 | e_lst |> List.iter (fun e2 -> 83 | aux e2; 84 | "; " |> Buffer.add_string buffer); 85 | Buffer.truncate buffer (Buffer.length buffer - 1); 86 | "]" |> Buffer.add_string buffer 87 | |Expressions.Put (_, path) -> path |> Buffer.add_string buffer 88 | in 89 | aux e; 90 | buffer 91 | 92 | -------------------------------------------------------------------------------- /Sources/Lexer.mll: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: may 2021 3 | * Modifications: may 2021, jun. 2021, aug. 2021, nov. 2021, dec. 2021, jan. 2022, 4 | * mar. 2022, may 2022, aug. 2022, jul. 2023 5 | *) 6 | 7 | { 8 | 9 | (* A type for the kinds of possible errors during the phase of the lexer. *) 10 | type error_kinds = 11 | |UnclosedComent 12 | |UnexpectedCharacter of char 13 | |Parsing 14 | 15 | (* A type to communicate about parsing or lexing errors. *) 16 | type errors = { 17 | position: FilePositions.file_positions; 18 | kind: error_kinds 19 | } 20 | 21 | (* An exception raised when an error is encountered. *) 22 | exception Error of errors 23 | 24 | (* Returns the kind of the error err. *) 25 | let error_to_error_kind err = 26 | err.kind 27 | 28 | (* Returns the file position of the error err. *) 29 | let error_to_position err = 30 | err.position 31 | 32 | (* Returns a string representation of the error kind ek. *) 33 | let error_kind_to_string ek = 34 | match ek with 35 | |UnclosedComent -> "unclosed comment" 36 | |UnexpectedCharacter c -> Printf.sprintf "unexpected character %c" c 37 | |Parsing -> "parsing error" 38 | 39 | (* Returns the file position obtained from the lexing buffer lexbuf. *) 40 | let lexbuf_to_position lexbuf = 41 | let pos = lexbuf.Lexing.lex_curr_p in 42 | FilePositions.construct 43 | pos.Lexing.pos_fname 44 | pos.Lexing.pos_lnum 45 | (pos.Lexing.pos_cnum - pos.Lexing.pos_bol + 1) 46 | 47 | (* Modifies the lexing buffer lexbuf so that it contains the next line. *) 48 | let next_line lexbuf = 49 | let pos = lexbuf.Lexing.lex_curr_p in 50 | lexbuf.Lexing.lex_curr_p <- 51 | {pos with 52 | Lexing.pos_bol = lexbuf.Lexing.lex_curr_pos; 53 | Lexing.pos_lnum = pos.Lexing.pos_lnum + 1} 54 | 55 | (* Raises Error with information about the unexpected character c. *) 56 | let unexpected_character_error lexbuf c = 57 | Error {position = lexbuf_to_position lexbuf; kind = UnexpectedCharacter c} |> raise 58 | 59 | (* Raises Error with information about an unclosed comment. *) 60 | let unclosed_comment_error lexbuf = 61 | Error {position = lexbuf_to_position lexbuf; kind = UnclosedComent} |> raise 62 | 63 | (* Raises Error with information about a parsing error. *) 64 | let parsing_error lexbuf = 65 | Error {position = lexbuf_to_position lexbuf; kind = Parsing} |> raise 66 | 67 | (* Returns the value computed by the parser parser_axiom, with the lexer lexer_axiom, and 68 | * with the lexing buffer lexbuf. If there is an error, the exception Error is raised. *) 69 | let parse_lexer_buffer parser_axiom lexer_axiom lexbuf = 70 | try 71 | parser_axiom lexer_axiom lexbuf 72 | with 73 | |Parser.Error -> parsing_error lexbuf 74 | |Error e -> Error e |> raise 75 | 76 | (* Returns the value contained in the file at path path, interpreted with the parser 77 | * parser_axiom, with the lexing bufer lexer_axiom. If an error is found, the exception 78 | * Error is raised. *) 79 | let value_from_file_path path parser_axiom lexer_axiom = 80 | assert (Sys.file_exists path); 81 | let ch = open_in path in 82 | let str = really_input_string ch (in_channel_length ch) in 83 | close_in ch; 84 | let lexbuf = Lexing.from_string str in 85 | lexbuf.Lexing.lex_curr_p <- {lexbuf.Lexing.lex_curr_p with Lexing.pos_fname = path}; 86 | parse_lexer_buffer parser_axiom lexer_axiom lexbuf 87 | 88 | } 89 | 90 | let letters = ['a'-'z' 'A'-'Z'] 91 | let digits = ['0'-'9'] 92 | let specials = ['_' '.' '/'] 93 | 94 | let char_string = (letters | specials) (letters | specials | digits)* 95 | let positive_number_string = digits+ '.'? digits* 96 | let number_string = '-'? positive_number_string 97 | 98 | rule read = parse 99 | |" " |"\t" {read lexbuf} 100 | |"\n" {next_line lexbuf; read lexbuf} 101 | |"(" {Parser.L_PAR} 102 | |")" {Parser.R_PAR} 103 | |"begin" {Parser.BEGIN} 104 | |"end" {Parser.END} 105 | |"+" {Parser.PLUS} 106 | |"*" {Parser.STAR} 107 | |"%" {Parser.PERCENT} 108 | |"^" {Parser.CIRCUMFLEX} 109 | |"reset" {Parser.RESET} 110 | |"scale" {Parser.SCALE} 111 | |"cycles" {Parser.CYCLES} 112 | |"vertical" {Parser.VERTICAL} 113 | |"horizontal" {Parser.HORIZONTAL} 114 | |"time" {Parser.TIME} 115 | |"'" {Parser.PRIME} 116 | |"," {Parser.COMMA} 117 | |"<" {Parser.LT} 118 | |">" {Parser.GT} 119 | |"$" {Parser.DOLLAR} 120 | |"if" {Parser.IF} 121 | |"then" {Parser.THEN} 122 | |"else" {Parser.ELSE} 123 | |"set" {Parser.SET} 124 | |"on" {Parser.ON} 125 | |"off" {Parser.OFF} 126 | |"random" {Parser.RANDOM} 127 | |";" {Parser.SEMICOLON} 128 | |"[" {Parser.L_BRACKET} 129 | |"]" {Parser.R_BRACKET} 130 | |"let" {Parser.LET} 131 | |"=" {Parser.EQUAL} 132 | |"in" {Parser.IN} 133 | |"put" {Parser.PUT} 134 | |char_string {Parser.STRING (Lexing.lexeme lexbuf)} 135 | |number_string {Parser.NUMBER (float_of_string (Lexing.lexeme lexbuf))} 136 | |"{" {comment 0 lexbuf} 137 | |eof {Parser.EOF} 138 | |_ as c {unexpected_character_error lexbuf c} 139 | 140 | and comment level = parse 141 | |"\n" {next_line lexbuf; comment level lexbuf} 142 | |"}" {if level = 0 then read lexbuf else comment (level - 1) lexbuf} 143 | |"{" {comment (level + 1) lexbuf} 144 | |eof {unclosed_comment_error lexbuf} 145 | |_ {comment level lexbuf} 146 | 147 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Calimba 2 | `<= 5.0.0`. An inferior but not too old version may be suitable.) 48 | + `opam` 49 | + `ocamlbuild` (Available by `opam install ocamlbuild`.) 50 | + `ocamlfind` (Available by `opam install ocamlfind`.) 51 | + `extlib` (Available by `opam install extlib`.) 52 | + `menhir` (Available by `opam install menhir`.) 53 | 54 | 55 | ### Building 56 | Here are the required steps to build the interpreter `calimba`: 57 | 58 | 1. Clone the repository somewhere by running 59 | `git clone https://github.com/SamueleGiraudo/Calimba.git`. 60 | 61 | 2. Install all dependencies (see the section above). 62 | 63 | 3. Build the project by running `make`. 64 | 65 | This creates an executable `calimba`. The following sections explain how to use it. 66 | 67 | 68 | ## User guide 69 | This [page](Help.md) contains the description of the Calimba language. 70 | 71 | Calimba program files must have `.cal` as extension. The main command is 72 | 73 | ``` 74 | ./calimba [--help] [--version] --file PATH [--verbose] [--bunch START LEN] [--text] [--write] [--draw] [--play] 75 | ``` 76 | 77 | where 78 | 79 | + `--help` prints the short help. 80 | + `--version` prints the version and other information. 81 | + `--file PATH` sets `PATH` as the path to the Qlusster program to consider. 82 | + `--verbose` enables the verbose mode. 83 | + `--bunch START LEN` specifies the part of the generated signal to consider, with its 84 | starting time `START` and length `LEN` in seconds. 85 | + `--text` creates the CAL file containing the processed expression specified the program. 86 | + `--write` creates the PCM file specified by the program. 87 | + `--draw` creates the SVG and PNG files specified by the program. 88 | + `--play` plays the signal specified by the program. 89 | 90 | 91 | ### Standard library 92 | The [standard library](Stdlib) contains definitions of synthesizers (trying to mimic some 93 | existing ones), effects, scales, transformations (repetitions, chords, let ring 94 | constructions), and randomization tools. 95 | 96 | 97 | ### Documentation of the standard library 98 | TODO 99 | 100 | 101 | ## Miscellaneous 102 | To get the syntax highlighting in the text editor `vim` for the Calimba language, put the 103 | file [cal.vim](Vim/syntax/cal.vim) at `~/.vim/syntax/cal.vim` and the file 104 | [cal.vim](Vim/ftdetect/cal.vim) at `~/.vim/fdetect/cal.vim`. 105 | 106 | 107 | ## Theoretical aspects 108 | 109 | ### Functional programming style 110 | All are expressions: notes, assemblies of notes, sound transformations, _etc._ For this 111 | reason, it is possible to build complex expressions by nesting some smaller ones, without 112 | any particular restriction. Besides, `let in` expressions can be used to write concise code, 113 | where names have restricted scopes. 114 | 115 | 116 | ### Expressions and compositions 117 | Any expression reduces to a simple expression, the fundamental data structure of Calimba 118 | programs. Simple expressions are then converted into sounds. Given some expressions, it is 119 | possible to assemble these in order to build a bigger expression. This operation is 120 | fundamental in the Calimba language. Following its use, this operation allows us to specify 121 | short patterns and consider some slight touch ups of these in order to include these in full 122 | musical compositions. 123 | 124 | 125 | ### Bibliography 126 | 127 | + About operads: 128 | + M. Méndez. 129 | Set operads in combinatorics and computer science. 130 | Springer, Cham, SpringerBriefs in Mathematics, xvi+129, 2015. 131 | 132 | + S. Giraudo. 133 | Nonsymmetric Operads in Combinatorics. 134 | Springer Nature Switzerland AG, ix+172, 2018. 135 | 136 | + About representation of music: 137 | + P. Hudak, 138 | An Algebraic Theory of Polymorphic Temporal Media. 139 | Practical Aspects of Declarative Languages. 140 | Lecture Notes in Computer Science, vol 3057, 2004. 141 | 142 | -------------------------------------------------------------------------------- /Sources/Processings.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: may 2021 3 | * Modifications: may 2021, jun. 2021, aug. 2021, nov. 2021, dec. 2021, jan. 2022, 4 | * mar. 2022, may 2022, aug. 2022, nov. 2022, jul. 2023 5 | *) 6 | 7 | (* A type to contain an option on a processed expression, an option on its sound, and a list 8 | * of errors. *) 9 | type processings = { 10 | (* The input expression. This is the expression obtained after each step of processing 11 | * before the computation of its sound. *) 12 | expression: Expressions.expressions option; 13 | 14 | (* The sound specified by the expression. *) 15 | sound: Sounds.sounds option; 16 | 17 | (* The list of errors detected during the processing. *) 18 | errors: Errors.errors list 19 | } 20 | 21 | (* A type to represent a transformation, which is a map from processings to processings. *) 22 | type transformations = Transformation of (processings -> processings) 23 | 24 | (* Returns the empty processing. *) 25 | let empty = 26 | {expression = None; sound = None; errors = []} 27 | 28 | (* Returns the expression of the processing pr. The expression of pr must be different from 29 | * None. *) 30 | let expression pr = 31 | assert (Option.is_some pr.expression); 32 | Option.get pr.expression 33 | 34 | (* Returns the sound of the processing pr. The expression of pr must be different from 35 | * None. *) 36 | let sound pr = 37 | assert (Option.is_some pr.sound); 38 | Option.get pr.sound 39 | 40 | (* Returns the list of errors of the processing pr. *) 41 | let errors pr = 42 | pr.errors 43 | 44 | (* Tests if there are errors in the processing pr. *) 45 | let has_errors pr = 46 | pr.errors <> [] 47 | 48 | (* Returns the processing obtained by applying the processing transformation tr on the 49 | * processing pr. *) 50 | let apply_transformation pr tr = 51 | let Transformation map = tr in 52 | map pr 53 | 54 | (* Returns the processing transformation which detects the errors computed by the function f 55 | * sending expressions to error lists. *) 56 | let error_transformation f = 57 | Transformation 58 | (fun pr -> 59 | if has_errors pr then 60 | pr 61 | else 62 | let errs = 63 | pr.expression 64 | |> Options.bind (fun e -> Some (f e)) 65 | |> Options.value [] 66 | in 67 | {pr with errors = errs}) 68 | 69 | (* Returns the processing transformation which applies the resolution computed by the 70 | * function f sending expressions to expressions. *) 71 | let resolution_transformation f = 72 | Transformation 73 | (fun pr -> 74 | if has_errors pr then 75 | pr 76 | else 77 | let e' = pr.expression |> Options.bind (fun e -> Some (f e)) in 78 | {pr with expression = e'}) 79 | 80 | (* Returns the processing of the expression e by resolving inclusions, aliases, and 81 | * compositions and flags, by constructing the list of errors in e, and by computing the 82 | * specified sound. 83 | * 84 | * This passes by the following steps: 85 | * 86 | * |=======================================|===============================================| 87 | * | PROCESSING | ERROR DETECTION | 88 | * |=======================================|===============================================| 89 | * | | Syntax errors in all included files and paths | 90 | * |---------------------------------------|-----------------------------------------------| 91 | * | Resolution of inclusions | | 92 | * |---------------------------------------|-----------------------------------------------| 93 | * | | Identifier errors | 94 | * |---------------------------------------|-----------------------------------------------| 95 | * | | Undefined alias errors | 96 | * |---------------------------------------|-----------------------------------------------| 97 | * | Resolution of aliases | | 98 | * |---------------------------------------|-----------------------------------------------| 99 | * | | Invalid arity of compositions | 100 | * |---------------------------------------|-----------------------------------------------| 101 | * | Resolution of compositions and flags | | 102 | * |=======================================|===============================================| 103 | *) 104 | let process e = 105 | let trs = [ 106 | error_transformation Errors.inclusion_errors; 107 | resolution_transformation Resolutions.resolve_inclusions; 108 | error_transformation Errors.invalid_identifier_errors; 109 | error_transformation Errors.undefined_alias_errors; 110 | resolution_transformation Resolutions.resolve_alias_definitions; 111 | error_transformation Errors.invalid_arity_composition_errors; 112 | resolution_transformation Resolutions.resolve_compositions_and_flags 113 | ] in 114 | let pr1 = {empty with expression = Some e} in 115 | let pr2 = trs |> List.fold_left apply_transformation pr1 in 116 | let s = 117 | if not (has_errors pr2) then Some (Evaluations.compute (expression pr2)) else None 118 | in 119 | {pr2 with sound = s} 120 | 121 | (* Returns the preprocessing of the expression contained in the file at path path. *) 122 | let process_path path = 123 | try 124 | process (Files.path_to_expression path) 125 | with 126 | |Lexer.Error err -> 127 | let errs = [Errors.syntax_error_from_lexer err] in 128 | {empty with errors = errs} 129 | 130 | -------------------------------------------------------------------------------- /Sources/Files.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (mau 2021), may 2022 3 | * Modifications: may 2022, aug. 2022, jul. 2023 4 | *) 5 | 6 | (* The extension of Calimba files. *) 7 | let extension = ".cal" 8 | 9 | (* The maximal beat (useful to avoid too big integers for beats). *) 10 | let max_beat = 1024 11 | 12 | (* The maximal length a flag. *) 13 | let max_flag_length = 255 14 | 15 | (* The maximal length for an alias (in definitions or in usage). *) 16 | let max_alias_length = 255 17 | 18 | (* The maximal length for a path. *) 19 | let max_path_length = 255 20 | 21 | (* Tests if the integer i can be a beat index. *) 22 | let is_beat_index i = 23 | 1 <= i && i <= max_beat 24 | 25 | (* Returns the path obtained from the path path by adding the Calimba file extension. *) 26 | let add_file_extension path = 27 | path ^ extension 28 | 29 | (* Tests if the character c is an alphabetic character. *) 30 | let is_alpha_character c = 31 | ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') 32 | 33 | (* Tests if the character c is a numerical character. *) 34 | let is_numerical_character c = 35 | ('0' <= c && c <= '9') 36 | 37 | (* Tests if the character c is a special character. *) 38 | let is_special_character c = 39 | c = '_' || c = '.' || c = '/' 40 | 41 | (* Tests if the character c is a character allowed in identifiers. *) 42 | let is_plain_character c = 43 | is_alpha_character c || is_numerical_character c || is_special_character c 44 | 45 | (* Tests if the string str can be a flag. *) 46 | let is_flag_name str = 47 | let len = String.length str in 48 | 1 <= len && len <= max_flag_length && is_alpha_character (String.get str 0) 49 | && String.for_all is_plain_character str 50 | 51 | (* Tests if the string str can be an alias. *) 52 | let is_alias str = 53 | let len = String.length str in 54 | 1 <= len && len <= max_alias_length && is_alpha_character (String.get str 0) 55 | && String.for_all is_plain_character str 56 | 57 | (* Tests if the string str can be a path of an included file. *) 58 | let is_inclusion_path str = 59 | let len = String.length str in 60 | if len > max_path_length then 61 | false 62 | else 63 | let levels = String.split_on_char '/' str |> List.fold_left 64 | (fun res u -> 65 | let v = if u = ".." then (List.hd res) - 1 else (List.hd res) + 1 in 66 | v :: res) 67 | [0] 68 | in 69 | if levels |> List.exists (fun v -> v < 0) then 70 | false 71 | else 72 | len >= (1 + String.length extension) && Paths.has_extension extension str 73 | && str |> String.for_all is_plain_character 74 | 75 | (* Returns the expression e obtained by adding to all its inclusion paths the prefix 76 | * pref. *) 77 | let complete_inclusion_paths pref e = 78 | let rec aux e = 79 | match e with 80 | |Expressions.Beat _ |Expressions.Alias _ -> e 81 | |Expressions.CycleOperation (info, op, e1') -> 82 | Expressions.CycleOperation (info, op, aux e1') 83 | |Expressions.UnaryOperation (info, op, e1) -> 84 | Expressions.UnaryOperation (info, op, aux e1) 85 | |Expressions.BinaryOperation (info, op, e1, e2) -> 86 | Expressions.BinaryOperation (info, op, aux e1, aux e2) 87 | |Expressions.FlagTest (info, st, fl, e1, e2) -> 88 | Expressions.FlagTest (info, st, fl, aux e1, aux e2) 89 | |Expressions.FlagModification (info, st, fl, e1) -> 90 | Expressions.FlagModification (info, st, fl, aux e1) 91 | |Expressions.AliasDefinition (info, alias, e1, e2) -> 92 | Expressions.AliasDefinition (info, alias, aux e1, aux e2) 93 | |Expressions.Composition (info, e1, e_lst) -> 94 | Expressions.Composition (info, aux e1, e_lst |> List.map aux) 95 | |Expressions.Put (info, path) -> Expressions.Put (info, pref ^ path) 96 | in 97 | aux e 98 | 99 | (* Returns the expression specified by the Calimba file at path path. The exception 100 | * Lexer.Error is raised when there are syntax errors in the program. *) 101 | let path_to_expression path = 102 | let e = Lexer.value_from_file_path path Parser.program Lexer.read in 103 | let path' = Paths.simplify path in 104 | e |> complete_inclusion_paths (Paths.trim path') 105 | (* TODO completion of identifiers *) 106 | 107 | (* Returns the list of the included paths in the expression e and recursively included by 108 | * the expressions of the included Calimba files. *) 109 | let included_paths e = 110 | let rec aux paths e = 111 | match e with 112 | |Expressions.Beat _ |Expressions.Alias _ -> [] 113 | |Expressions.CycleOperation (_, _, e1) |Expressions.UnaryOperation (_, _, e1) 114 | |Expressions.FlagModification (_, _, _, e1) -> 115 | aux paths e1 116 | |Expressions.BinaryOperation (_, _, e1, e2) 117 | |Expressions.AliasDefinition (_, _, e1, e2) 118 | |Expressions.FlagTest (_, _, _, e1, e2) -> 119 | List.append (aux paths e1) (aux paths e2) 120 | |Expressions.Composition (_, e1, e_lst) -> 121 | List.append (aux paths e1) (e_lst |> List.map (aux paths) |> List.flatten) 122 | |Expressions.Put (_, path) -> 123 | let path = add_file_extension path in 124 | if not (Sys.file_exists path) || not (is_inclusion_path path) then 125 | [] 126 | else 127 | let path' = Paths.simplify path in 128 | if List.mem path' paths then 129 | [path'] 130 | else 131 | try 132 | let e0 = path_to_expression path' in 133 | let paths' = path' :: paths in 134 | path' :: aux paths' e0 135 | with 136 | |Lexer.Error _ -> [] 137 | in 138 | aux [] e 139 | 140 | -------------------------------------------------------------------------------- /Sources/Calimba.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (aug. 2016), apr. 2020 3 | * Modifications: apr. 2020, may 2020, jul. 2020, aug. 2020, dec. 2020, jan. 2021, may 2021, 4 | * aug. 2021, nov. 2021, dec. 2021, jan. 2022, may 2022, aug. 2022, nov. 2022, jul. 2023 5 | *) 6 | 7 | (* Calimba - A program to program music. *) 8 | 9 | (* TODO 10 | * 11 | * - Improve flags by adding to them the prefix of their file of appearance. 12 | * 13 | * - Rewrite the parser by introducing expression_1, expression_2, etc. to manage 14 | * priorities. 15 | * 16 | * - Improve the syntax and the abstract syntax tree of expressions. 17 | * 18 | * - Add a loop operation. 19 | * 20 | * - Implement environment model. 21 | * 22 | * - Replace List.append by @. 23 | * 24 | * - Add prefixes to the messages of the raised exceptions by the name of their modules. 25 | * 26 | *) 27 | 28 | let name = "Calimba" 29 | 30 | let logo = "< Bunches.construct None None 79 | |[x1] -> Bunches.construct (Some (float_of_string x1)) None 80 | |x1 :: x2 :: _ -> 81 | Bunches.construct (Some (float_of_string x1)) (Some (float_of_string x2)) 82 | with 83 | |Failure _ -> begin 84 | "Error: after -b, there must be 0, 1, or 2 float arguments.\n" 85 | |> Outputs.print_error; 86 | "Default bunch has be assigned.\n" |> Outputs.print_information_1; 87 | exit 0 88 | end 89 | 90 | ;; 91 | 92 | (* Main expression. *) 93 | 94 | Random.self_init (); 95 | 96 | (* Creation of the buffer directory if it does not exist. *) 97 | let cmd = Printf.sprintf "mkdir -p %s" Buffers.path_directory in 98 | Sys.command cmd |> ignore; 99 | 100 | (* Version. *) 101 | if Arguments.exists "--version" then begin 102 | Outputs.print_success information; 103 | exit 0 104 | end; 105 | 106 | (* Help. *) 107 | if Arguments.exists "--help" then begin 108 | Outputs.print_information_1 help_string; 109 | exit 0 110 | end; 111 | 112 | (* Test if there is a single file path. *) 113 | let arg_lst = Arguments.option_values "--file" in 114 | if List.length arg_lst <> 1 then begin 115 | "Error: one path must follow the --file argument.\n" |> Outputs.print_error; 116 | exit 1 117 | end; 118 | 119 | (* The path of the file containing the program. *) 120 | let path = List.hd arg_lst in 121 | 122 | (* Checks the existence of the file at path path. *) 123 | if Sys.file_exists path |> not then begin 124 | Printf.sprintf "Error: there is no file %s.\n" path |> Outputs.print_error; 125 | exit 1 126 | end; 127 | 128 | (* Checks if the file has the right extension. *) 129 | if not (Paths.has_extension Files.extension path) then begin 130 | Printf.sprintf "Error: the file %s has not %s as extension.\n" path Files.extension 131 | |> Outputs.print_error; 132 | exit 1 133 | end; 134 | 135 | (* Detection of the verbose mode. *) 136 | let verbose = Arguments.exists "--verbose" in 137 | 138 | (* Detecting a bunch specification. *) 139 | let bunch = read_bunch () in 140 | 141 | (* Writing a CAL file. *) 142 | if Arguments.exists "--text" then 143 | Executions.interpret_path_and_write_expression verbose path bunch; 144 | 145 | (* Writing a PCM file. *) 146 | if Arguments.exists "--write" then 147 | Executions.interpret_path_and_write_sound verbose path bunch; 148 | 149 | (* Writing an SVG and PNG file. *) 150 | if Arguments.exists "--draw" then 151 | Executions.interpret_path_and_draw_sound verbose path bunch; 152 | 153 | (* Playing. *) 154 | if Arguments.exists "--play" then 155 | Executions.interpret_path_and_play verbose path bunch; 156 | 157 | exit 0 158 | 159 | -------------------------------------------------------------------------------- /Sources/Parser.mly: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: may 2021 3 | * Modifications: may 2021, jun. 2021, aug. 2021, nov. 2021, dec. 2021, jan. 2022, 4 | * mar. 2022, may 2022, aug. 2022, jul. 2023 5 | *) 6 | 7 | %token L_PAR R_PAR 8 | %token BEGIN END 9 | %token PERCENT 10 | %token PLUS STAR CIRCUMFLEX 11 | %token RESET 12 | %token SCALE 13 | %token CYCLES 14 | %token VERTICAL HORIZONTAL 15 | %token TIME 16 | %token PRIME COMMA 17 | %token LT GT 18 | %token DOLLAR 19 | %token IF 20 | %token THEN ELSE 21 | %token SET 22 | %token ON OFF RANDOM 23 | %token SEMICOLON 24 | %token L_BRACKET R_BRACKET 25 | %token LET 26 | %token EQUAL 27 | %token IN 28 | %token PUT 29 | %token STRING 30 | %token NUMBER 31 | %token EOF 32 | 33 | %left IN 34 | %left ELSE 35 | %left PLUS 36 | %left STAR 37 | %left CIRCUMFLEX 38 | %left L_BRACKET 39 | 40 | %nonassoc PRIME 41 | %nonassoc COMMA 42 | %nonassoc LT 43 | %nonassoc GT 44 | 45 | %start program 46 | 47 | %% 48 | 49 | program: 50 | |e=expression EOF {e} 51 | 52 | expression: 53 | |L_PAR e=expression R_PAR {e} 54 | |PERCENT i=NUMBER { 55 | let info = Information.construct (FilePositions.from_position $startpos) in 56 | Expressions.Beat (info, Beats.Beat (Scalars.bounded_int_of_float i)) 57 | } 58 | |e=scale {e} 59 | |e=reset {e} 60 | |e=binary_operation {e} 61 | |IF st=flag_status fl=flag THEN e1=expression ELSE e2=expression { 62 | let info = Information.construct (FilePositions.from_position $startpos) in 63 | Expressions.FlagTest (info, st, Flags.Flag fl, e1, e2) 64 | } 65 | |SET st=flag_status fl=flag IN e=expression { 66 | let info = Information.construct (FilePositions.from_position $startpos) in 67 | Expressions.FlagModification (info, st, Flags.Flag fl, e) 68 | } 69 | |e=expression L_BRACKET e_lst=separated_list(SEMICOLON, expression) R_BRACKET { 70 | let info = Information.construct (FilePositions.from_position $startpos) in 71 | Expressions.Composition (info, e, e_lst) 72 | } 73 | |alias=STRING { 74 | let info = Information.construct (FilePositions.from_position $startpos) in 75 | Expressions.Alias (info, alias) 76 | } 77 | |LET alias=STRING EQUAL e1=expression IN e2=expression { 78 | let info = Information.construct (FilePositions.from_position $startpos) in 79 | Expressions.AliasDefinition (info, alias, e1, e2) 80 | } 81 | |PUT path=STRING { 82 | let info = Information.construct (FilePositions.from_position $startpos) in 83 | Expressions.Put (info, path) 84 | } 85 | |e=sugar {e} 86 | 87 | scale: 88 | |SCALE CYCLES x=NUMBER IN e=expression { 89 | let info = Information.construct (FilePositions.from_position $startpos) in 90 | let sc = Scalars.Scalar x in 91 | Expressions.CycleOperation (info, Expressions.UpdateCycleNumber sc, e) 92 | } 93 | |SCALE VERTICAL x=NUMBER IN e=expression { 94 | let info = Information.construct (FilePositions.from_position $startpos) in 95 | let sc = Scalars.Scalar x in 96 | Expressions.UnaryOperation (info, Expressions.VerticalScaling sc, e) 97 | } 98 | |SCALE HORIZONTAL x=NUMBER IN e=expression { 99 | let info = Information.construct (FilePositions.from_position $startpos) in 100 | let sc = Scalars.Scalar x in 101 | Expressions.UnaryOperation (info, Expressions.HorizontalScaling sc, e) 102 | } 103 | 104 | reset: 105 | |RESET CYCLES IN e=expression { 106 | let info = Information.construct (FilePositions.from_position $startpos) in 107 | Expressions.CycleOperation (info, Expressions.ResetCycleNumber, e) 108 | } 109 | 110 | binary_operation: 111 | |e1=expression PLUS e2=expression { 112 | let info = Information.construct (FilePositions.from_position $startpos) in 113 | Expressions.BinaryOperation (info, Expressions.Addition, e1, e2) 114 | } 115 | |e1=expression STAR e2=expression { 116 | let info = Information.construct (FilePositions.from_position $startpos) in 117 | Expressions.BinaryOperation (info, Expressions.Concatenation, e1, e2) 118 | } 119 | |e1=expression CIRCUMFLEX e2=expression { 120 | let info = Information.construct (FilePositions.from_position $startpos) in 121 | Expressions.BinaryOperation (info, Expressions.Multiplication, e1, e2) 122 | } 123 | 124 | flag: 125 | |DOLLAR fl=STRING {fl} 126 | 127 | flag_status: 128 | |ON {Flags.On} 129 | |OFF {Flags.Off} 130 | |RANDOM {Flags.Random} 131 | 132 | sugar: 133 | |BEGIN e=expression END {e} 134 | |e=expression PRIME { 135 | let info = Information.construct (FilePositions.from_position $startpos) in 136 | let sc = Scalars.Scalar 2.0 in 137 | Expressions.CycleOperation (info, Expressions.UpdateCycleNumber sc, e) 138 | } 139 | |e=expression COMMA { 140 | let info = Information.construct (FilePositions.from_position $startpos) in 141 | let sc = Scalars.Scalar 0.5 in 142 | Expressions.CycleOperation (info, Expressions.UpdateCycleNumber sc, e) 143 | } 144 | |e=expression LT { 145 | let info = Information.construct (FilePositions.from_position $startpos) in 146 | let sc = Scalars.Scalar 2.0 in 147 | Expressions.CycleOperation (info, 148 | Expressions.UpdateCycleNumber sc, 149 | Expressions.UnaryOperation (info, Expressions.HorizontalScaling sc, e)) 150 | } 151 | |e=expression GT { 152 | let info = Information.construct (FilePositions.from_position $startpos) in 153 | let sc = Scalars.Scalar 0.5 in 154 | Expressions.CycleOperation (info, 155 | Expressions.UpdateCycleNumber sc, 156 | Expressions.UnaryOperation (info, Expressions.HorizontalScaling sc, e)) 157 | } 158 | |SCALE TIME x=NUMBER IN e=expression { 159 | let info = Information.construct (FilePositions.from_position $startpos) in 160 | let sc = Scalars.Scalar x in 161 | Expressions.CycleOperation (info, 162 | Expressions.UpdateCycleNumber sc, 163 | Expressions.UnaryOperation (info, Expressions.HorizontalScaling sc, e)) 164 | } 165 | 166 | -------------------------------------------------------------------------------- /Sources/Buffers.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: aug. 2021 3 | * Modifications: aug. 2021, nov. 2021, may 2022, aug. 2022, jul. 2023 4 | *) 5 | 6 | (* The buffer for sounds. A buffer contains a sound data encoded by its wave in the PCM 7 | * format. *) 8 | 9 | (* Returns the default sampling rate expressed in number of values by second for the wave 10 | * contained in the buffer. *) 11 | let sampling_rate = 12 | 48000 13 | 14 | (* Returns the default depth expressed in bytes (8 bits) used to represent each value of the 15 | * wave in the buffer. *) 16 | let depth = 17 | 4 18 | 19 | (* This is the default buffer path. The files stored in this directory are in RAM instead on 20 | * the disk. *) 21 | let path_directory = 22 | "/dev/shm/Calimba/" 23 | 24 | (* The default buffer file. *) 25 | let path_file = 26 | path_directory ^ "Buffer.pcm" 27 | 28 | (* Returns the length of the buffer in bytes. *) 29 | let length () = 30 | try 31 | let buffer = open_in path_file in 32 | let size = in_channel_length buffer in 33 | close_in buffer; 34 | size 35 | with 36 | |_ -> 0 37 | 38 | (* Returns the number of values of the wave in the buffer in seconds. *) 39 | let nb_values () = 40 | float (length ()) /. float depth 41 | 42 | (* Returns the duration of the wave in the buffer in seconds. *) 43 | let duration () = 44 | nb_values () /. float sampling_rate 45 | 46 | (* Remove the buffer file from the file system. *) 47 | let delete () = 48 | try Sys.remove path_file with |_ -> () 49 | 50 | (* Returns the list of size size of integers, each between 0 and 255, encoding the integer 51 | * value v. The representation is in little-endian and encodes negative values by their 52 | * two's complement. *) 53 | let value_to_bytes v size = 54 | assert (size >= 1); 55 | let rec encoding x n = 56 | if n = 0 then 57 | [] 58 | else 59 | let m = x land 0xFF and q = x asr 8 in 60 | m :: (encoding q (n - 1)) 61 | in 62 | if v >= 0 then 63 | encoding v size 64 | else 65 | let tmp = (1 lsl (size lsl 3)) + v in 66 | encoding tmp size 67 | 68 | (* Returns the integer value represented in little-endian by the list of bytes byte_lst. *) 69 | let bytes_to_value byte_lst = 70 | assert (byte_lst <> []); 71 | assert (byte_lst |> List.for_all (fun b -> 0 <= b && b < 256)); 72 | let byte_lst' = List.rev byte_lst in 73 | let tmp = byte_lst' |> List.fold_left (fun res b -> b + res * 256 ) 0 in 74 | if List.hd byte_lst' < 128 then 75 | tmp 76 | else 77 | - ((1 lsl ((List.length byte_lst) * 8)) - tmp) 78 | 79 | (* Writes the sound s in the buffer. *) 80 | let write s = 81 | let buffer = open_out path_file in 82 | let mult = (1 lsl ((8 * depth) - 1)) - 1 in 83 | let mult' = float mult in 84 | let nb_points = int_of_float (Sounds.duration s *. (float sampling_rate)) in 85 | let rec write_bytes i = 86 | if i mod 655536 = 0 then flush buffer; 87 | if i < nb_points then begin 88 | let x = float i /. float sampling_rate in 89 | let y = Sounds.value s x in 90 | let y' = 91 | mult' *. copysign (min (Float.abs y) 1.0) y 92 | |> Scalars.float_to_rounded_int 93 | in 94 | let byte_lst = value_to_bytes y' depth in 95 | byte_lst |> List.iter (fun x -> output_byte buffer x); 96 | write_bytes (i + 1) 97 | end 98 | in 99 | write_bytes 0; 100 | close_out buffer 101 | 102 | (* Returns the command to play a sound calling aplay with the good parameters. The path to 103 | * the buffer is not included by the command in order to be able to pipe it from a file. *) 104 | let command_play = 105 | let format_string = 106 | match depth with 107 | |1 -> "U8" 108 | |2 -> "S16_LE" 109 | |3 -> "S24_3LE" 110 | |4 -> "S32_LE" 111 | |_ -> raise (Failure "Unknown format.") 112 | in 113 | Printf.sprintf "aplay -c 1 -t raw -r %d -f %s &> /dev/null" sampling_rate format_string 114 | 115 | (* Plays the sound specified by the wave which is in the buffer. *) 116 | let play () = 117 | let cmd = Printf.sprintf "cat %s | %s" path_file command_play in 118 | Sys.command cmd |> ignore 119 | 120 | (* Returns a string containing information about the sound s of which the wave is in the 121 | * buffer. *) 122 | let to_information_string () = 123 | Printf.sprintf "Path: %s\n" path_file 124 | ^ 125 | Printf.sprintf "Sampling rate (Hz): %d\n" sampling_rate 126 | ^ 127 | Printf.sprintf "Depth (B): %d\n" depth 128 | ^ 129 | Printf.sprintf "Duration (s): %.2f\n" (duration ()) 130 | ^ 131 | Printf.sprintf "Size (B): %d\n" (length ()) 132 | 133 | (* Writes the buffer into a PCM file at path path. *) 134 | let write_pcm_file path = 135 | assert (not (Sys.file_exists path)); 136 | assert (Paths.extension path = ".pcm"); 137 | Sys.command (Printf.sprintf "cp %s %s" path_file path) |> ignore 138 | 139 | (* Draws the wave of the buffer into an SVG file at path path. *) 140 | let write_svg_file path = 141 | assert (not (Sys.file_exists path)); 142 | assert (Paths.extension path = ".svg"); 143 | let height = 256 in 144 | let width = 1024.0 +. 128.0 *. duration () |> Scalars.float_to_rounded_int in 145 | let nb_values = nb_values () in 146 | let max_value = 1 lsl ((depth * 8) - 1) |> float in 147 | let factor_x = float width -. 1.0 and factor_y = float height -. 1.0 in 148 | let buffer = open_in path_file in 149 | let f_out = open_out path in 150 | Printf.fprintf f_out "\n" width height; 151 | Printf.fprintf f_out " input_byte buffer) in 157 | let y = float (bytes_to_value byte_lst) /. max_value in 158 | let x' = factor_x *. x |> Scalars.float_to_rounded_int in 159 | let y' = factor_y *. (-. y +. 1.0) /. 2.0 |> Scalars.float_to_rounded_int in 160 | let line = Printf.sprintf "%d,%d\n" x' y' in 161 | if line <> previous_line then output_string f_out line; 162 | write_points (i + 1) line 163 | end 164 | in 165 | write_points 0 ""; 166 | Printf.fprintf f_out "\"/>\n"; 167 | Printf.fprintf f_out "\n"; 168 | close_in buffer; 169 | close_out f_out 170 | 171 | -------------------------------------------------------------------------------- /Sources/Resolutions.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (may 2021), jul. 2023 3 | * Modifications: jul. 2023 4 | *) 5 | 6 | (* Returns the expression obtained by replacing all free occurrences of the alias alias in 7 | * the expression e1 by the expression e2. *) 8 | let substitute_free_aliases e1 alias e2 = 9 | assert (Properties.is_inclusion_free e1); 10 | assert (Properties.is_inclusion_free e2); 11 | let rec aux e1 = 12 | match e1 with 13 | |Expressions.Beat _ -> e1 14 | |Expressions.CycleOperation (info, op, e1') -> 15 | Expressions.CycleOperation (info, op, aux e1') 16 | |Expressions.UnaryOperation (info, op, e1') -> 17 | Expressions.UnaryOperation (info, op, aux e1') 18 | |Expressions.BinaryOperation (info, op, e1', e2') -> 19 | Expressions.BinaryOperation (info, op, aux e1', aux e2') 20 | |Expressions.FlagTest (info, st, fl, e1', e2') -> 21 | Expressions.FlagTest (info, st, fl, aux e1', aux e2') 22 | |Expressions.FlagModification (info, st, fl, e1') -> 23 | Expressions.FlagModification (info, st, fl, aux e1') 24 | |Expressions.Composition (info, e1', e_lst) -> 25 | Expressions.Composition (info, aux e1', e_lst |> List.map aux) 26 | |Expressions.Alias (_, alias') -> if alias' = alias then e2 else e1 27 | |Expressions.AliasDefinition (info, alias', e1', e2') -> 28 | let e2'' = if alias' = alias then e2' else aux e2' in 29 | Expressions.AliasDefinition (info, alias', aux e1', e2'') 30 | |_ -> Expressions.ValueError (e1, "substitute_free_aliases") |> raise 31 | in 32 | aux e1 33 | 34 | (* Returns the expression obtained by composing the expression e with the list e_lst of 35 | * expressions. This replaces each beat i of e by the i-th element of e_lst (starting from 36 | * 1). The expression e has to be inclusion and alias free. *) 37 | let compose e e_lst = 38 | assert (Properties.is_inclusion_free e); 39 | assert (Properties.is_alias_free e); 40 | assert (Properties.greatest_beat_index e = List.length e_lst); 41 | let rec aux e = 42 | match e with 43 | |Expressions.Beat (_, b) -> List.nth e_lst (Beats.index b - 1) 44 | |Expressions.CycleOperation (info, op, e1) -> 45 | Expressions.CycleOperation (info, op, aux e1) 46 | |Expressions.UnaryOperation (info, op, e1) -> 47 | Expressions.UnaryOperation (info, op, aux e1) 48 | |Expressions.BinaryOperation (info, op, e1, e2) -> 49 | Expressions.BinaryOperation (info, op, aux e1, aux e2) 50 | |Expressions.FlagTest (info, st, fl, e1, e2) -> 51 | Expressions.FlagTest (info, st, fl, aux e1, aux e2) 52 | |Expressions.FlagModification (info, st, fl, e1) -> 53 | Expressions.FlagModification (info, st, fl, aux e1) 54 | |Expressions.Composition (info, e1, e_lst') -> 55 | Expressions.Composition (info, e1, e_lst' |> List.map aux) 56 | |_ -> Expressions.ValueError (e, "compose") |> raise 57 | in 58 | aux e 59 | 60 | (* Returns the expression obtained from the expression e by resolving its inclusions. The 61 | * expression e has to have no inclusion errors. *) 62 | let resolve_inclusions e = 63 | assert (Errors.inclusion_errors e = []); 64 | let rec aux e = 65 | match e with 66 | |Expressions.Beat _ |Expressions.Alias _ -> e 67 | |Expressions.CycleOperation (info, op, e1) -> 68 | Expressions.CycleOperation (info, op, aux e1) 69 | |Expressions.UnaryOperation (info, op, e1) -> 70 | Expressions.UnaryOperation (info, op, aux e1) 71 | |Expressions.BinaryOperation (info, op, e1, e2) -> 72 | Expressions.BinaryOperation (info, op, aux e1, aux e2) 73 | |Expressions.FlagTest (info, st, fl, e1, e2) -> 74 | Expressions.FlagTest (info, st, fl, aux e1, aux e2) 75 | |Expressions.FlagModification (info, st, fl, e1) -> 76 | Expressions.FlagModification (info, st, fl, aux e1) 77 | |Expressions.AliasDefinition (info, alias, e1, e2) -> 78 | Expressions.AliasDefinition (info, alias, aux e1, aux e2) 79 | |Expressions.Composition (info, e1, e_lst) -> 80 | Expressions.Composition (info, aux e1, e_lst |> List.map aux) 81 | |Expressions.Put (_, path) -> 82 | let path' = Paths.simplify (Files.add_file_extension path) in 83 | aux (Files.path_to_expression path') 84 | in 85 | aux e 86 | 87 | (* Returns the expression obtained by replacing all the aliases in the expression e by their 88 | * definitions. *) 89 | let resolve_alias_definitions e = 90 | assert (Properties.is_inclusion_free e); 91 | let rec aux e = 92 | match e with 93 | |Expressions.Beat _ |Expressions.Alias _ -> e 94 | |Expressions.CycleOperation (info, op, e1') -> 95 | Expressions.CycleOperation (info, op, aux e1') 96 | |Expressions.UnaryOperation (info, op, e1) -> 97 | Expressions.UnaryOperation (info, op, aux e1) 98 | |Expressions.BinaryOperation (info, op, e1, e2) -> 99 | Expressions.BinaryOperation (info, op, aux e1, aux e2) 100 | |Expressions.FlagTest (info, st, fl, e1, e2) -> 101 | Expressions.FlagTest (info, st, fl, aux e1, aux e2) 102 | |Expressions.FlagModification (info, st, fl, e1) -> 103 | Expressions.FlagModification (info, st, fl, aux e1) 104 | |Expressions.AliasDefinition (_, alias, e1, e2) -> 105 | substitute_free_aliases (aux e2) alias (aux e1) 106 | |Expressions.Composition (info, e1, e_lst) -> 107 | Expressions.Composition (info, aux e1, e_lst |> List.map aux) 108 | |_ -> Expressions.ValueError (e, "resolve_alias_definitions") |> raise 109 | in 110 | aux e 111 | 112 | (* Returns the expression obtained by resolving all the compositions and flags in the 113 | * expression e. This expression has to be inclusion free and alias free. *) 114 | let resolve_compositions_and_flags e = 115 | assert (Properties.is_inclusion_free e); 116 | assert (Properties.is_alias_free e); 117 | let rec aux flags e = 118 | match e with 119 | |Expressions.Beat _ -> e 120 | |Expressions.CycleOperation (info, op, e1) -> 121 | Expressions.CycleOperation (info, op, aux flags e1) 122 | |Expressions.UnaryOperation (info, op, e1) -> 123 | Expressions.UnaryOperation (info, op, aux flags e1) 124 | |Expressions.BinaryOperation (info, op, e1, e2) -> 125 | Expressions.BinaryOperation (info, op, aux flags e1, aux flags e2) 126 | |Expressions.FlagTest (_, st, fl, e1, e2) -> 127 | if Flags.test flags st fl then aux flags e1 else aux flags e2 128 | |Expressions.FlagModification (_, st, fl, e1) -> 129 | aux (Flags.modify flags st fl) e1 130 | |Expressions.Composition (_, e1, e_lst) -> aux flags (compose e1 e_lst) 131 | |_ -> Expressions.ValueError (e, "resolve_compositions_and_flags") |> raise 132 | in 133 | aux [] e 134 | 135 | -------------------------------------------------------------------------------- /Sources/Errors.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: (mau 2021), may 2022 3 | * Modifications: may 2022, aug. 2022, nov. 2022, jul. 2023 4 | *) 5 | 6 | (* The different kinds of errors a Calimba program can contain. *) 7 | type kinds = 8 | |InvalidAlias of Expressions.aliases 9 | |InvalidBeat of Beats.beats 10 | |InvalidFlag of Flags.flags 11 | |InvalidInclusionPath of Expressions.paths 12 | |UndefinedAlias of Expressions.aliases 13 | |InvalidHorizontalScalingValue of Scalars.scalars 14 | |InvalidArityComposition of int * int 15 | |CircularInclusion of Expressions.paths 16 | |SyntaxError of Lexer.error_kinds 17 | 18 | (* The type to represent information about an error. *) 19 | type errors = { 20 | (* The kind of the error. *) 21 | kind: kinds; 22 | 23 | (* Information about the subexpression where the error appears. *) 24 | information: Information.information 25 | } 26 | 27 | (* Returns the error obtained from the lexer error err. The kind of the returned error is 28 | * SyntaxError. *) 29 | let syntax_error_from_lexer err = 30 | let info = Information.construct (Lexer.error_to_position err) in 31 | let kind = SyntaxError (Lexer.error_to_error_kind err) in 32 | {information = info; kind = kind} 33 | 34 | (* Returns a string representation of the error err. *) 35 | let to_string err = 36 | Information.to_string err.information ^ ": " ^ 37 | match err.kind with 38 | |InvalidAlias alias -> Printf.sprintf "invalid alias %s" alias 39 | |InvalidBeat b -> Printf.sprintf "invalid beat %s" (Beats.to_string b); 40 | |InvalidFlag fl -> Printf.sprintf "invalid flag $%s" (Flags.to_string fl); 41 | |InvalidInclusionPath path -> Printf.sprintf "path %s is invalid for inclusion" path 42 | |UndefinedAlias alias -> Printf.sprintf "undefined alias %s" alias 43 | |InvalidHorizontalScalingValue x -> 44 | Printf.sprintf "invalid horizontal scaling value %s" (Scalars.to_string x) 45 | |InvalidArityComposition (n, n') -> 46 | Printf.sprintf "composition expects %d argument(s) instead of %d" n n' 47 | |CircularInclusion path -> Printf.sprintf "circular inclusion involving %s" path 48 | |SyntaxError err -> Lexer.error_kind_to_string err 49 | 50 | (* Returns the list of the inclusion errors in the expression e and recursively in the 51 | * expressions of the included Calimba files. *) 52 | let inclusion_errors e = 53 | let rec aux paths e = 54 | match e with 55 | |Expressions.Beat _ |Expressions.Alias _ -> [] 56 | |Expressions.CycleOperation (_, _, e1) |Expressions.UnaryOperation (_, _, e1) 57 | |Expressions.FlagModification (_, _, _, e1) -> 58 | aux paths e1 59 | |Expressions.BinaryOperation (_, _, e1, e2) 60 | |Expressions.AliasDefinition (_, _, e1, e2) 61 | |Expressions.FlagTest (_, _, _, e1, e2) -> 62 | List.append (aux paths e1) (aux paths e2) 63 | |Expressions.Composition (_, e1, e_lst) -> 64 | List.append (aux paths e1) (e_lst |> List.map (aux paths) |> List.flatten) 65 | |Expressions.Put (info, path) -> 66 | let path = Files.add_file_extension path |> Paths.simplify in 67 | if not (Sys.file_exists path) || not (Files.is_inclusion_path path) then 68 | [{kind = InvalidInclusionPath path; information = info}] 69 | else 70 | if List.mem path paths then 71 | [] 72 | else 73 | try 74 | let e0 = Files.path_to_expression path in 75 | let paths' = path :: paths in 76 | if List.mem path (Files.included_paths e0) then 77 | [{kind = CircularInclusion path; information = info}] 78 | else 79 | aux paths' e0 80 | with 81 | |Lexer.Error err -> [syntax_error_from_lexer err] 82 | in 83 | aux [] e |> List.sort_uniq compare 84 | 85 | (* Returns the list of the invalid identifiers in the expression e. This expression has to 86 | * be inclusion free. *) 87 | let invalid_identifier_errors e = 88 | assert (Properties.is_inclusion_free e); 89 | let rec aux e = 90 | match e with 91 | |Expressions.Beat (info, b) -> 92 | if Files.is_beat_index (Beats.index b) then 93 | [] 94 | else 95 | [{kind = InvalidBeat b; information = info}] 96 | |Expressions.CycleOperation (_, _, e1) 97 | |Expressions.UnaryOperation (_, _, e1) -> 98 | aux e1 99 | |Expressions.BinaryOperation (_, _, e1, e2) -> List.append (aux e1) (aux e2) 100 | |Expressions.FlagTest (info, _, fl, e1, e2) -> 101 | let tmp = List.append (aux e1) (aux e2) in 102 | if Files.is_flag_name (Flags.name fl) then 103 | tmp 104 | else 105 | {kind = InvalidFlag fl; information = info} :: tmp 106 | |Expressions.FlagModification (info, _, fl, e1) -> 107 | let tmp = aux e1 in 108 | if Files.is_flag_name (Flags.name fl) then 109 | tmp 110 | else 111 | {kind = InvalidFlag fl; information = info} :: tmp 112 | |Expressions.Composition (_, e1, e_lst) -> 113 | List.append (aux e1) (e_lst |> List.map aux |> List.flatten) 114 | |Expressions.Alias (info, alias) -> 115 | if Files.is_alias alias then 116 | [] 117 | else 118 | [{kind = InvalidAlias alias; information = info}] 119 | |Expressions.AliasDefinition (info, alias, e1, e2) -> 120 | let tmp = List.append (aux e1) (aux e2) in 121 | if Files.is_alias alias then 122 | tmp 123 | else 124 | {kind = InvalidAlias alias; information = info} :: tmp 125 | |_ -> Expressions.ValueError (e, "invalid_identifier_errors") |> raise 126 | in 127 | aux e |> List.sort_uniq compare 128 | 129 | (* Returns the list of the errors about the undefined aliases in the expression e. This 130 | * expression has to be inclusion free. *) 131 | let undefined_alias_errors e = 132 | assert (Properties.is_inclusion_free e); 133 | let rec aux e = 134 | match e with 135 | |Expressions.Beat _ -> [] 136 | |Expressions.CycleOperation (_, _, e1) |Expressions.UnaryOperation (_, _, e1) 137 | |Expressions.FlagModification (_, _, _, e1) -> 138 | aux e1 139 | |Expressions.BinaryOperation (_, _, e1, e2) 140 | |Expressions.FlagTest (_, _, _, e1, e2) -> 141 | List.append (aux e1) (aux e2) 142 | |Expressions.Composition (_, e1, e_lst) -> 143 | List.append (aux e1) (e_lst |> List.map aux |> List.flatten) 144 | |Expressions.Alias (info, alias) -> [(alias, info)] 145 | |Expressions.AliasDefinition (_, alias, e1, e2) -> 146 | List.append 147 | (aux e1) 148 | (aux e2 |> List.filter (fun (alias', _) -> alias' <> alias)) 149 | |_ -> Expressions.ValueError (e, "undefined_alias_errors") |> raise 150 | in 151 | aux e 152 | |> List.map (fun (alias, info) -> {kind = UndefinedAlias alias; information = info}) 153 | |> List.sort_uniq compare 154 | 155 | (* Returns the list of the errors about the invalid compositions w.r.t. the arity of the 156 | * left-hand members in the expression e. This expression has to be inclusion free and 157 | * alias free. *) 158 | let invalid_arity_composition_errors e = 159 | assert (Properties.is_inclusion_free e); 160 | assert (Properties.is_alias_free e); 161 | let rec aux e = 162 | match e with 163 | |Expressions.Beat _ -> [] 164 | |Expressions.CycleOperation (_, _, e1) 165 | |Expressions.FlagModification (_, _, _, e1) 166 | |Expressions.UnaryOperation (_, _, e1) -> 167 | aux e1 168 | |Expressions.BinaryOperation (_, _, e1, e2) 169 | |Expressions.FlagTest (_, _, _, e1, e2) -> 170 | List.append (aux e1) (aux e2) 171 | |Expressions.Composition (info, e1, e_lst) -> 172 | let n = Properties.greatest_beat_index e1 and n' = List.length e_lst in 173 | let tmp = List.append (aux e1) (e_lst |> List.map aux |> List.flatten) in 174 | if n <> n' then 175 | {kind = InvalidArityComposition (n, n'); information = info} :: tmp 176 | else 177 | tmp 178 | |_ -> Expressions.ValueError (e, "invalid_arity_composition_errors") |> raise 179 | in 180 | aux e |> List.sort_uniq compare 181 | 182 | -------------------------------------------------------------------------------- /Sources/Statistics.ml: -------------------------------------------------------------------------------- 1 | (* Author: Samuele Giraudo 2 | * Creation: may 2022 3 | * Modifications: may 2022, aug. 2022, nov. 2022, jul. 2023 4 | *) 5 | 6 | (* A type to collect some statistics about an expression. *) 7 | type statistics = { 8 | nb_beats: int; 9 | nb_update_cycle_numbers: int; 10 | nb_reset_cycle_numbers: int; 11 | nb_vertical_scalings: int; 12 | nb_horizontal_scalings: int; 13 | nb_concatenations: int; 14 | nb_additions: int; 15 | nb_multiplications: int; 16 | nb_flag_tests: int; 17 | nb_flag_modifications: int; 18 | nb_compositions: int; 19 | nb_aliases: int; 20 | nb_alias_definitions: int; 21 | nb_puts: int; 22 | height: int; 23 | greatest_beat_index: int 24 | } 25 | 26 | (* Returns a string representation of the statistics st. *) 27 | let to_string st = 28 | let string_if condition str = 29 | if condition then str else "" 30 | in 31 | string_if (st.nb_beats >= 1) (Printf.sprintf "Nb. beats: %d\n" st.nb_beats) 32 | ^ 33 | string_if (st.nb_update_cycle_numbers >= 1) 34 | (Printf.sprintf "Nb. cycle scalings: %d\n" st.nb_update_cycle_numbers) 35 | ^ 36 | string_if (st.nb_reset_cycle_numbers >= 1) 37 | (Printf.sprintf "Nb. cycle resettings: %d\n" st.nb_reset_cycle_numbers) 38 | ^ 39 | string_if (st.nb_vertical_scalings >= 1) 40 | (Printf.sprintf "Nb. vertical scalings: %d\n" st.nb_vertical_scalings) 41 | ^ 42 | string_if (st.nb_horizontal_scalings >= 1) 43 | (Printf.sprintf "Nb. horizontal scalings: %d\n" st.nb_horizontal_scalings) 44 | ^ 45 | string_if (st.nb_concatenations >= 1) 46 | (Printf.sprintf "Nb. concatenations: %d\n" st.nb_concatenations) 47 | ^ 48 | string_if (st.nb_additions >= 1) (Printf.sprintf "Nb. additions: %d\n" st.nb_additions) 49 | ^ 50 | string_if (st.nb_multiplications >= 1) 51 | (Printf.sprintf "Nb. multiplications: %d\n" st.nb_multiplications) 52 | ^ 53 | string_if (st.nb_flag_tests >= 1) 54 | (Printf.sprintf "Nb. flag tests: %d\n" st.nb_flag_tests) 55 | ^ 56 | string_if (st.nb_flag_modifications >= 1) 57 | (Printf.sprintf "Nb. flag modifications: %d\n" st.nb_flag_modifications) 58 | ^ 59 | string_if (st.nb_compositions >= 1) 60 | (Printf.sprintf "Nb. compositions: %d\n" st.nb_compositions) 61 | ^ 62 | string_if (st.nb_aliases >= 1) (Printf.sprintf "Nb. aliases.: %d\n" st.nb_aliases) 63 | ^ 64 | string_if (st.nb_alias_definitions >= 1) 65 | (Printf.sprintf "Nb. alias definitions: %d\n" st.nb_alias_definitions) 66 | ^ 67 | string_if (st.nb_puts >= 1) (Printf.sprintf "Nb. puts: %d\n" st.nb_puts) 68 | ^ 69 | Printf.sprintf "Height: %d\n" st.height 70 | ^ 71 | Printf.sprintf "Greatest beat index: %d\n" st.greatest_beat_index 72 | 73 | (* Returns the number of puts surveyed by the statistics st. *) 74 | let nb_puts st = 75 | st.nb_puts 76 | 77 | (* Returns the number of aliases surveyed by the statistics st. *) 78 | let nb_aliases st = 79 | st.nb_aliases 80 | 81 | (* Returns the number of alias definitions surveyed by the statistics st. *) 82 | let nb_alias_definitions st = 83 | st.nb_alias_definitions 84 | 85 | (* Returns the number of compositions surveyed by the statistics st. *) 86 | let nb_compositions st = 87 | st.nb_compositions 88 | 89 | (* Returns the number of flag tests surveyed by the statistics st. *) 90 | let nb_flag_tests st = 91 | st.nb_flag_tests 92 | 93 | (* Returns the number of flag modifications surveyed by the statistics st. *) 94 | let nb_flag_modifications st = 95 | st.nb_flag_modifications 96 | 97 | (* Returns the greatest beat surveyed by the statistics st. *) 98 | let greatest_beat_index st = 99 | st.greatest_beat_index 100 | 101 | (* Returns the empty statistics. *) 102 | let empty = 103 | {nb_beats = 0; 104 | nb_update_cycle_numbers = 0; 105 | nb_reset_cycle_numbers = 0; 106 | nb_vertical_scalings = 0; 107 | nb_horizontal_scalings = 0; 108 | nb_concatenations = 0; 109 | nb_additions = 0; 110 | nb_multiplications = 0; 111 | nb_flag_tests = 0; 112 | nb_flag_modifications = 0; 113 | nb_compositions = 0; 114 | nb_aliases = 0; 115 | nb_alias_definitions = 0; 116 | nb_puts = 0; 117 | height = 0; 118 | greatest_beat_index = 0} 119 | 120 | (* Returns the statistics obtained by merging the statistics st1 and st2. *) 121 | let merge st1 st2 = 122 | {nb_beats = st1.nb_beats + st2.nb_beats; 123 | nb_update_cycle_numbers = st1.nb_update_cycle_numbers + st2.nb_update_cycle_numbers; 124 | nb_reset_cycle_numbers = st1.nb_reset_cycle_numbers + st2.nb_reset_cycle_numbers; 125 | nb_vertical_scalings = st1.nb_vertical_scalings + st2.nb_vertical_scalings; 126 | nb_horizontal_scalings = st1.nb_horizontal_scalings + st2.nb_horizontal_scalings; 127 | nb_concatenations = st1.nb_concatenations + st2.nb_concatenations; 128 | nb_additions = st1.nb_additions + st2.nb_additions; 129 | nb_multiplications = st1.nb_multiplications + st2.nb_multiplications; 130 | nb_flag_tests = st1.nb_flag_tests + st2.nb_flag_tests; 131 | nb_flag_modifications = st1.nb_flag_modifications + st2.nb_flag_modifications; 132 | nb_compositions = st1.nb_compositions + st2.nb_compositions; 133 | nb_aliases = st1.nb_aliases + st2.nb_aliases; 134 | nb_alias_definitions = st1.nb_alias_definitions + st2.nb_alias_definitions; 135 | nb_puts = st1.nb_puts + st2.nb_puts; 136 | height = max st1.height st2.height; 137 | greatest_beat_index = max st1.greatest_beat_index st2.greatest_beat_index} 138 | 139 | (* Returns the statistics collected from the expression e. *) 140 | let rec compute e = 141 | match e with 142 | |Expressions.Beat (_, b) -> 143 | {empty with nb_beats = 1; greatest_beat_index = Beats.index b} 144 | |Expressions.CycleOperation (_, Expressions.UpdateCycleNumber _, e1) -> 145 | let st1 = compute e1 in 146 | {st1 with 147 | nb_update_cycle_numbers = 1 + st1.nb_update_cycle_numbers; 148 | height = 1 + st1.height} 149 | |Expressions.CycleOperation (_, Expressions.ResetCycleNumber, e1) -> 150 | let st1 = compute e1 in 151 | {st1 with 152 | nb_reset_cycle_numbers = 1 + st1.nb_reset_cycle_numbers; 153 | height = 1 + st1.height} 154 | |Expressions.UnaryOperation (_, Expressions.VerticalScaling _, e1) -> 155 | let st1 = compute e1 in 156 | {st1 with 157 | nb_vertical_scalings = 1 + st1.nb_vertical_scalings; 158 | height = 1 + st1.height} 159 | |Expressions.UnaryOperation (_, Expressions.HorizontalScaling _, e1) -> 160 | let st1 = compute e1 in 161 | {st1 with 162 | nb_horizontal_scalings = 1 + st1.nb_horizontal_scalings; 163 | height = 1 + st1.height} 164 | |Expressions.BinaryOperation (_, Expressions.Concatenation, e1, e2) -> 165 | let st1 = compute e1 and st2 = compute e2 in 166 | let st = merge st1 st2 in 167 | {st with 168 | nb_concatenations = 1 + st.nb_concatenations; 169 | height = 1 + st.height} 170 | |Expressions.BinaryOperation (_, Expressions.Addition, e1, e2) -> 171 | let st1 = compute e1 and st2 = compute e2 in 172 | let st = merge st1 st2 in 173 | {st with 174 | nb_additions = 1 + st.nb_additions; 175 | height = 1 + st.height} 176 | |Expressions.BinaryOperation (_, Expressions.Multiplication, e1, e2) -> 177 | let st1 = compute e1 and st2 = compute e2 in 178 | let st = merge st1 st2 in 179 | {st with 180 | nb_multiplications = 1 + st.nb_multiplications; 181 | height = 1 + st.height} 182 | |Expressions.FlagTest (_, _, _, e1, e2) -> 183 | let st1 = compute e1 and st2 = compute e2 in 184 | let st = merge st1 st2 in 185 | {st with 186 | nb_flag_tests = 1 + st.nb_flag_tests; 187 | height = 1 + st.height} 188 | |Expressions.FlagModification (_, _, _, e1) -> 189 | let st1 = compute e1 in 190 | {st1 with 191 | nb_flag_modifications = 1 + st1.nb_flag_modifications; 192 | height = 1 + st1.height} 193 | |Expressions.Alias _ -> {empty with nb_aliases = 1} 194 | |Expressions.AliasDefinition (_, _, e1, e2) -> 195 | let st1 = compute e1 and st2 = compute e2 in 196 | let st = merge st1 st2 in 197 | {st with 198 | nb_alias_definitions = 1 + st.nb_alias_definitions; 199 | height = 1 + st.height} 200 | |Expressions.Composition (_, e1, e_lst) -> 201 | let st1 = compute e1 and st_lst = e_lst |> List.map compute in 202 | let st = st_lst |> List.fold_left merge st1 in 203 | {st with 204 | nb_compositions = 1 + st.nb_compositions; 205 | height = 1 + st.height} 206 | |Expressions.Put _ -> {empty with nb_puts = 1} 207 | 208 | --------------------------------------------------------------------------------