07-15-2023, 01:38 AM
(This post was last modified: 07-15-2023, 04:35 AM by PhilOfPerth.)
(07-15-2023, 12:17 AM)grymmjack Wrote: @PhilOfPerth This is a great example. One thing to consider possibly, is to let us press a key to advance, or a menu to choose different subjects
That way you could quickly use it as a reference too!
Anyway, this is really good stuff. I learned some new things!
<3
Thanks grymmjack. Yes, both good ideas. I've implemented both here:
Code: (Select All)
Screen _NewImage(1200, 820, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 24, "monospace")
_Font f&
Start:
Color _RGB(255, 255, 0)
Print Tab(30); "The Sounds of Music"; Tab(28); "(as implemented in QB64PE)"
Print: Color _RGB(255, 255, 255)
Print " The several topics in this series can be reached individually from the Menu, or"
Print " the whole series may be played from start to finish."
Color _RGB(255, 255, 0): Print: Print Tab(40); "Menu": Color _RGB(255, 255, 255)
Print Tab(30); "A All topics"; Tab(30); "B Tones"; Tab(30); "C Semitones"; Tab(30); "D Tones (method 2)"; Tab(30); "E Silence"; Tab(30); "F Note Length (multiple notes)"
Print Tab(30); "G Note Length (single notes)"
Print Tab(30); "H Dotted Notes"; Tab(30); "I Mood"; Tab(30); "J Tempo (speed)"; Tab(30); "K Volume"; Tab(30); "L Polyphonics"
Print Tab(30); "M Background"; Tab(30); "N Accent"; Tab(30); "X Exit Programme"
Print: Color _RGB(255, 255, 0): Print Tab(31); "Choose a topic (A to N)"
GetAKey:
k$ = UCase$(InKey$)
If k$ < "A" Or k$ > "X" Then GoTo GetAKey
Cls
Select Case k$
Case "A" To "B"
GoTo Tones
Case "C"
GoTo Semitones
Case "D"
GoTo Tones2
Case "E"
GoTo Silence
Case "F"
GoTo Notelength
Case "G"
GoTo Notelength2
Case "H"
GoTo Notelength3
Case "I"
GoTo Mood
Case "J"
GoTo Speed
Case "K"
GoTo Volume
Case "L"
GoTo Polyphonics
Case "M"
GoTo BackgroundSound
Case "N"
GoTo Accent
Case "X"
System
Case Else
Beep: GoTo GetAKey
End Select
GoTo GetAKey
Tones:
Color _RGB(255, 255, 0): Print " Tones:"
Color _RGB(255, 255, 255): Print
Print " The notes span seven octaves, from C in octave 0 to B# in octave 6, including"
Print " the semitones. Select the octave with ";: Color _RGB(255, 255, 0): Print "On";: Color _RGB(255, 255, 255)
Print " (n ";: Color _RGB(255, 255, 255): Print "can be from 0 to 6, default 3),"
Print " and the note from ";: Color _RGB(255, 255, 0): Print "A ";: Color _RGB(255, 255, 255): Print "to ";: Color _RGB(255, 255, 0): Print "G";
Color _RGB(255, 255, 255): Print ". Use ";: Color _RGB(255, 255, 0): Print "+ ";: Color _RGB(255, 255, 255): Print "or ";: Color _RGB(255, 255, 0)
Print "# ";: Color _RGB(255, 255, 255): Print "for sharps,";: Color _RGB(255, 255, 0): Print " -";: Color _RGB(255, 255, 255): Print " for flats."
Print: Print " Example (2 octaves): ";: Color _RGB(255, 255, 0): Print "L8 O2 CDEFGAB O3 CDEFGAB O4 C";: Color _RGB(255, 255, 255)
Sleep 1: Play "L8 O2 CDEFGAB O3 CDEFGAB O4 C"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print: Print Tab(26); "Press a key for next topic":
Sleep: Cls: Print
Semitones:
Color _RGB(255, 255, 0): Print " Semitones:"
Color _RGB(255, 255, 255): Print
Print " Each octave has 12 semitones: ";: Color _RGB(255, 255, 0): Print " C C# D D# E F F# G G# A A# B": Color _RGB(255, 255, 255)
Print " (that's called a chomatic scale). Select notes by their letter, followed by sharp or flat if needed"
Print " (spaces and case are both ignored)."
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L8 O3 C C# D D# E F F# G G# A A# B O4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L8 O3 C C# D D# E F F# G G# A A# B o4 C"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Tones2:
Color _RGB(255, 255, 0): Print " Tones (method 2):"
Color _RGB(255, 255, 255): Print
Print " Any of the 85 individual semitones (from 0 to 84) can also be selected with ";: Color _RGB(255, 255, 0): Print "Nn ": Color _RGB(255, 255, 255)
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L8 N32 N33 N34 N35 N36 N37 N38 N39 N40";: Color _RGB(255, 255, 255)
Sleep 1: Play "L8 N32 N33 N34 N35 N36 N37 N38 N39 N40 N41 N42 N43 N44 N45 N46 N47 N48"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Silence:
Color _RGB(255, 255, 0): Print " Silence:"
Color _RGB(255, 255, 255): Print
Print " Pauses, or rests (silence) can be from 1 to 64 quarter-notes in length"
Print " Example: (this is the same string, with pauses inserted:"
Print: Color _RGB(255, 255, 0): Print " O3 C C# D P4 D# E F P4 F# G G# P4 A A# B O4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "O3 C C# D P4 D# E F P4 F# G G# P4 A A# B O4 C"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Notelength:
Color _RGB(255, 255, 0): Print " Note Length (multiple notes):"
Color _RGB(255, 255, 255): Print
Print " Length (in fractions of a note) can be 1 to 64 (eg L16 is 1/16 note in length)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "o3 L2EEE L4 EEE L8 EEE P2 L2 EEE L4 EEE L8 EEE";: Color _RGB(255, 255, 255)
Sleep 1: Play " O3 L2EEE L4 EEE L8 EEE P2 L2 EEE L4 EEE L8 EEE"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Notelength2:
Color _RGB(255, 255, 0): Print " Note Length (single notes):"
Color _RGB(255, 255, 255): Print
Sleep 1: Print " An alternative way of changing a note length is by appending"
Print " a number to the note, rather than using Ln."
Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 CC8CC P2 C8CCC P2 CC8CC": Color _RGB(255, 255, 255): Print
Print " The difference is that the appended version only applies to the previous note, then"
Print " dies, while the Ln version persists until over-written by another Ln."
Sleep 2: Play "L4 CC8CC P2 C8CCC P2 CC8CC"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Notelength3:
Color _RGB(255, 255, 0): Print " Note Length (dotted notes):"
Color _RGB(255, 255, 255): Print
Print " Duration can also be Modified for individual notes by adding one or two ";: Color _RGB(255, 255, 0): Print ". (periods)";: Color _RGB(255, 255, 255): Print " to the note."
Print " A single period extends its length to 1 1/2 times, while a double period extends it"
Print " to 1 3/4 times its length."
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "C P1 C. P1 C.. P2 C P1 C. P1 C.. P2 C P1 C. P1 C..";: Color _RGB(255, 255, 255)
Sleep 1: Play "C P1 C. P1 C.. P2 C P1 C. P1 C.. P2 C P1 C. P1 C.."
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Mood:
Color _RGB(255, 255, 0): Print " Mood:"
Color _RGB(255, 255, 255): Print
Print " The mood of music can be Modified for groups or for individual notes:"
Color _RGB(255, 255, 0): Print " MS = Staccato (3/4 length), MN = normal (7/8 length), ML = Legato (1.5 times length)":: Color _RGB(255, 255, 255)
Print " Aide de memoir: S for Short, N for Normal, L for Long)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L4 MS CCCC P4 MN CCCC P4 ML CCCC P1 MS CCCC P4 MN CCCC P4 ML CCCC";: Color _RGB(255, 255, 255)
Sleep 1: Play "L4 MS CCCC P4 MN CCCC P4 ML CCCC P1 MS CCCC P4 MN CCCC P4 ML CCCC"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Speed:
Color _RGB(255, 255, 0): Print " Speed (Tempo):"
Color _RGB(255, 255, 255): Print
Print " Tempo, or speed can be from 32 to 255 quarter-notes per minute"
Print " (Default is 120 - standard military march tempo)"
Print " Use ";: Color _RGB(255, 255, 0): Print "Tn";: Color _RGB(255, 255, 255): Print " (where n is from 32 to 255)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "O3 T90 CDEFGAB O4C T120 CDEFGAB O3C T240 CDEFGAB O4C": Color _RGB(255, 255, 255)
Sleep 1: Play "O3 T90 CDEFGAB O4C T120 O3 CDEFGAB O4C T240 O3 CDEFGAB O4C"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Volume:
Color _RGB(255, 255, 0): Print " Volume:"
Color _RGB(255, 255, 255): Print
Print " Volume is specified with ";: Color _RGB(255, 255, 0): Print " Vn";: Color _RGB(255, 255, 255): Print ", where n can be be 0 to 100)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 V100 C P16 V75 C P16 V50 C P16 V25 C V100 C P16 V75 C P16 V50 C P16 V25 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L2 V100 C P16 V75 C P16 V50 C P16 V25 C V100 C P16 V75 C P16 V50 C P16 V25 C"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Polyphonics:
Color _RGB(255, 255, 0): Print " Polyphonics:"
Color _RGB(255, 255, 255): Print
Print " Polyphonics (multiple notes simultaneously) is provided with commas between notes"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L1 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L1 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C"
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
BackgroundSound:
Color _RGB(255, 255, 0): Print " Background Sound:"
Color _RGB(255, 255, 255): Print
Print " A programme can either continue executing, or pause while music is played."
Color _RGB(255, 255, 0): Print " MF (Music Foreground) pauses programme, MB allows programme to continue.": Color _RGB(255, 255, 255)
Print: Print " Example:": Sleep 1
Play "MF L2 O3 CDEFGAB O4 C"
For a = 1 To 4: Print " Music has finished!": _Delay .2: Next
Sleep 1: Play "MB L2 O3 CDEFGAB O4 C"
For a = 1 To 4: Print " Music is playing!";: _Delay .2: Next
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key for next topic": Sleep: Cls: Print
Timbre:
Color _RGB(255, 255, 0): Print " Timbre (richness):"
Color _RGB(255, 255, 255): Print
Print " The timbre, or texture of notes can be changed by changing their waveform with the ";: Color _RGB(255, 255, 0): Print " @";: Color _RGB(255, 255, 255): Print " symbol."
Print " There are 5 waveforms: ";: Color _RGB(255, 255, 0): Print "1=square, 2=sawtooth, 3=triangle, 4=sine, 5=white-noise": Color _RGB(255, 255, 255)
Print " (You may need to turn volume up to hear the difference here)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print " L2 @1 C P2 @2 C P2 @3 C P2 @4 C P2 @5 C P4 @1 C P2 @2 C P2 @3 C P2 @4 C P3 @4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L2 @1 C P2 @2 C P2 @3 C P2 @4 C P2 @5 C P4 @1 C P2 @2 C P2 @3 C P2 @4 C P3 @4 C"
Print " (the reason for the final @4 in this string, is that the @ is sticky, and remains"
Print " for the next PLAY string)."
If k$ <> "A" Then Sleep 1: Cls: GoTo Start
Color _RGB(255, 255, 0): Print: Print Tab(30); "Press a key for next topic": Sleep: Cls: Print
Accent:
Color _RGB(255, 255, 0): Print " Accent (attack):"
Color _RGB(255, 255, 255): Print
Print " The attack rate of notes can be changed with ";: Color _RGB(255, 255, 0): Print "Q";: Color _RGB(255, 255, 255): Print " (can be from 0 to 100)."
Print " This changes note from, say the emphatic piano sound, to the softer sound"
Print " of a flute."
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 Q0 CEG P1 Q50 CEG P1 Q100 CEG": Color _RGB(255, 255, 255)
Sleep 1: Play "L2 Q0 CEG P1 Q50 CEG P1 Q100 CEG": Sleep 1
Color _RGB(255, 255, 0): Print: Print Tab(26); "Press a key ": Sleep: Cls: GoTo Start
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/