Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,35 @@ This notice file contains more details, as well as document the organization of
- **COPYING** contains a copy of the full [AGPL-3.0 license](https://www.gnu.org/licenses/agpl-3.0.txt)

- **NOTICE.md** (this file) documents the project licensing.

## A note about some functions from Base

We copied some implementation of functions from [Base](https://github.com/janestreet/base) project. `Base` is released under `MIT`.

### Notice

The files where we imported the functions is `src/stdlib/fingerboard_stdlib.ml`. We've added a notice in the file and a comment next to the code that was copied and modified, which includes `Base`'s original LICENSE:

```text
The MIT License

Copyright (c) 2016--2024 Jane Street Group, LLC <opensource-contacts@janestreet.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
106 changes: 28 additions & 78 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -23,69 +23,29 @@
(depends
(ocaml
(>= 5.2))
(base
(>= v0.17))
(bitv
(>= 2.1))
(dyn
(>= 3.20))
(ordering
(>= 3.20))
(patdiff
(>= v0.17))
(pp
(>= 2.0.0))
(ppx_compare
(>= v0.17))
(ppx_enumerate
(>= v0.17))
(ppx_hash
(>= v0.17))
(ppx_here
(>= v0.17))
(ppx_let
(>= v0.17))
(ppx_sexp_conv
(>= v0.17))
(ppx_sexp_value
(>= v0.17))
(ppxlib
(>= 0.33))
(print-table
(>= 0.1.0))
(sexplib0
(>= v0.17))))
(>= 0.1.0))))

(package
(name fingerboard-system)
(synopsis "Package for Fingerboard systems")
(depends
(ocaml
(>= 5.2))
(base
(>= v0.17))
(crs
(>= 0.0.20250705))
(expect_test_helpers_core
(>= v0.17))
(fingerboard
(= :version))
(patdiff
(>= v0.17))
(ppx_compare
(>= v0.17))
(ppx_enumerate
(>= v0.17))
(ppx_expect
(>= v0.17))
(ppx_hash
(>= v0.17))
(ppx_here
(>= v0.17))
(ppx_let
(>= v0.17))
(ppx_sexp_conv
(>= v0.17))
(ppx_sexp_value
(>= v0.17))
(ppxlib
(>= 0.33))
(print-table
Expand All @@ -97,51 +57,41 @@
(depends
(ocaml
(>= 5.2))
(ocamlformat
(and
:with-dev-setup
(= 0.28.1)))
(base
(>= v0.17))
(bisect_ppx
(and
:with-dev-setup
(>= 2.8.3)))
(crs
(>= 0.0.20250705))
(expect_test_helpers_core
(>= v0.17))
(fingerboard
(= :version))
(fingerboard-system
(= :version))
(patdiff
(>= v0.17))
(ppx_compare
(>= v0.17))
(ppx_enumerate
(>= v0.17))
(ppx_expect
(>= v0.17))
(ppx_hash
(>= v0.17))
(ppx_here
(>= v0.17))
(ppxlib
(>= 0.33))
(print-table
(>= 0.1.0))))

(package
(name fingerboard-dev)
(synopsis "Package to regroup dev targets, documentation, and more")
(allow_empty)
(depends
(ocaml
(>= 5.2))
(ocamlformat
(= 0.28.1))
(bisect_ppx
(>= 2.8.3))
(crs
(>= 0.0.20250705))
(fingerboard
(= :version))
(fingerboard-system
(= :version))
(fingerboard-tests
(= :version))
(ppx_js_style
(and
:with-dev-setup
(>= v0.17)))
(ppx_let
(>= v0.17))
(ppx_sexp_conv
(>= v0.17))
(ppx_sexp_value
(>= v0.17))
(ppxlib
(>= 0.33))
(print-table
(>= 0.1.0))
(sherlodoc
(and
:with-doc
(>= 0.2)))))
(>= 0.2))))
39 changes: 39 additions & 0 deletions fingerboard-dev.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Package to regroup dev targets, documentation, and more"
maintainer: ["Mathieu Barbin <opensource@mbarbin.org>"]
authors: ["Mathieu Barbin"]
license: "AGPL-3.0-or-later"
homepage: "https://github.com/mbarbin/fingerboard"
doc: "https://mbarbin.github.io/fingerboard/"
bug-reports: "https://github.com/mbarbin/fingerboard/issues"
depends: [
"dune" {>= "3.20"}
"ocaml" {>= "5.2"}
"ocamlformat" {= "0.28.1"}
"bisect_ppx" {>= "2.8.3"}
"crs" {>= "0.0.20250705"}
"fingerboard" {= version}
"fingerboard-system" {= version}
"fingerboard-tests" {= version}
"ppx_js_style" {>= "v0.17"}
"ppxlib" {>= "0.33"}
"sherlodoc" {>= "0.2"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mbarbin/fingerboard.git"
x-maintenance-intent: ["(latest)"]
10 changes: 0 additions & 10 deletions fingerboard-system.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,9 @@ bug-reports: "https://github.com/mbarbin/fingerboard/issues"
depends: [
"dune" {>= "3.20"}
"ocaml" {>= "5.2"}
"base" {>= "v0.17"}
"crs" {>= "0.0.20250705"}
"expect_test_helpers_core" {>= "v0.17"}
"fingerboard" {= version}
"patdiff" {>= "v0.17"}
"ppx_compare" {>= "v0.17"}
"ppx_enumerate" {>= "v0.17"}
"ppx_expect" {>= "v0.17"}
"ppx_hash" {>= "v0.17"}
"ppx_here" {>= "v0.17"}
"ppx_let" {>= "v0.17"}
"ppx_sexp_conv" {>= "v0.17"}
"ppx_sexp_value" {>= "v0.17"}
"ppxlib" {>= "0.33"}
"print-table" {>= "0.1.0"}
"odoc" {with-doc}
Expand Down
14 changes: 0 additions & 14 deletions fingerboard-tests.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,12 @@ bug-reports: "https://github.com/mbarbin/fingerboard/issues"
depends: [
"dune" {>= "3.20"}
"ocaml" {>= "5.2"}
"ocamlformat" {with-dev-setup & = "0.28.1"}
"base" {>= "v0.17"}
"bisect_ppx" {with-dev-setup & >= "2.8.3"}
"crs" {>= "0.0.20250705"}
"expect_test_helpers_core" {>= "v0.17"}
"fingerboard" {= version}
"fingerboard-system" {= version}
"patdiff" {>= "v0.17"}
"ppx_compare" {>= "v0.17"}
"ppx_enumerate" {>= "v0.17"}
"ppx_expect" {>= "v0.17"}
"ppx_hash" {>= "v0.17"}
"ppx_here" {>= "v0.17"}
"ppx_js_style" {with-dev-setup & >= "v0.17"}
"ppx_let" {>= "v0.17"}
"ppx_sexp_conv" {>= "v0.17"}
"ppx_sexp_value" {>= "v0.17"}
"ppxlib" {>= "0.33"}
"print-table" {>= "0.1.0"}
"sherlodoc" {with-doc & >= "0.2"}
"odoc" {with-doc}
]
build: [
Expand Down
12 changes: 1 addition & 11 deletions fingerboard.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ bug-reports: "https://github.com/mbarbin/fingerboard/issues"
depends: [
"dune" {>= "3.20"}
"ocaml" {>= "5.2"}
"base" {>= "v0.17"}
"bitv" {>= "2.1"}
"dyn" {>= "3.20"}
"ordering" {>= "3.20"}
"patdiff" {>= "v0.17"}
"pp" {>= "2.0.0"}
"ppx_compare" {>= "v0.17"}
"ppx_enumerate" {>= "v0.17"}
"ppx_hash" {>= "v0.17"}
"ppx_here" {>= "v0.17"}
"ppx_let" {>= "v0.17"}
"ppx_sexp_conv" {>= "v0.17"}
"ppx_sexp_value" {>= "v0.17"}
"ppxlib" {>= "0.33"}
"print-table" {>= "0.1.0"}
"sexplib0" {>= "v0.17"}
"odoc" {with-doc}
]
build: [
Expand Down
49 changes: 22 additions & 27 deletions src/acoustic_interval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ let to_cents = function
| Cents x -> x
;;

let hash t = Float.hash (to_cents t)
let hash_fold_t state t = Float.hash_fold_t state (to_cents t)
let of_cents x = Cents x

let aux_reduced_natural_ratio_of_octaves ~number_of_octaves =
Expand Down Expand Up @@ -115,26 +113,25 @@ let rec remove t1 t2 =
, Equal_division_of_the_octave { divisor = d2; number_of_divisions = p2 } )
when d1 = d2 ->
let p = p1 - p2 in
(match Int.compare p 0 |> Ordering.of_int with
| Less -> None
| Equal -> Some Zero
| Greater ->
Some (Equal_division_of_the_octave { divisor = d1; number_of_divisions = p }))
(match Int.compare p 0 with
| Lt -> None
| Eq -> Some Zero
| Gt -> Some (Equal_division_of_the_octave { divisor = d1; number_of_divisions = p }))
| Octaves { number_of_octaves = n1 }, Octaves { number_of_octaves = n2 } ->
let n = n1 - n2 in
(match Int.compare n 0 |> Ordering.of_int with
| Less -> None
| Equal -> Some Zero
| Greater -> Some (Octaves { number_of_octaves = n }))
(match Int.compare n 0 with
| Lt -> None
| Eq -> Some Zero
| Gt -> Some (Octaves { number_of_octaves = n }))
| Reduced_natural_ratio r1, Reduced_natural_ratio r2 ->
let r = Natural_ratio.Reduced.divide r1 r2 in
let { Natural_ratio.numerator; denominator } =
Natural_ratio.Reduced.to_natural_ratio r
in
(match Int.compare numerator denominator |> Ordering.of_int with
| Less -> None
| Equal -> Some Zero
| Greater -> Some (Reduced_natural_ratio r))
(match Int.compare numerator denominator with
| Lt -> None
| Eq -> Some Zero
| Gt -> Some (Reduced_natural_ratio r))
| Octaves { number_of_octaves }, (Reduced_natural_ratio _ as t2) ->
remove (reduced_natural_ratio_of_octaves ~number_of_octaves) t2
| (Reduced_natural_ratio _ as t1), Octaves { number_of_octaves } ->
Expand All @@ -147,10 +144,10 @@ let rec remove t1 t2 =
remove t1 (equal_division_of_the_octave_of_octaves ~divisor ~number_of_octaves)
| _ ->
let cents = to_cents t1 -. to_cents t2 in
(match Float.compare cents 0. |> Ordering.of_int with
| Less -> None
| Equal -> Some Zero
| Greater -> Some (Cents cents))
(match Float.compare cents 0. with
| Lt -> None
| Eq -> Some Zero
| Gt -> Some (Cents cents))
;;

let rec equal t1 t2 =
Expand Down Expand Up @@ -234,12 +231,12 @@ let pythagorean (interval : Interval.t) =
let chromatic = chromatic + chromatic_shift in
chromatic, diatonic
in
[ List.init interval.additional_octaves ~f:(Fn.const octave)
[ List.init interval.additional_octaves ~f:(Fun.const octave)
; List.init
(min chromatic diatonic)
~f:(Fn.const (Reduced_natural_ratio pythagorean_ton))
; List.init (max 0 (chromatic - diatonic)) ~f:(Fn.const pythagorean_chromatic_semiton)
; List.init (max 0 (diatonic - chromatic)) ~f:(Fn.const pythagorean_diatonic_semiton)
~f:(Fun.const (Reduced_natural_ratio pythagorean_ton))
; List.init (max 0 (chromatic - diatonic)) ~f:(Fun.const pythagorean_chromatic_semiton)
; List.init (max 0 (diatonic - chromatic)) ~f:(Fun.const pythagorean_diatonic_semiton)
]
|> List.concat
|> compound
Expand Down Expand Up @@ -268,8 +265,7 @@ let just_major_sixth = 5 // 3

let shift_up t frequency =
let of_cents cents =
Frequency.to_float frequency *. Stdlib.Float.exp2 (cents /. 1200.)
|> Frequency.of_float_exn
Frequency.to_float frequency *. Float.exp2 (cents /. 1200.) |> Frequency.of_float_exn
in
let of_natural_ratio { Natural_ratio.numerator; denominator } =
Frequency.to_float frequency *. Float.of_int numerator /. Float.of_int denominator
Expand All @@ -287,8 +283,7 @@ let shift_up t frequency =

let shift_down t frequency =
let of_cents cents =
Frequency.to_float frequency /. Stdlib.Float.exp2 (cents /. 1200.)
|> Frequency.of_float_exn
Frequency.to_float frequency /. Float.exp2 (cents /. 1200.) |> Frequency.of_float_exn
in
let of_natural_ratio { Natural_ratio.numerator; denominator } =
Frequency.to_float frequency *. Float.of_int denominator /. Float.of_int numerator
Expand Down
Loading