From 20328b348398055e95b3046123104340d2b006d0 Mon Sep 17 00:00:00 2001 From: VLAD EMINOVICI Date: Sun, 17 Mar 2024 22:44:35 +0200 Subject: [PATCH] Split the exerices --- README.md | 54 ++++++++++++------------ examples/exercise1.rs | 10 +++++ examples/exercise2.rs | 16 ++++++++ examples/exercise3.rs | 50 +++++++++++++++++++++++ examples/exercise4.rs | 15 +++++++ examples/exercises.rs | 95 ------------------------------------------- 6 files changed, 118 insertions(+), 122 deletions(-) create mode 100644 examples/exercise1.rs create mode 100644 examples/exercise2.rs create mode 100644 examples/exercise3.rs create mode 100644 examples/exercise4.rs delete mode 100644 examples/exercises.rs diff --git a/README.md b/README.md index f3e459b..cf4b208 100644 --- a/README.md +++ b/README.md @@ -44,38 +44,34 @@ The create allows you to build the following chords: You can find all the chords in the [chords][chords_folder] folder. -## Piano Exercises -You can find all piano exercises implemented in the [practices][practices_file] file. You can see the practices by running: -```bsh -cargo run --example practices -``` - -### Exercise 1 (| C - Am | F - G |) ```rust -use musika_rs::*; +use musika_rs::* + +let cmaj = C.major(); +println!("{:X}", cmaj); + +let amin = A.minor(); +println!("{:X}", amin); + +let cmaj7 = C.major7(); +println!("{:X}", cmaj7); -println!("Exercise 1: (| C - Am | F - G |)"); -println!("{:X}", C.major()); // C [C, E, G] -println!("{:X}", A.minor()); // Am [A, C, E] -println!("{:X}", F.major()); // F [F, A, C] -println!("{:X}", G.major()); // G [G, B, D] ``` -### Exercise 2 (| C - G | Am - F | C - G | F - Em - Dm - C |) -```rust -println!("Exercise 2: (| C - G | Am - F | C - G | F - Em - Dm - C |)"); -println!("{:X}", C.major()); // C [C, E, G] -println!("{:X}", G.major()); // G [G, B, D] -println!("{:X}", A.minor()); // Am [A, C, E] -println!("{:X}", F.major()); // F [F, A, C] -println!("{:X}", C.major()); // C [C, E, G] -println!("{:X}", G.major()); // G [G, B, D] -println!("{:X}", F.major()); // F [F, A, C] -println!("{:X}", E.minor()); // Em [E, G, B] -println!("{:X}", D.minor()); // Dm [D, F, A] -println!("{:X}", C.major()); // C [C, E, G] +## Piano Exercises +You can find all piano exercises implemented in the exercises examples. You can see the practices by running: +```bsh +cargo run --example exercise1 +cargo run --example exercise2 +cargo run --example exercise3 +cargo run --example exercise4 ``` +- [Exercise 1][exercise1_file] | C - Am | F - G | +- [Exercise 2][exercise2_file] | C - G | Am - F | C - G | F - Em - Dm - C | +- [Exercise 3][exercise3_file] | Cx4 | Gx4 | Gx4 | Cx4 | Fx4 | Cx4 | Gx4 | Cx4 | +- [Exercise 4][exercise4_file] | C | F | Bdim | Em | Am | Dm | G | C | + ## Resources - [Piano Chords][piano_chords_url] @@ -102,4 +98,8 @@ println!("{:X}", C.major()); // C [C, E, G] [minor7b5_chord_url]: https://www.pianochord.org/cm7b5.html [dim_chord_url]: https://www.pianochord.org/c-dim.html [dim7_chord_url]: https://www.pianochord.org/c-dim7.html -[dom7_chord_url]: https://www.pianochord.org/c7.html \ No newline at end of file +[dom7_chord_url]: https://www.pianochord.org/c7.html +[exercise1_file]: ./examples/exercise1.rs +[exercise2_file]: ./examples/exercise2.rs +[exercise3_file]: ./examples/exercise3.rs +[exercise4_file]: ./examples/exercise4.rs \ No newline at end of file diff --git a/examples/exercise1.rs b/examples/exercise1.rs new file mode 100644 index 0000000..2a4ae45 --- /dev/null +++ b/examples/exercise1.rs @@ -0,0 +1,10 @@ +use musika_rs::*; + +fn main() { + println!(); + println!("Exercise 1: | C - Am | F - G |"); + println!("{:X}", C.major()); // C [C, E, G] + println!("{:X}", A.minor()); // Am [A, C, E] + println!("{:X}", F.major()); // F [F, A, C] + println!("{:X}", G.major()); // G [G, B, D] +} diff --git a/examples/exercise2.rs b/examples/exercise2.rs new file mode 100644 index 0000000..f044125 --- /dev/null +++ b/examples/exercise2.rs @@ -0,0 +1,16 @@ +use musika_rs::*; + +fn main() { + println!(); + println!("Exercise 2: | C - G | Am - F | C - G | F - Em - Dm - C |"); + println!("{:X}", C.major()); // C [C, E, G] + println!("{:X}", G.major()); // G [G, B, D] + println!("{:X}", A.minor()); // Am [A, C, E] + println!("{:X}", F.major()); // F [F, A, C] + println!("{:X}", C.major()); // C [C, E, G] + println!("{:X}", G.major()); // G [G, B, D] + println!("{:X}", F.major()); // F [F, A, C] + println!("{:X}", E.minor()); // Em [E, G, B] + println!("{:X}", D.minor()); // Dm [D, F, A] + println!("{:X}", C.major()); // C [C, E, G] +} diff --git a/examples/exercise3.rs b/examples/exercise3.rs new file mode 100644 index 0000000..d3c322f --- /dev/null +++ b/examples/exercise3.rs @@ -0,0 +1,50 @@ +use musika_rs::*; + +fn main() { + println!(); + println!("Exercise 3: | Cx4 | Gx4 | Gx4 | Cx4 | Fx4 | Cx4 | Gx4 | Cx4 |"); + + let cmaj = C.major(); + let gmaj = G.major(); + let fmaj = F.major(); + + // bar 1 + for _ in 0..4 { + println!("{:X}", cmaj); // C [C, E, G] + } + + // bar 2 + for _ in 0..4 { + println!("{:X}", gmaj); // C [C, E, G] + } + + // bar 3 + for _ in 0..4 { + println!("{:X}", gmaj); // C [C, E, G] + } + + // bar 4 + for _ in 0..4 { + println!("{:X}", cmaj); // C [C, E, G] + } + + // bar 5 + for _ in 0..4 { + println!("{:X}", fmaj); // C [C, E, G] + } + + // bar 6 + for _ in 0..4 { + println!("{:X}", cmaj); // C [C, E, G] + } + + // bar 7 + for _ in 0..4 { + println!("{:X}", gmaj); // C [C, E, G] + } + + // bar 8 + for _ in 0..4 { + println!("{:X}", cmaj); // C [C, E, G] + } +} diff --git a/examples/exercise4.rs b/examples/exercise4.rs new file mode 100644 index 0000000..dcadb9c --- /dev/null +++ b/examples/exercise4.rs @@ -0,0 +1,15 @@ +use musika_rs::*; + +fn main() { + println!(); + println!("Exercise 4: | C | F | Bdim | Em | Am | Dm | G | C |"); + + println!("{:X}", C.major()); + println!("{:X}", F.major()); + println!("{:X}", B.diminished()); + println!("{:X}", E.minor()); + println!("{:X}", A.minor()); + println!("{:X}", D.minor()); + println!("{:X}", G.major()); + println!("{:X}", C.major()); +} diff --git a/examples/exercises.rs b/examples/exercises.rs deleted file mode 100644 index 7ece763..0000000 --- a/examples/exercises.rs +++ /dev/null @@ -1,95 +0,0 @@ -use musika_rs::*; - -fn exercise1() { - println!(); - println!("Exercise 1: | C - Am | F - G |"); - println!("{:X}", C.major()); // C [C, E, G] - println!("{:X}", A.minor()); // Am [A, C, E] - println!("{:X}", F.major()); // F [F, A, C] - println!("{:X}", G.major()); // G [G, B, D] -} - -fn exercise2() { - println!(); - println!("Exercise 2: | C - G | Am - F | C - G | F - Em - Dm - C |"); - println!("{:X}", C.major()); // C [C, E, G] - println!("{:X}", G.major()); // G [G, B, D] - println!("{:X}", A.minor()); // Am [A, C, E] - println!("{:X}", F.major()); // F [F, A, C] - println!("{:X}", C.major()); // C [C, E, G] - println!("{:X}", G.major()); // G [G, B, D] - println!("{:X}", F.major()); // F [F, A, C] - println!("{:X}", E.minor()); // Em [E, G, B] - println!("{:X}", D.minor()); // Dm [D, F, A] - println!("{:X}", C.major()); // C [C, E, G] -} - -fn exercise3() { - println!(); - println!("Exercise 3: | Cx4 | Gx4 | Gx4 | Cx4 | Fx4 | Cx4 | Gx4 | Cx4 |"); - - let cmaj = C.major(); - let gmaj = G.major(); - let fmaj = F.major(); - - // bar 1 - for _ in 0..4 { - println!("{:X}", cmaj); // C [C, E, G] - } - - // bar 2 - for _ in 0..4 { - println!("{:X}", gmaj); // C [C, E, G] - } - - // bar 3 - for _ in 0..4 { - println!("{:X}", gmaj); // C [C, E, G] - } - - // bar 4 - for _ in 0..4 { - println!("{:X}", cmaj); // C [C, E, G] - } - - // bar 5 - for _ in 0..4 { - println!("{:X}", fmaj); // C [C, E, G] - } - - // bar 6 - for _ in 0..4 { - println!("{:X}", cmaj); // C [C, E, G] - } - - // bar 7 - for _ in 0..4 { - println!("{:X}", gmaj); // C [C, E, G] - } - - // bar 8 - for _ in 0..4 { - println!("{:X}", cmaj); // C [C, E, G] - } -} - -fn exercise4() { - println!(); - println!("Exercise 4: | C | F | Bdim | Em | Am | Dm | G | C |"); - - println!("{:X}", C.major()); - println!("{:X}", F.major()); - println!("{:X}", B.diminished()); - println!("{:X}", E.minor()); - println!("{:X}", A.minor()); - println!("{:X}", D.minor()); - println!("{:X}", G.major()); - println!("{:X}", C.major()); -} - -fn main() { - exercise1(); - exercise2(); - exercise3(); - exercise4(); -}