Blog Post

Small Basic Blog
1 MIN READ

Small Basic - Chord Sounds

Ed Price's avatar
Ed Price
Former Employee
Feb 12, 2019
First published on MSDN on Mar 12, 2016

Authored by LitDev


This blog is by Small Basic user Yvan Leduc and is based on this Forum Post .  It shows how to play musical chords in Small Basic just using the standard Sound.PlayMusic method.


Objective


How to play a complete music chord, for example a C major chord, instead of playing the separate notes.


Solution


A full sample program is provided with the publish code, NNP250 .  It plays the first staves of a piece for classical guitar written by Matteo Carcassi: Study No.6 Op60.



How it Works


As an example of a chord in the program, we look at a C major chord which plays 3 notes together.

Here is a full C major:



a [ 1 ] = "o4l64 E" + "o6l64 C" + "o8l64 G" 'C major chords, 3 notes together

n [ 1 ] = "o5l6 E"


It has two variables a and n , together they build the chord,

o4 = the octave on the keyboard

l64 = the duration of the note (very short)

E = the note

E+C+G = C major on a piano.

and the final instruction that plays the chord is:



Sound . PlayMusic ( a [ t ] + n [ t ] )


This is placed in a For Endfor loop with other chords and notes.


Thanks Yvan for sharing this.

Published Feb 12, 2019
Version 1.0

1 Comment

  • altafhas's avatar
    altafhas
    Copper Contributor

    This blog is by Small Basic user https://chordsandlyric.com/https://social.msdn.microsoft.com/profile/yvan%20leduc/?type=forum&referrer=http://social.msdn.microsoft.com/Forums/en-US/home?forum=smallbasicand is based on this Forum Post.  It shows how to play musical chords in Small Basic just using the standard Sound.PlayMusic method.

     

    Objective

     

    How to play a complete music chord, for example a C major chord, instead of playing the separate notes.