Sign in to follow this  
Followers 0
Achilles

Practice your guitar chords

32 posts in this topic

#1 ·  Posted (edited)

I just recently starting learning guitar.. I've been using online lessons (www.justinguitar.com) and he taught that you needs lots of repetition when practicing your chords. Well, to facilitate that I made this program.

Suggestions/comments/criticism/insults/compliments all welcome.

If I get around to it I might add a little history file so it remembers which chords you do and do not want. There's probably more chords to be added and I'll do that sometime too.

Change log
9/7/2010 - Changed to use graphics instead of physical pictures
9/8/2010 - Added lots of chords, listview select now previews the chord, double-click checks/unchecks items
9/13/2010 - Change to Event mode, changed the listview a little, cleaned up a few other little things)

Code: (picture files no longer needed!)

#include <Array.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt('GUIResizeMode', 802) ; control will not move during resizing
Opt('GUIOnEventMode', 1)
Opt('GUICloseOnESC', 1)

Global Const $WIDTH = 200, $HEIGHT = 300, $B = 10 ; border between objects
Global Const $EXTRA_HEIGHT = 150 ; height added in expanded view

Global $chordData[20][3] = [['A', '1.2|1.3|1.4', 'xo|||o'], ['A7', '1.2|1.4', 'xo|o|o'], ['Am', '1.2|1.3|0.4', 'xo|||o'], _
    ['Asus2', '1.2|1.3', 'xo||oo'], ['Asus4', '1.2|1.3|2.4', 'xo|||o'], ['B7', '1.1|0.2|1.3|1.5', 'x|||o|'], _
    ['C', '2.1|1.2|0.4', 'x||o|o'], ['C7', '2.1|1.2|2.3|0.4', 'x||||o'], ['D', '1.3|2.4|1.5', 'xxo|||'], _
    ['D7', '1.3|0.4|1.5', 'xxo|||'], ['Dm', '1.3|2.4|0.5', 'xxo|||'], ['Dsus2', '1.3|2.4', 'xxo||o'], _
    ['Dsus4', '1.3|2.4|3.5', 'xxo|||'], ['E', '1.1|1.2|0.3', 'o||||oo'], ['E7', '1.1|0.3', 'o|o||oo'], _
    ['Em', '1.1|1.2', 'o||ooo'], ['Esus4', '1.1|1.2|1.3', 'o|||oo'], ['Fmaj7', '2.2|1.3|0.4', 'xx|||o'], _
    ['G', '2.0|1.1|2.5', '||ooo|'], ['G7', '2.0|1.1|0.5', '||ooo|']]

Global $listview = -1


Global $checkedList[UBound($chordData)]
    For $i = 0 to UBound($chordData) - 1
        $checkedList[$i] = 0
    Next
Global $currentIndex = -1

$gui = GUICreate('Chord Practice', $WIDTH + $B * 2, $HEIGHT + $B * 8)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')

$chordPic = '56]' ; not quite sure why I needed this, but using a random negative number messed everything up

Global $xOffset = 5
$chordName = GUICtrlCreateLabel('', $B * 2, $B * 2.25, $WIDTH - $B * 2, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 20, 500, -1, 'Tahoma')

Global $lblStrum[6]
For $i = 0 to UBound($lblStrum) - 1
    $lblStrum[$i] = GUICtrlCreateLabel('', 31 - $xOffset + 30 * $i, 53, 20, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetFont(-1, 16, 500, -1, 'Tahoma')
Next

$txtInterval = GUICtrlCreateInput('4', $B, $HEIGHT + $B * 2, 40, 20, $ES_NUMBER)
GUICtrlCreateUpdown($txtInterval)
GUICtrlCreateLabel('Interval (seconds)', $B + 45, $HEIGHT + $B * 2 +3, 90)

$startStop = GUICtrlCreateButton('Start', $WIDTH - 40, $HEIGHT + $B * 2, 50, 20)
    GUICtrlSetOnEvent(-1, '_StartStop')

$btnExpand = GUICtrlCreateButton('>>>', $B, $HEIGHT + $B * 5, $WIDTH, 20)
    GUICtrlSetOnEvent(-1, '_ExpandEvent')
$expanded = False

GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()

While Sleep(200)
WEnd

Func _StartStop()
    If GUICtrlRead($startStop) = 'Start' then
        _UpdateCheckedList()
        $pass = 0
        $index = 0
        Do
            If $checkedList[$index] then
                $pass += 1
            EndIf
            $index += 1
        Until $index >= UBound($checkedList) or $pass > 2
        If $pass < 2 then
            Msgbox(16, 'Error', 'Please select more chords to practice!')
            If Not $expanded then _Expand()
            Return
        EndIf

        $int = GUICtrlRead($txtInterval)
        If $int < 1 then
            $int = 1
            GUICtrlSetData($txtInterval, $int)
        EndIf
        AdlibRegister('_ChangeChordPic', $int * 1000)
        GUICtrlSetData($startStop, 'Stop')
        GUICtrlSetState($txtInterval, $GUI_DISABLE)
        GUICtrlSetState($btnExpand, $GUI_DISABLE)
        If $expanded then _Contract()
        _ChangeChordPic()
    Else
        AdlibUnRegister('_ChangeChordPic')
        GUICtrlSetData($startStop, 'Start')
        GUICtrlSetState($txtInterval, $GUI_ENABLE)
        GUICtrlSetState($btnExpand, $GUI_ENABLE)
    EndIf
EndFunc

Func _ExpandEvent()
    If $expanded then
        _Contract()
    Else
        _Expand()
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc

Func _ChangeChordPic()
    Local $index = -1
    Do
        $index = Random(0, UBound($chordData) - 1, 1)
    Until $index <> $currentIndex and $checkedList[$index] = 1
    $currentIndex = $index

    _SetChord()
EndFunc

Func _UpdateCheckedList()
    For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1
        If _GUICtrlListView_GetItemChecked($listview, $i) then
            $checkedList[$i] = 1
        Else
            $checkedList[$i] = 0
        EndIf
    Next
EndFunc


Func _Contract()
    GUICtrlSetState($listview, $GUI_HIDE)

    $pos = WinGetPos($gui)
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] - $EXTRA_HEIGHT)

    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5, $WIDTH, 20)

    $expanded = False
    GUICtrlSetData($btnExpand, '>>>')
EndFunc


Func _Expand()
    $pos = WinGetPos($gui)
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] + $EXTRA_HEIGHT)

    If $listview <> -1 then
        GUICtrlSetState($listview, $GUI_SHOW)
    Else
        $listview = GUICtrlCreateListView('Chord', $B, $HEIGHT + $B * 5, $WIDTH, $EXTRA_HEIGHT, $LVS_SHOWSELALWAYS)
            $listviewMenu = GUICtrlCreateContextMenu($listview)
                GUICtrlCreateMenuItem('Select', $listviewMenu)
                    GUICtrlSetOnEvent(-1, '_Select')
                GUICtrlCreateMenuItem('Unselect', $listviewMenu)
                    GUICtrlSetOnEvent(-1, '_Unselect')
                GUICtrlCreateMenuItem('Select All', $listviewMenu)
                    GUICtrlSetOnEvent(-1, '_SelectAll')
                GUICtrlCreateMenuItem('Unselect All', $listviewMenu)
                    GUICtrlSetOnEvent(-1, '_UnselectAll')
        _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
        _GUICtrlListView_SetColumnWidth($listview, 0, $WIDTH - 30)

        For $i = 0 to UBound($chordData) - 1
            _GUICtrlListView_AddItem($listview, $chordData[$i][0])
            If $checkedList[$i] = 1 then
                _GUICtrlListView_SetItemChecked($listview, $i, True)
            EndIf
        Next
    EndIf

    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5 + $EXTRA_HEIGHT + 5, $WIDTH, 20)

    $expanded = True
    GUICtrlSetData($btnExpand, '<<<')
EndFunc

Func _Select()
    $sel = _GUICtrlListView_GetSelectedIndices($listview, True)

    For $i = 1 to $sel[0]
        _GUICtrlListView_SetItemChecked($listview, $sel[$i])
    Next
EndFunc

Func _Unselect()
    $sel = _GUICtrlListView_GetSelectedIndices($listview, True)

    For $i = 1 to $sel[0]
        _GUICtrlListView_SetItemChecked($listview, $sel[$i], False)
    Next
EndFunc

Func _SelectAll()
    For $i = 0 to _GUICtrlListView_GetItemCount($listview)
        _GUICtrlListView_SetItemChecked($listview, $i)
    Next
EndFunc

Func _UnselectAll()
    For $i = 0 to _GUICtrlListView_GetItemCount($listview)
        _GUICtrlListView_SetItemChecked($listview, $i, False)
    Next
EndFunc

Func _SetChord()
    GUICtrlDelete($chordPic)

    $chordPic = GUICtrlCreateGraphic($B, $B, $WIDTH, $HEIGHT)
        GUICtrlSetBkColor(-1, 0xFFFFFF)
        GUICtrlSetColor(-1, 0)

    GUICtrlSetData($chordName, $chordData[$currentIndex][0])

    $strum = StringSplit($chordData[$currentIndex][2], '')
    For $i = 0 to UBound($lblStrum) - 1
        If $strum[$i + 1] = '|' then $strum[$i + 1] = ''
        GUICtrlSetData($lblStrum[$i], $strum[$i + 1])
    Next

    For $i = 1 to 6
        GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, $i * 30 - $xOffset, 65, 2, 184)
    Next
    GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 65, 150, 2)
    For $i = 0 to 5
        GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 72 + $i * 35, 150, 2)
    Next

    ; open E string would be 0.0... open A string would be 0.1..
    $pos = StringSplit($chordData[$currentIndex][1], '|')
    GUICtrlSetGraphic($chordPic, $GUI_GR_COLOR, 0, 0)
    For $i = 0 to UBound($pos) - 2
        $stringSplit = StringSplit($pos[$i + 1], '.')
        GUICtrlSetGraphic($chordPic, $GUI_GR_ELLIPSE, ($stringSplit[2] + 1) * 30 - 15, ($stringSplit[1]) * 35 + 63 + 35/2, 22, 22)
    Next
    GUICtrlSetGraphic($chordPic, $GUI_GR_REFRESH)
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

    $hWndListView = $listview
    If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $index = DllStructGetData($tInfo, 'SubItem')
                    If $index <> $currentIndex then
                        $currentIndex = $index
                        _SetChord()
                    EndIf
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $index = DllStructGetData($tInfo, 'SubItem')
                    If _GUICtrlListView_GetItemChecked($listview, $index) then
                        _GUICtrlListView_SetItemChecked($listview, $index, False)
                    Else
                        _GUICtrlListView_SetItemChecked($listview, $index)
                    EndIf
                    ; No return value
;~              Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
;~                  $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)

;~                  Return 1 ; not to allow the default processing
;~                  ;Return 0 ; allow the default processing
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by Achilles

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites



i like it.

you need to add more chords though, but you already know that.

wouldve been nice back when i still played guitar.

nice job.

legoman

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hey that's not a bad idea at all. LOL

Playing chords in a random order can be good for learning basic chords and also for finger practice. Playing scales at random is also very beneficial.

Edit

One thing I don't like about it are the diagrams. They are not clear because they don't indicate which strings I need to avoid playing. This is usually represented by an x. And strings played open are represented by an o

Fmaj7
 xo   o
 ||||•|
 |||•||
 ||•|||
Edited by czardas

Share this post


Link to post
Share on other sites

i like it.

you need to add more chords though, but you already know that.

wouldve been nice back when i still played guitar.

nice job.

legoman

Thanks! lol, the only bad part about this program is that it doesn't stay useful very long..

lol i play guitar too ;) good job ;) not gonna use it though ^^

Thanks

nvm... :)

ok

Hey that's not a bad idea at all. LOL

Playing chords in a random order can be good for learning basic chords and also for finger practice. Playing scales at random is also very beneficial.

Edit

One thing I don't like about it are the diagrams. They are not clear because they don't indicate which strings I need to avoid playing. This is usually represented by an x. And strings played open are represented by an o

Fmaj7
 xo   o
 ||||•|
 |||•||
 ||•|||

Am I looking at the same pictures as you are? 'cause in the pictures I uploaded I see x's and o's.. lol, I was thinking about adding scales sometime..

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Am I looking at the same pictures as you are? 'cause in the pictures I uploaded I see x's and o's.. lol, I was thinking about adding scales sometime..

Haha, you're right. They are nice and clear when you run the program. I just glanced at the thumbnails in the folder and didn't notice them. Either the thumbnails are too small or I need glasses. Probably I need glasses anyway. ;)

Anyway what's wrong with having an A bass in Fmaj7, or an A bass in a D chord? Well I guess it's not so important, but I would include them. It's easier for the right hand to just miss out the sixth string, so it would be easier for a beginner to play the chords. It's just a suggestion. I still think it's a great idea.

Edited by czardas

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Chords.xls

Example

#include <GUIConstantsEx.au3>


Global $a, $wi=40, $hi=20, $ww=10, $hh=10, $nP=3, $z=0
Dim $a1[6]
$gui = GUICreate('Chords', 300, 283,30,10)
$restart = GUICtrlCreateButton("R", 10, 260, 18, 20)

$Combo = GUICtrlCreateList('', 240, 10, 50, 17*16+2)
GUICtrlSetData(-1,"Cm|C|C7|Cm7|Cm75|Cm6|Cmj7|Cj7|C75-|C5+|Cm5-|C7+5+|Csus7|C75+|Co|C9-|C9","Cm")

Dim $Lab[6]
For $i = 0 to 5
    $Lab[$i]=GUICtrlCreateLabel ("", $ww+$wi*5-$i*$wi+8,$hh,10,13)
    GUICtrlSetBkColor(-1, 0xffffff)
Next

$a2 = GUICtrlCreateGraphic(10, 150, 15, 88)
GUICtrlSetGraphic($a2, $GUI_GR_COLOR, 0, 0xFF0000)
GUICtrlSetGraphic($a2, $GUI_GR_ELLIPSE, 0, 0, 11, 11)
GUICtrlSetGraphic($a2, $GUI_GR_COLOR, 0, 0x00dd00)
GUICtrlSetGraphic($a2, $GUI_GR_ELLIPSE, 0, 20, 11, 11)
GUICtrlSetGraphic($a2, $GUI_GR_COLOR, 0, 0x5555FF)
GUICtrlSetGraphic($a2, $GUI_GR_ELLIPSE, 0, 40, 11, 11)
GUICtrlSetGraphic($a2, $GUI_GR_COLOR, 0, 0)
GUICtrlSetGraphic($a2, $GUI_GR_ELLIPSE, 0, 60, 11, 11)
GUICtrlCreateLabel ("1", 25, 148,10,13)
GUICtrlCreateLabel ("2", 25, 168,10,13)
GUICtrlCreateLabel ("3", 25, 188,10,13)
GUICtrlCreateLabel ("4", 25, 208,10,13)


$Play=GUICtrlCreateCheckbox("Play", 55, 148, 60,13)


$a = GUICtrlCreateGraphic($ww, $hh, $wi*6-20, $hi*6+5)
GUICtrlSetBkColor($a, 0xffffff)

; струны
For $i = 0 to 5
    GUICtrlSetGraphic($a, $GUI_GR_RECT, $ww,$hh+$i*$hi+5, $wi*5+1, 1)
Next

; лады
For $i = 0 to 5
    GUICtrlSetGraphic($a, $GUI_GR_RECT, $ww+$i*$wi,$hh+5, 1, $hi*5)
Next

_nLab()
_Point(1, 1, 3)
_Point(2, 2, 2)
_Point(3, 3, 1)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)


GUISetState()

While 1
     $msg = GUIGetMsg()
     Select
        Case $msg = -3
            Exit
        Case $msg = $Combo
            For $i = 0 to 5
                GUICtrlDelete($a1[$i])
            Next
            Switch GUICtrlRead($Combo)
                Case 'Cm'
_nLab()
_Point(1, 1, 3)
_Point(2, 2, 2)
_Point(3, 3, 1)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 2, 2)
    _BeepG(3, 3, 1)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'C'
_nLab()
_Point(1, 1, 3)
_Point(2, 3, 2)
_Point(3, 3, 1)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 3, 2)
    _BeepG(3, 3, 1)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'C7'
_nLab()
_Point(1, 1, 3)
_Point(2, 3, 2)
_Point(3, 1)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 3, 2)
    _BeepG(3, 1)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'Cm7'
_nLab()
_Point(1, 1, 3)
_Point(2, 2, 2)
_Point(3, 1)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 2, 2)
    _BeepG(3, 1)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'Cm75'
                $nP+=1
_nLab()
_Point(1, 3)
_Point(2, 1, 2)
_Point(3, 2, 1)
_Point(4, 1, 3)
_Point(5, 3, 2)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 3)
    _BeepG(2, 1, 2)
    _BeepG(3, 2, 1)
    _BeepG(4, 1, 3)
    _BeepG(5, 3, 2)
EndIf
                $nP-=1
                Case 'Cm6'
                $nP-=2
_nLab()
_Point(1, 3, 3)
_Point(2, 1, 1)
_Point(3, 2)
_Point(4, 1, 2)
_Point(5, 3, 1)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 3, 3)
    _BeepG(2, 1, 1)
    _BeepG(3, 2)
    _BeepG(4, 1, 2)
    _BeepG(5, 3, 1)
EndIf
                $nP+=2
                Case 'Cmj7'
_nLab()
_Point(1, 1, 3)
_Point(2, 2, 2)
_Point(3, 2)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 2, 2)
    _BeepG(3, 2)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'Cj7'
_nLab()
_Point(1, 1, 3)
_Point(2, 3, 2)
_Point(3, 2)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 3, 2)
    _BeepG(3, 2)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'C75-'
                $nP-=2
_nLab()
_Point(1, 2, 3)
_Point(2, 1, 1)
_Point(3, 3)
_Point(4, 2, 2)
_Point(5, 1)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 2, 3)
    _BeepG(2, 1, 1)
    _BeepG(3, 3)
    _BeepG(4, 2, 2)
    _BeepG(5, 1)
EndIf
                $nP+=2
                Case 'C5+'
                $nP+=1
_nLab()
_Point(1, 1, 3)
_Point(2, 2, 2)
_Point(3, 2, 1)
_Point(4, 3, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 2, 2)
    _BeepG(3, 2, 1)
    _BeepG(4, 3, 3)
EndIf
                $nP-=1
                Case 'Cm5-'
                $nP-=1
_nLab()
_Point(1, 1, 3)
_Point(2, 3, 2)
_Point(3, 4, 1)
_Point(4, 3, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 3, 2)
    _BeepG(3, 4, 1)
    _BeepG(4, 3, 3)
EndIf
                $nP+=1
                Case 'C7+5+'
                $nP+=2
_nLab()
_Point(1, 3)
_Point(2, 1, 2)
_Point(3, 1, 1)
_Point(4, 2, 3)
_Point(5, 3, 2)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 3)
    _BeepG(2, 1, 2)
    _BeepG(3, 1, 1)
    _BeepG(4, 2, 3)
    _BeepG(5, 3, 2)
EndIf
                $nP-=2
                Case 'Csus7'
_nLab()
_Point(1, 1, 3)
_Point(2, 4, 2)
_Point(3, 1)
_Point(4, 3, 3)
_Point(5, 1, 1)
_Point(6, 1, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 1, 3)
    _BeepG(2, 4, 2)
    _BeepG(3, 1)
    _BeepG(4, 3, 3)
    _BeepG(5, 1, 1)
    _BeepG(6, 1, 3)
EndIf
                Case 'C75+'
                $nP+=2
_nLab()
_Point(1, 2)
_Point(2, 1, 2)
_Point(3, 1, 1)
_Point(4, 2, 3)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 2)
    _BeepG(2, 1, 2)
    _BeepG(3, 1, 1)
    _BeepG(4, 2, 3)
EndIf
                $nP-=2
                Case 'Co'
                $nP-=2
_nLab()
_Point(1, 2)
_Point(2, 1)
_Point(3, 2)
_Point(4, 1)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 2)
    _BeepG(2, 1)
    _BeepG(3, 2)
    _BeepG(4, 1)
EndIf
                $nP+=2
                Case 'C9-'
                $nP-=1
_nLab()
_Point(1, 2)
_Point(2, 1)
_Point(3, 2)
_Point(4, 1)
_Point(5, 2)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 2)
    _BeepG(2, 1)
    _BeepG(3, 2)
    _BeepG(4, 1)
    _BeepG(5, 2)
EndIf
                $nP+=1
                Case 'C9'
                $nP+=2
_nLab()
_Point(1, 2)
_Point(2, 1, 2)
_Point(3, 1, 1)
_Point(4, 1, 3)
_Point(5, 1)

If GUICtrlRead($Play)=1 Then
    _BeepG(1, 2)
    _BeepG(2, 1, 2)
    _BeepG(3, 1, 1)
    _BeepG(4, 1, 3)
    _BeepG(5, 1)
EndIf
                $nP-=2
            EndSwitch
        Case $msg = $restart
            _restart()
    EndSelect
WEnd

Func _nLab()
    For $i = 0 to 5
        GUICtrlSetData($Lab[$i],$i+$nP-1)
    Next
    $z=0
EndFunc

Func _Point($S, $L, $C=0)
$clr = 0
Switch $C
    Case 1
       $clr = 0xFF0000
    Case 2
       $clr = 0x00dd00
    Case 3
       $clr = 0x5555FF
    Case Else
       $clr = 0
EndSwitch

$a1[$z] = GUICtrlCreateGraphic($ww, $hh)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $clr) ; цвет круга
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $wi*6-$L*$wi-$wi/2+5, $hi*6-$S*$hi+5+5, 11, 11)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
$z+=1
EndFunc

Func _BeepG($S, $L, $C=0)
Switch $S
    Case 1
       $delta = 24
    Case 2
       $delta = 19
    Case 3
       $delta = 15
    Case 4
       $delta = 10
    Case 5
       $delta = 5
    Case 6
       $delta = 0
EndSwitch
$iNote=$delta+$nP+$L
$iFrequency=440*2^(($iNote)/12+3+1/6-4)
Beep($iFrequency, 200)
EndFunc

Func _restart()
    Local $sAutoIt_File = @TempDir & "\~Au3_ScriptRestart_TempFile.au3"
    Local $sRunLine, $sScript_Content, $hFile

    $sRunLine = @ScriptFullPath
    If Not @Compiled Then $sRunLine = @AutoItExe & ' /AutoIt3ExecuteScript ""' & $sRunLine & '""'
    If $CmdLine[0] > 0 Then $sRunLine &= ' ' & $CmdLineRaw

    $sScript_Content &= '#NoTrayIcon' & @CRLF & _
            'While ProcessExists(' & @AutoItPID & ')' & @CRLF & _
            '   Sleep(10)' & @CRLF & _
            'WEnd' & @CRLF & _
            'Run("' & $sRunLine & '")' & @CRLF & _
            'FileDelete(@ScriptFullPath)' & @CRLF

    $hFile = FileOpen($sAutoIt_File, 2)
    FileWrite($hFile, $sScript_Content)
    FileClose($hFile)

    Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sAutoIt_File & '"', @ScriptDir, @SW_HIDE)
    Sleep(1000)
    Exit
EndFunc   ;==>_restart
Edited by AZJIO

Share this post


Link to post
Share on other sites

Nice example. I wish I had more time to look at the code right now. I'll have to look later.

The diagram is normally rotated the other way around. Again it doesn't matter too much.

654321
0||||||
1||||||
2||||||
3||||||
4||||||
5||||||

Thanks for all this great stuff Azilo. ;)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Global $Object = ObjCreate("SAPI.SpVoice")
 $Object.Rate = 0
 $Object.Volume = 60


Func _ChangeChordPic()
    Local $index = -1
    Do
        $index = Random(1, $chordList[0], 1)
    Until $index <> $currentIndex and $checkedList[$index] = 1
    $currentIndex = $index

    GUICtrlSetImage($chordPic, '')
    GUICtrlSetImage($chordPic, $dir & '\' & $chordList[$currentIndex])
    $chordname = stringtrimright ($chordlist[$currentIndex], 4)
    $saychord = StringReplace ($chordname , 'maj' , ' major' , 1)
    $len = StringLen ($saychord)
    If $len < 4 Then
        $saychord = StringReplace ($saychord , 'm' , ' minor' , 1)
     Endif
        $saychord = StringReplace ($saychord , "a" , "eigh")
    $Object.Speak($saychord, 0)
EndFunc

Added lines to your changechordPic function to make it say the name of the chord as your seeing and playing

*edit: no minor 7 examples in the .zip, but i changed the length to "$len < 4" for those cases

stringreplaced "a" for "eigh" to help SAM with pronunciation.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Updated!

Now it uses only graphics...

Anyway what's wrong with having an A bass in Fmaj7, or an A bass in a D chord? Well I guess it's not so important, but I would include them. It's easier for the right hand to just miss out the sixth string, so it would be easier for a beginner to play the chords. It's just a suggestion. I still think it's a great idea.

I've wondered that too.. I mean an A is part of a D chord..

Chords.xls

Example

;code...
  

Thanks for that example.. I updated by program based on it.

Nice example. I wish I had more time to look at the code right now. I'll have to look later.

The diagram is normally rotated the other way around. Again it doesn't matter too much.

654321
0||||||
1||||||
2||||||
3||||||
4||||||
5||||||

Thanks for all this great stuff Azilo. ;)

I thought that's how these pictures were.. ? At least the low E string is on the far left, and I think it's the one called the 6th string

Global $Object = ObjCreate("SAPI.SpVoice")
 $Object.Rate = 0
 $Object.Volume = 60


Func _ChangeChordPic()
    Local $index = -1
    Do
        $index = Random(1, $chordList[0], 1)
    Until $index <> $currentIndex and $checkedList[$index] = 1
    $currentIndex = $index

    GUICtrlSetImage($chordPic, '')
    GUICtrlSetImage($chordPic, $dir & '\' & $chordList[$currentIndex])
    $chordname = stringtrimright ($chordlist[$currentIndex], 4)
    $saychord = StringReplace ($chordname , 'maj' , ' major' , 1)
    $len = StringLen ($saychord)
    If $len < 4 Then
        $saychord = StringReplace ($saychord , 'm' , ' minor' , 1)
     Endif
        $saychord = StringReplace ($saychord , "a" , "eigh")
    $Object.Speak($saychord, 0)
EndFunc

Added lines to your changechordPic function to make it say the name of the chord as your seeing and playing

*edit: no minor 7 examples in the .zip, but i changed the length to "$len < 4" for those cases

stringreplaced "a" for "eigh" to help SAM with pronunciation.

I'll implement an option for this sometime..

Nice Idea, I like it.

I can see this working alongside mp3s with timed chord changes.

That would be a fun project to do.. if I get ambitious it might happen

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

#include <Array.au3> 
#include <EditConstants.au3> 
#include <File.au3> 
#include <GUIConstantsEx.au3> 
#Include <GuiListView.au3>
#include <StaticConstants.au3> 

Opt('GUIResizeMode', 802) 
Global Const $WIDTH = 200, $HEIGHT = 300, $B = 10 
Global Const $EXTRA_HEIGHT = 150  
Global $chordData[8][4] = [['A major', '1.2|1.3|1.4', 'xo|||o' , '_Amajorscale'] , ['A major 7', '1.2|1.4', 'xo|o|o' , '_Amajor7scale'], ['A minor', '1.2|1.3|0.4', 'xo|||o', '_Aminorscale'] , ['B flat minor', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|1.4', '||||||' , '_Bflatminorscale'] , ['A suspend 2', '1.2|1.3', 'xo||oo' , '_Asus2scale'], ['A suspend 4', '1.2|1.3|2.4', 'xo|||o' , '_Asus4scale'], ['B major 7', '1.1|0.2|1.3|1.5', 'x|||o|', '_Bmajor7scale'] , ['B major', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|2.4', '||||||' , '_Bmajorscale']]
Global $listview = -1 
Global $checkedList[UBound($chordData)]     
For $i = 0 to UBound($chordData) - 1         
    $checkedList[$i] = 1     
Next 
Global $currentIndex = -1 
$gui = GUICreate('Chord Practice', $WIDTH + $B * 2, $HEIGHT + $B * 8) 
$chordPic = '56]'  
Global $xOffset = 5 
$chordName = GUICtrlCreateLabel('', $B * 2, $B * 2.5, $WIDTH - $B * 2, 32, $SS_CENTER)
GUICtrlSetFont(-1, 20)   
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)    
GUICtrlSetFont(-1, 20, 500, -1, 'Tahoma') 
Global $lblStrum[6]
For $i = 0 to UBound($lblStrum) - 1    
$lblStrum[$i] = GUICtrlCreateLabel('', 31 - $xOffset + 30 * $i, 53, 20, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))        
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)        
GUICtrlSetFont(-1, 16, 500, -1, 'Tahoma')
Next 
$txtInterval = GUICtrlCreateInput('2', $B, $HEIGHT + $B * 2, 40, 20, $ES_NUMBER) 
GUICtrlCreateUpdown($txtInterval)
GUICtrlCreateLabel('Interval (seconds)', $B + 45, $HEIGHT + $B * 2 +3, 90) 
$startStop = GUICtrlCreateButton('Start', $WIDTH - 40, $HEIGHT + $B * 2, 50, 20)
$btnExpand = GUICtrlCreateButton('>>>', $B, $HEIGHT + $B * 5, $WIDTH, 20) 
$expanded = False 
GUISetState() 

Global $Object = ObjCreate("SAPI.SpVoice")


While 1     
    Switch GUIGetMsg()        
    Case $GUI_EVENT_CLOSE            
        Exit        
    Case $startStop             
        If GUICtrlRead($startStop) = 'Start' then                
            $int = GUICtrlRead($txtInterval)                
            If $int < 1 then                    
                $int = 1                   
                GUICtrlSetData($txtInterval, $int)            
            EndIf               
            AdlibRegister('_ChangeChordPic', $int * 2000)            
            GUICtrlSetData($startStop, 'Stop')           
            GUICtrlSetState($txtInterval, $GUI_DISABLE)         
            GUICtrlSetState($btnExpand, $GUI_DISABLE)     
            _UpdateCheckedList()      
            If $expanded then _Contract()          
                _ChangeChordPic()  
                            Else             
                AdlibUnRegister('_ChangeChordPic')          
            GUICtrlSetData($startStop, 'Start')        
            GUICtrlSetState($txtInterval, $GUI_ENABLE)        
            GUICtrlSetState($btnExpand, $GUI_ENABLE)     
        EndIf        
    Case $btnExpand         
        If $expanded then     
            _Contract()        
        Else               
            _Expand()         
        EndIf   
    EndSwitch
WEnd 

Func _ChangeChordPic()   
    Local $index = -1    
    Do        
        $index = Random(0, UBound($chordData) - 1, 1)   
    Until $index <> $currentIndex and $checkedList[$index] = 1    
    $currentIndex = $index  
    _SetChord()
    $saychord = StringReplace ($chorddata[$index][0], "a" , "eigh")
    $Object.Speak($saychord, 0)
    call ($chorddata[$index][3])
EndFunc

Func _UpdateCheckedList()  
    For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1       
        If _GUICtrlListView_GetItemChecked($listview, $i) then         
            $checkedList[$i] = 1   
        Else            
            $checkedList[$i] = 0         
        EndIf    
    Next
EndFunc 

Func _Contract()  
    GUICtrlSetState($listview, $GUI_HIDE)   
    $pos = WinGetPos($gui)   
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] - $EXTRA_HEIGHT)    
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5, $WIDTH, 20)   
    $expanded = False     GUICtrlSetData($btnExpand, '>>>')
EndFunc 

Func _Expand()  
    $pos = WinGetPos($gui)  
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] + $EXTRA_HEIGHT)   
    If $listview <> -1 then         
        GUICtrlSetState($listview, $GUI_SHOW)  
    Else      
        $listview = GUICtrlCreateListView('Chord', $B, $HEIGHT + $B * 5, $WIDTH, $EXTRA_HEIGHT)      
        _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))   
        _GUICtrlListView_SetColumnWidth($listview, 0, $WIDTH - 30)        
        For $i = 0 to UBound($chordData) - 1    
            _GUICtrlListView_AddItem($listview, $chordData[$i][0])      
            If $checkedList[$i] = 1 then         
                _GUICtrlListView_SetItemChecked($listview, $i, True)         
            EndIf      
        Next   
    EndIf    
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5 + $EXTRA_HEIGHT + 5, $WIDTH, 20)  
    $expanded = True   
    GUICtrlSetData($btnExpand, '<<<')
EndFunc 

Func _SetChord()   
    GUICtrlDelete($chordPic)   
    $chordPic = GUICtrlCreateGraphic($B, $B, $WIDTH, $HEIGHT)       
    GUICtrlSetBkColor(-1, 0xFFFFFF)      
    GUICtrlSetColor(-1, 0)   
    GUICtrlSetData($chordName, $chordData[$currentIndex][0])    
    $strum = StringSplit($chordData[$currentIndex][2], '')   
    For $i = 0 to UBound($lblStrum) - 1      
        If $strum[$i + 1] = '|' then $strum[$i + 1] = ''      
            GUICtrlSetData($lblStrum[$i], $strum[$i + 1])    
        Next    
        For $i = 1 to 6      
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, $i * 30 - $xOffset, 65, 2, 184)   
        Next    
        GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 65, 150, 2)  
        For $i = 0 to 5      
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 72 + $i * 35, 150, 2) 
        Next        
        $pos = StringSplit($chordData[$currentIndex][1], '|')   
        GUICtrlSetGraphic($chordPic, $GUI_GR_COLOR, 0, 0)  
        For $i = 0 to UBound($pos) - 2       
            $stringSplit = StringSplit($pos[$i + 1], '.')      
            GUICtrlSetGraphic($chordPic, $GUI_GR_ELLIPSE, ($stringSplit[2] + 1) * 30 - 15, ($stringSplit[1]) * 35 + 63 + 35/2, 22, 22)   
        Next   
        GUICtrlSetGraphic($chordPic, $GUI_GR_REFRESH)
    EndFunc
    
Func _Beep($iNote,$iOctave=4,$iDuration=200,$iPause=0)
        Global $nTempo=0.8
Global $iTone=-1
    $iFrequency=440*2^(($iNote+$iTone)/12+$iOctave+1/6-4)
    Beep($iFrequency, $iDuration/$nTempo)
    If $iPause<>0 Then Sleep($iPause/$nTempo)
    EndFunc

Func _Amajorscale()
_Beep(1,3,200)
_Beep(3,3,200)
_Beep(5,3,200)
_Beep(6,3,200)
_Beep(8,3,200)
_Beep(10,3,200)
_Beep(12,3,200)
_Beep(1,4,600)
Endfunc

Func _Amajor7scale()
_Beep(1,3,200)
_Beep(2,3,200)
_Beep(5,3,200)
_Beep(6,3,200)
_Beep(8,3,200)
_Beep(10,3,200)
_Beep(12,3,200)
_Beep(1,4,600)
Endfunc

Func _Asus2scale()
_Beep(1,3,200)
_Beep(3,3,200)
_Beep(5,3,200)
_Beep(6,3,200)
_Beep(8,3,200)
_Beep(10,3,200)
_Beep(11,3,200)
_Beep(1,4,600)
Endfunc

Func _Aminorscale()
_Beep(1,3,200)
_Beep(3,3,200)
_Beep(4,3,200)
_Beep(6,3,200)
_Beep(8,3,200)
_Beep(9,3,200)
_Beep(11,3,200)
_Beep(1,4,600)
Endfunc

Func _Asus4scale()
_Beep(2,3,200)
_Beep(3,3,200)
_Beep(5,3,200)
_Beep(6,3,200)
_Beep(8,3,200)
_Beep(10,3,200)
_Beep(12,3,200)
_Beep(1,4,600)
Endfunc

Func _Bflatminorscale()
_Beep(2,3,200)
_Beep(4,3,200)
_Beep(5,3,200)
_Beep(7,3,200)
_Beep(9,3,200)
_Beep(10,3,200)
_Beep(12,3,200)
_Beep(2,4,600)
Endfunc

Func _Bmajorscale()
_Beep(2,3,200)
_Beep(4,3,200)
_Beep(6,3,200)
_Beep(7,3,200)
_Beep(9,3,200)
_Beep(11,3,200)
_Beep(1,4,200)
_Beep(2,4,600)
Endfunc


Func _Bmajor7scale()
_Beep(2,3,200)
_Beep(3,3,200)
_Beep(6,3,200)
_Beep(7,3,200)
_Beep(9,3,200)
_Beep(11,3,200)
_Beep(1,4,200)
_Beep(2,4,600)
Endfunc

i made a couple of additions in my playing

- it shows the chord

-says the name = [$index][0] Then

-beeps the scale = [$index][3]


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

First, Thanks for a script that is challenging me to learn new stuff while potentially proving useful in my guitar instruction.

On your last change, the double click only affects the 0 item in the list.

Here is the alternative I am using - continuing to play with

1) on double click the current item is checked/unchecked AND current item chord pattern is displayed-

* except if you double click on the checkbox, since that throws a -1, I just have it display the 0 item rather than blow up

2) Clicking in a box will only select/deselect the item and not redraw the chord

3) added a 4th dimension for the array that is used to denote the "first visible fret" to the left of the board - my example being the D# minor where the first fret shown on screen is actually the 4th fret.

4) SAM reads the contents of the first dimension

5) beeps play the tones as they would be if you plucked the chord from low to high

#include <Array.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt('GUIResizeMode', 802) 
Global Const $WIDTH = 200, $HEIGHT = 300, $B = 10 
Global Const $EXTRA_HEIGHT = 150  
Global $chordData[26][5] = [['A major', '1.2|1.3|1.4', 'xo|||o' , '_Amajor' , ''] , ['A major 7', '1.2|1.4', 'xo|o|o' , '_Amajor7', ''], _
['A suspend 2', '1.2|1.3', 'xo||oo' , '_Asus2', ''], ['A suspend 4', '1.2|1.3|2.4', 'xo|||o' , '_Asus4', ''], ['A minor', '1.2|1.3|0.4', 'xo|||o', '_Aminor', ''], _ 
['B flat minor', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|1.4', '||||||' , '_Bflatminor', '']  , ['B flat major', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|2.4', '||||||' , '_Bflatmajor', ''], _ 
['B major', '1.0|1.1|1.2|1.3|1.4|1.5|3.2|3.3|3.4', '||||||' , '_Bmajor', ''] , ['B major 7', '1.1|0.2|1.3|1.5', 'x|||o|', '_Bmajor7', ''] , ['C major', '2.1|1.2|0.4', 'x||o|o' , '_Cmajor', ''], _ 
['C major 7', '2.1|1.2|2.3|0.4', 'x||||o' , '_Cmajor7', ''],  ['C minor', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|3.4', '||||||' , '_Cminor', ''], _ 
['D major', '1.3|2.4|1.5', 'xxo|||' , '_Dmajor', ''],  ['D major 7', '1.3|0.4|1.5', 'xxo|||' , '_Dmajor7', ''],  ['D minor', '1.3|2.4|0.5', 'xxo|||' , '_Dminor', ''], _ 
['D suspend 2', '1.3|2.4', 'xxo||o' , '_Dsus2', ''],  ['D suspend 4', '1.3|2.4|3.5', 'xxo|||', '_Dsus4', ''], ['E major', '1.1|1.2|0.3', 'o||||oo' , '_Emajor', ''], _ 
['E7', '1.1|0.3', 'o|o||oo' , '_Emajor7', ''], ['E minor', '1.1|1.2', 'o||ooo' , '_Eminor', ''], ['E suspend 4', '1.1|1.2|1.3', 'o|||oo' , '_Esus4', ''], _ 
['F major 7', '2.2|1.3|0.4', 'xx|||o' , '_Fmajor7', ''] ,  ['G major', '2.0|1.1|2.4|2.5', '||oo||' , '_Gmajor', ''], _ 
['G major 7', '2.0|1.1|0.5', '||ooo|' , '_Gmajor7', ''],  ['D sharp minor', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|3.4', '||||||' , '_Dsharpminor', '4'], _
['D sharp major', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|4.4', '||||||' , '_Dsharpmajor', '4']]



Global $listview = -1 
Global $checkedList[UBound($chordData)]     
For $i = 0 to UBound($chordData) - 1         
    $checkedList[$i] = 1     
Next 
Global $currentIndex = -1 
$gui = GUICreate('Chord Practice', $WIDTH + $B * 2, $HEIGHT + $B * 8) 
$chordPic = '56]'  
Global $xOffset = 5 
$chordName = GUICtrlCreateLabel('', $B * 2, $B * 2.5, $WIDTH - $B * 2, 32, $SS_CENTER)
GUICtrlSetFont(-1, 20)   
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)    
GUICtrlSetFont(-1, 20, 500, -1, 'Tahoma') 
Global $lblStrum[6]
For $i = 0 to UBound($lblStrum) - 1    
$lblStrum[$i] = GUICtrlCreateLabel('', 31 - $xOffset + 30 * $i, 53, 20, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))        
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)        
GUICtrlSetFont(-1, 16, 500, -1, 'Tahoma')
Next 
$txtInterval = GUICtrlCreateInput('2', $B, $HEIGHT + $B * 2, 40, 20, $ES_NUMBER) 
GUICtrlCreateUpdown($txtInterval)
GUICtrlCreateLabel('Interval (seconds)', $B + 45, $HEIGHT + $B * 2 +3, 90) 
$startStop = GUICtrlCreateButton('Start', $WIDTH - 40, $HEIGHT + $B * 2, 50, 20)
$btnExpand = GUICtrlCreateButton('>>>', $B, $HEIGHT + $B * 5, $WIDTH, 20) 
$expanded = False 
GUISetState() 

Global $Object = ObjCreate("SAPI.SpVoice")

GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()

While 1     
    Switch GUIGetMsg()        
    Case $GUI_EVENT_CLOSE            
        Exit        
    Case $startStop             
        If GUICtrlRead($startStop) = 'Start' then                
            $int = GUICtrlRead($txtInterval)                
            If $int < 1 then                    
                $int = 1                   
                GUICtrlSetData($txtInterval, $int)            
            EndIf               
            AdlibRegister('_ChangeChordPic', $int * 2000)            
            GUICtrlSetData($startStop, 'Stop')           
            GUICtrlSetState($txtInterval, $GUI_DISABLE)         
            GUICtrlSetState($btnExpand, $GUI_DISABLE)     
            _UpdateCheckedList()      
            If $expanded then _Contract()          
                _ChangeChordPic()  
                            Else             
                AdlibUnRegister('_ChangeChordPic')          
            GUICtrlSetData($startStop, 'Start')        
            GUICtrlSetState($txtInterval, $GUI_ENABLE)        
            GUICtrlSetState($btnExpand, $GUI_ENABLE)     
        EndIf        
    Case $btnExpand         
        If $expanded then     
            _Contract()        
        Else               
            _Expand()         
        EndIf   
    EndSwitch
WEnd 

Func _ChangeChordPic()   
    Local $index = -1    
    Do        
        $index = Random(0, UBound($chordData) - 1, 1)   
    Until $index <> $currentIndex and $checkedList[$index] = 1    
    $currentIndex = $index  
    _SetChord()
    $saychord = StringReplace ($chorddata[$index][0], "A" , "eigh" , 0 , 1)
    $saychord1 = StringReplace ($saychord, "flat" , "phlat")
    $Object.Speak($saychord1, 0)
    call ($chorddata[$index][3])
EndFunc

Func _UpdateCheckedList()  
    For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1       
        If _GUICtrlListView_GetItemChecked($listview, $i) then         
            $checkedList[$i] = 1   
        Else            
            $checkedList[$i] = 0         
        EndIf    
    Next
EndFunc 

Func _Contract()  
    GUICtrlSetState($listview, $GUI_HIDE)   
    $pos = WinGetPos($gui)   
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] - $EXTRA_HEIGHT)    
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5, $WIDTH, 20)   
    $expanded = False    
    GUICtrlSetData($btnExpand, '>>>')
EndFunc 

Func _Expand()  
    $pos = WinGetPos($gui)  
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] + $EXTRA_HEIGHT)   
    If $listview <> -1 then         
        GUICtrlSetState($listview, $GUI_SHOW)  
    Else      
        $listview = GUICtrlCreateListView('Chord', $B, $HEIGHT + $B * 5, $WIDTH, $EXTRA_HEIGHT)      
        _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES ))   ;$LVS_EX_ONECLICKACTIVATE
        _GUICtrlListView_SetColumnWidth($listview, 0, $WIDTH - 30)        
        For $i = 0 to UBound($chordData) - 1    
            _GUICtrlListView_AddItem($listview, $chordData[$i][0])      
            If $checkedList[$i] = 1 then         
                _GUICtrlListView_SetItemChecked($listview, $i, True)         
            EndIf      
        Next   
    EndIf    
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5 + $EXTRA_HEIGHT + 5, $WIDTH, 20)  
    $expanded = True   
    GUICtrlSetData($btnExpand, '<<<')
EndFunc 

Func _SetChord()   
    GUICtrlDelete($chordPic)   
    $chordPic = GUICtrlCreateGraphic($B, $B, $WIDTH, $HEIGHT)       
    GUICtrlSetBkColor(-1, 0xFFFFFF)      
    GUICtrlSetColor(-1, 0)   
    GUICtrlSetData($chordName, $chordData[$currentIndex][0])    
    $strum = StringSplit($chordData[$currentIndex][2], '')   
    For $i = 0 to UBound($lblStrum) - 1      
        If $strum[$i + 1] = '|' then $strum[$i + 1] = ''      
            GUICtrlSetData($lblStrum[$i], $strum[$i + 1])    
        Next    
        For $i = 1 to 6      
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, $i * 30 - $xOffset, 65, 2, 184)   
        Next    
        GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 65, 150, 2)  
        For $i = 0 to 5      
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 72 + $i * 35, 150, 2) 
        Next        
        $pos = StringSplit($chordData[$currentIndex][1], '|')   
        GUICtrlSetGraphic($chordPic, $GUI_GR_COLOR, 0, 0)  
        GUICtrlCreateLabel ( $chorddata[$currentindex][4], 20 - $xOffset, 88, 10, 13 )
    GUICtrlSetBkColor(-1, 0xFFFFFF)      
    GUICtrlSetColor(-1, 0) 
    GUICtrlSetFont (-1 , '' , 600)
        For $i = 0 to UBound($pos) - 2       
            $stringSplit = StringSplit($pos[$i + 1], '.')      
            GUICtrlSetGraphic($chordPic, $GUI_GR_ELLIPSE, ($stringSplit[2] + 1) * 30 - 15, ($stringSplit[1]) * 35 + 63 + 35/2, 22, 22)   
        Next   
        GUICtrlSetGraphic($chordPic, $GUI_GR_REFRESH)
    EndFunc
    
    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $listview
    If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
            Case $NM_DblClk 
                $currentindex = -1
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                        $CurrentIndex =  _GUICtrlListView_GetHotItem ($hWndlistview)
                        If $CurrentIndex   = -1 Then
                        $CurrentIndex = 0
                    Else
                    If _GUICtrlListView_GetItemChecked($hWndlistview, $CurrentIndex) then
                        _GUICtrlListView_SetItemChecked($hWndlistview, $CurrentIndex, False)
                    Else
                        _GUICtrlListView_SetItemChecked($hWndlistview, $CurrentIndex)
                        endif
    
EndIf
_setchord()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 
    
Func _Beep($iNote,$iOctave=4,$iDuration=200,$iPause=0)
        Global $nTempo=0.8
Global $iTone=-1
    $iFrequency=440*2^(($iNote+$iTone)/12+$iOctave+1/6-4)
    Beep($iFrequency, $iDuration/$nTempo)
    If $iPause<>0 Then Sleep($iPause/$nTempo)
    EndFunc

Func _Amajor()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(5,3,300)
_Beep(8,3,300)
Endfunc

Func _Amajor7()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(11,2,300)
_Beep(5,3,300)
_Beep(8,3,300)
Endfunc

Func _Asus2()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Asus4()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(7,3,300)
_Beep(8,3,300)
Endfunc

Func _Aminor()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc



Func _Bflatminor()
_Beep(9,1,300)
_Beep(2,2,300)
_Beep(9,2,300)
_Beep(2,3,300)
_Beep(5,3,300)
_Beep(9,3,300)
Endfunc

Func _Bflatmajor()
_Beep(9,1,300)
_Beep(2,2,300)
_Beep(9,2,300)
_Beep(2,3,300)
_Beep(6,3,300)
_Beep(9,3,300)
Endfunc

Func _Bmajor()
_Beep(10,1,300)
_Beep(3,2,300)
_Beep(10,2,300)
_Beep(3,3,300)
_Beep(7,3,300)
_Beep(9,3,300)
Endfunc


Func _Bmajor7()
_Beep(3,2,300)
_Beep(7,2,300)
_Beep(1,3,300)
_Beep(3,3,300)
_Beep(10,3,300)
Endfunc

Func _Cmajor()
_Beep(4,2,300)
_Beep(8,2,300)
_Beep(11,2,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Cmajor7()
_Beep(4,2,300)
_Beep(8,2,300)
_Beep(2,3,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Cminor()
_Beep(11,1,300)
_Beep(4,2,300)
_Beep(11,2,300)
_Beep(4,3,300)
_Beep(7,3,300)
_Beep(11,3,300)
Endfunc

Func _Dmajor()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(6,3,300)
_Beep(10,3,300)
Endfunc

Func _Dmajor7()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(10,3,300)
Endfunc

Func _Dminor()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(9,3,300)
Endfunc

Func _Dsus2()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(6,3,300)
_Beep(8,3,300)
Endfunc

Func _Dsus4()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(6,3,300)
_Beep(12,3,300)
Endfunc

Func _Emajor()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(8,2,300)
_Beep(12,2,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Emajor7()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(6,2,300)
_Beep(12,2,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Eminor()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(8,2,300)
_Beep(11,2,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Esus4()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Fmajor7()
_Beep(9,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Gmajor()
_Beep(11,1,300)
_Beep(3,2,300)
_Beep(6,2,300)
_Beep(11,2,300)
_Beep(6,3,300)
_Beep(11,3,300)
Endfunc

Func _Gmajor7()
_Beep(11,1,300)
_Beep(3,2,300)
_Beep(6,2,300)
_Beep(11,2,300)
_Beep(3,3,300)
_Beep(9,3,300)
Endfunc

Func _Dsharpminor()
_Beep(2,2,300)
_Beep(7,2,300)
_Beep(12,2,300)
_Beep(5,3,300)
_Beep(8,3,300)
_Beep(2,4,300)
Endfunc

Func _Dsharpmajor()
_Beep(2,2,300)
_Beep(7,2,300)
_Beep(12,2,300)
_Beep(5,3,300)
_Beep(9,3,300)
_Beep(2,4,300)
Endfunc

;A=1
;A#=2
;B=3
;C=4
;C#=5
;D=6
;Eb=7
;E=8
;F=9
;F#=10
;G=11
;G#=12
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Thanks a lot for the script i will try to get use of it when i play on my classic guitar.

Edited by big_daddy
Removed Link

Share this post


Link to post
Share on other sites

Anyway what's wrong with having an A bass in Fmaj7, or an A bass in a D chord? Well I guess it's not so important, but I would include them. It's easier for the right hand to just miss out the sixth string, so it would be easier for a beginner to play the chords. It's just a suggestion. I still think it's a great idea.

I've wondered that too.. I mean an A is part of a D chord..

There's nothing wrong with it. It slighly changes the sounds of the chord. Usually it doesn't matter.

Although sometimes, with certain songs, it just doesn't sound right.

Since the D chord officially uses only 4 strings, I add the A string to give the chord more volume when played after an Em or G.

Share this post


Link to post
Share on other sites

Since the D chord officially uses only 4 strings, I add the A string to give the chord more volume when played after an Em or G.

With particular chord progressions different bass notes work better: Obviously!. e.g. D/A - A7 - D which is far richer in sound than plain old D - A7 - D.

Share this post


Link to post
Share on other sites

cleaned the listview functionality a bit - while cluttering the code equally. Made it a little more user friendly, imho

*is there any way to control the volume of the internal system speaker (the _beep one, not the wav one)?

1) double click on chord name checks/unchecks the item AND displays the chord

2) single right click deselects all items

3) double right click selects all items

4) selecting less than 1 item will cause it to exit

4) selecting a single item loops that item until - stop

5) stop - will select all items and enable the expand button again - (so if start were pressed again all items would loop, otherwise only the previous selection would react to right click when returning to the listview)

#include <Array.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

Opt('GUIResizeMode', 802) 
Global Const $WIDTH = 200, $HEIGHT = 300, $B = 10 
Global Const $EXTRA_HEIGHT = 150  
$n = 28
Global $chordData[$n][5] = [['A major', '1.2|1.3|1.4', 'xo|||o' , '_Amajor' , ''] , ['A major 7', '1.2|1.4', 'xo|o|o' , '_Amajor7', ''], _
['A suspend 2', '1.2|1.3', 'xo||oo' , '_Asus2', ''], ['A suspend 4', '1.2|1.3|2.4', 'xo|||o' , '_Asus4', ''], ['A minor', '1.2|1.3|0.4', 'xo|||o', '_Aminor', ''], _ 
['B flat minor', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|1.4', '||||||' , '_Bflatminor', '']  , ['B flat major', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|2.4', '||||||' , '_Bflatmajor', ''], _ 
['B major', '1.0|1.1|1.2|1.3|1.4|1.5|3.2|3.3|3.4', '||||||' , '_Bmajor', ''] , ['B major 7', '1.1|0.2|1.3|1.5', 'x|||o|', '_Bmajor7', ''] , ['C major', '2.1|1.2|0.4', 'x||o|o' , '_Cmajor', ''], _ 
['C major 7', '2.1|1.2|2.3|0.4', 'x||||o' , '_Cmajor7', ''],  ['C minor', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|3.4', '||||||' , '_Cminor', ''], _ 
['D major', '1.3|2.4|1.5', 'xxo|||' , '_Dmajor', ''],  ['D major 7', '1.3|0.4|1.5', 'xxo|||' , '_Dmajor7', ''],  ['D minor', '1.3|2.4|0.5', 'xxo|||' , '_Dminor', ''], _ 
['D suspend 2', '1.3|2.4', 'xxo||o' , '_Dsus2', ''],  ['D suspend 4', '1.3|2.4|3.5', 'xxo|||', '_Dsus4', ''], ['E major', '1.1|1.2|0.3', 'o||||oo' , '_Emajor', ''], _ 
['E7', '1.1|0.3', 'o|o||oo' , '_Emajor7', ''], ['E minor', '1.1|1.2', 'o||ooo' , '_Eminor', ''], ['E suspend 4', '1.1|1.2|1.3', 'o|||oo' , '_Esus4', ''], _ 
['F major 7', '2.2|1.3|0.4', 'xx|||o' , '_Fmajor7', ''] ,  ['G major', '2.0|1.1|2.4|2.5', '||oo||' , '_Gmajor', ''], _
['G major Barre', '2.0|2.1|2.2|2.3|2.4|2.5|4.1|4.2|3.3', '||||||' , '_GmajorBarre', ''] , ['G minor Barre', '2.0|2.1|2.2|2.3|2.4|2.5|4.1|4.2', '||||||' , '_GminorBarre', ''] , _ 
['G major 7', '2.0|1.1|0.5', '||ooo|' , '_Gmajor7', ''],  ['D sharp minor', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|3.4', '||||||' , '_Dsharpminor', '4'], _
['D sharp major', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|4.4', '||||||' , '_Dsharpmajor', '4']]



Global $listview = -1 
Global $checkedList[UBound($chordData)]     
For $i = 0 to UBound($chordData) - 1         
    $checkedList[$i] = 1     
Next 
Global $currentIndex = -1 
$gui = GUICreate('Chord Practice', $WIDTH + $B * 2, $HEIGHT + $B * 8) 
$chordPic = '56]'  
Global $xOffset = 5 
$chordName = GUICtrlCreateLabel('', $B * 2, $B * 2.5, $WIDTH - $B * 2, 32, $SS_CENTER)
GUICtrlSetFont(-1, 20)   
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)    
GUICtrlSetFont(-1, 20, 500, -1, 'Tahoma') 
Global $lblStrum[6]
For $i = 0 to UBound($lblStrum) - 1    
$lblStrum[$i] = GUICtrlCreateLabel('', 31 - $xOffset + 30 * $i, 53, 20, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))        
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)        
GUICtrlSetFont(-1, 16, 500, -1, 'Tahoma')
Next 
$txtInterval = GUICtrlCreateInput('2', $B, $HEIGHT + $B * 2, 40, 20, $ES_NUMBER) 
GUICtrlCreateUpdown($txtInterval)
GUICtrlCreateLabel('Interval (seconds)', $B + 45, $HEIGHT + $B * 2 +3, 90) 
$startStop = GUICtrlCreateButton('Start', $WIDTH - 40, $HEIGHT + $B * 2, 50, 20)
$btnExpand = GUICtrlCreateButton('>>>', $B, $HEIGHT + $B * 5, $WIDTH, 20) 
$expanded = False 
GUISetState() 

Global $Object = ObjCreate("SAPI.SpVoice")




While 1     
    GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
    Switch GUIGetMsg()        
    Case $GUI_EVENT_CLOSE            
        Exit        
    Case $startStop             
        If GUICtrlRead($startStop) = 'Start' then                
            $int = GUICtrlRead($txtInterval)                
            If $int < 1 then                    
                $int = 1                   
                GUICtrlSetData($txtInterval, $int)            
            EndIf               
            AdlibRegister('_ChangeChordPic', $int * 2000)            
         
            GUICtrlSetState($txtInterval, $GUI_DISABLE)         
            GUICtrlSetState($btnExpand, $GUI_DISABLE)     
            _UpdateCheckedList() 
            
            
            $string = 0
            
            For $i = 0 To UBound($checkedlist) - 1
    $string += $checkedlist[$i]
Next



        If $string < 1 Then  
GUIDelete ($gui)
msgbox (0, '', 'please open again and select 1 or more items')
exit
endif
            If $expanded then
                _Contract() 
                EndIf
GUICtrlSetData($startStop, 'Stop')
                _ChangeChordPic()  
                            Else             
                AdlibUnRegister('_ChangeChordPic')          
            GUICtrlSetData($startStop, 'Start')        
            GUICtrlSetState($txtInterval, $GUI_ENABLE)        
            GUICtrlSetState($btnExpand, $GUI_ENABLE)    
     For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1    
        $checkedList[$i] = 1
If $checkedList[$i] = 1 then         
                _GUICtrlListView_SetItemChecked($listview, $i, True)         
            EndIf
next
         
Endif        
    Case $btnExpand         
        If $expanded then     
            _Contract()        
        Else               
            _Expand()         
        EndIf   
    EndSwitch
WEnd 

Func _ChangeChordPic()   
    Local $index = -1    
    Do        
        $index = Random(0, UBound($checkedlist) - 1, 1)   
    Until $index - 1 <> $currentIndex and $checkedList[$index] = 1  
    $currentIndex = $index
    _SetChord()
    $saychord = StringReplace ($chorddata[$index][0], "A" , "eigh" , 0 , 1)
    $saychord1 = StringReplace ($saychord, "flat" , "phlat")
    $Object.Speak($saychord1, 0)
    call ($chorddata[$index][3])
EndFunc

Func _UpdateCheckedList()  
    For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1       
        If _GUICtrlListView_GetItemChecked($listview, $i)  then         
            $checkedList[$i] = 1   
        Else            
            $checkedList[$i] = 0       
        EndIf    
    Next
EndFunc 

Func _Contract()  
    GUICtrlSetState($listview, $GUI_HIDE)   
    $pos = WinGetPos($gui)   
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] - $EXTRA_HEIGHT)    
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5, $WIDTH, 20)   
    $expanded = False    
    GUICtrlSetData($btnExpand, '>>>')
EndFunc 

Func _Expand()  
    msgbox (0, '' , 'you must select 1 or more items, otherwise program will exit')
    $pos = WinGetPos($gui)  
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] + $EXTRA_HEIGHT)   
    If $listview <> -1 then         
        GUICtrlSetState($listview, $GUI_SHOW)  
    Else      
        $listview = GUICtrlCreateListView('Chord', $B, $HEIGHT + $B * 5, $WIDTH, $EXTRA_HEIGHT)      
        _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES ))   ;$LVS_EX_ONECLICKACTIVATE
        _GUICtrlListView_SetColumnWidth($listview, 0, $WIDTH - 30)        
        For $i = 0 to UBound($chordData) - 1    
            _GUICtrlListView_AddItem($listview, $chordData[$i][0])      
            If $checkedList[$i] = 1 then         
                _GUICtrlListView_SetItemChecked($listview, $i, True)         
            EndIf      
        Next   
    EndIf    
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5 + $EXTRA_HEIGHT + 5, $WIDTH, 20)  
    $expanded = True   
    GUICtrlSetData($btnExpand, '<<<')
    GUICtrlSetState(-1 , $GUI_ENABLE)
EndFunc 

Func _SetChord()   
    GUICtrlDelete($chordPic)   
    $chordPic = GUICtrlCreateGraphic($B, $B, $WIDTH, $HEIGHT)       
    GUICtrlSetBkColor(-1, 0xFFFFFF)      
    GUICtrlSetColor(-1, 0)   
    GUICtrlSetData($chordName, $chordData[$currentIndex][0])    
    $strum = StringSplit($chordData[$currentIndex][2], '')   
    For $i = 0 to UBound($lblStrum) - 1      
        If $strum[$i + 1] = '|' then $strum[$i + 1] = ''      
            GUICtrlSetData($lblStrum[$i], $strum[$i + 1])    
        Next    
        For $i = 1 to 6      
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, $i * 30 - $xOffset, 65, 2, 184)   
        Next    
        GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 65, 150, 2)  
        For $i = 0 to 5      
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 72 + $i * 35, 150, 2) 
        Next        
        $pos = StringSplit($chordData[$currentIndex][1], '|')   
        GUICtrlSetGraphic($chordPic, $GUI_GR_COLOR, 0, 0)  
        GUICtrlCreateLabel ( $chorddata[$currentindex][4], 20 - $xOffset, 88, 10, 13 )
    GUICtrlSetBkColor(-1, 0xFFFFFF)      
    GUICtrlSetColor(-1, 0) 
    GUICtrlSetFont (-1 , '' , 600)
        For $i = 0 to UBound($pos) - 2       
            $stringSplit = StringSplit($pos[$i + 1], '.')      
            GUICtrlSetGraphic($chordPic, $GUI_GR_ELLIPSE, ($stringSplit[2] + 1) * 30 - 15, ($stringSplit[1]) * 35 + 63 + 35/2, 22, 22)   
        Next   
        GUICtrlSetGraphic($chordPic, $GUI_GR_REFRESH)
    EndFunc
    
    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $listview
    If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
            Case $NM_DblClk 
                $currentindex = -1
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                        $CurrentIndex =  _GUICtrlListView_GetHotItem ($hWndlistview)
                        If $CurrentIndex   = -1 Then
                        $CurrentIndex = 0
                    Else
                    If _GUICtrlListView_GetItemChecked($hWndlistview, $CurrentIndex) then
                        _GUICtrlListView_SetItemChecked($hWndlistview, $CurrentIndex, False)
                    Else
                        _GUICtrlListView_SetItemChecked($hWndlistview, $CurrentIndex)
                    endif
                EndIf
                _setchord()
                Case $NM_RCLICK 
                    
                For $i = 0 to _GUICtrlListView_GetItemCount($hWndlistview) - 1   
            If $checkedList[$i] = 1 then         
                _GUICtrlListView_SetItemChecked($listview, $i, False) 
            
            EndIf      
        Next   
                        
                    Case $NM_RDBLCLK 
                        
                        For $i = 0 to $n -1
                        If $checkedlist[$i] = 1 then
                _GUICtrlListView_SetItemChecked($listview, $i, True) 
                Endif
            Next
            
            
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 
    
Func _Beep($iNote,$iOctave=4,$iDuration=200,$iPause=0)
        Global $nTempo=0.8
Global $iTone=-1
    $iFrequency=440*2^(($iNote+$iTone)/12+$iOctave+1/6-4)
    Beep($iFrequency, $iDuration/$nTempo)
    If $iPause<>0 Then Sleep($iPause/$nTempo)
    EndFunc

Func _Amajor()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(5,3,300)
_Beep(8,3,300)
Endfunc

Func _Amajor7()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(11,2,300)
_Beep(5,3,300)
_Beep(8,3,300)
Endfunc

Func _Asus2()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Asus4()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(7,3,300)
_Beep(8,3,300)
Endfunc

Func _Aminor()
_Beep(1,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Bflatminor()
_Beep(9,1,300)
_Beep(2,2,300)
_Beep(9,2,300)
_Beep(2,3,300)
_Beep(5,3,300)
_Beep(9,3,300)
Endfunc

Func _Bflatmajor()
_Beep(9,1,300)
_Beep(2,2,300)
_Beep(9,2,300)
_Beep(2,3,300)
_Beep(6,3,300)
_Beep(9,3,300)
Endfunc

Func _Bmajor()
_Beep(10,1,300)
_Beep(3,2,300)
_Beep(10,2,300)
_Beep(3,3,300)
_Beep(7,3,300)
_Beep(9,3,300)
Endfunc

Func _Bmajor7()
_Beep(3,2,300)
_Beep(7,2,300)
_Beep(1,3,300)
_Beep(3,3,300)
_Beep(10,3,300)
Endfunc

Func _Cmajor()
_Beep(4,2,300)
_Beep(8,2,300)
_Beep(11,2,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Cmajor7()
_Beep(4,2,300)
_Beep(8,2,300)
_Beep(2,3,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Cminor()
_Beep(11,1,300)
_Beep(4,2,300)
_Beep(11,2,300)
_Beep(4,3,300)
_Beep(7,3,300)
_Beep(11,3,300)
Endfunc

Func _Dmajor()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(6,3,300)
_Beep(10,3,300)
Endfunc

Func _Dmajor7()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(10,3,300)
Endfunc

Func _Dminor()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(9,3,300)
Endfunc

Func _Dsus2()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(6,3,300)
_Beep(8,3,300)
Endfunc

Func _Dsus4()
_Beep(6,2,300)
_Beep(1,3,300)
_Beep(6,3,300)
_Beep(12,3,300)
Endfunc

Func _Emajor()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(8,2,300)
_Beep(12,2,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Emajor7()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(6,2,300)
_Beep(12,2,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Eminor()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(8,2,300)
_Beep(11,2,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Esus4()
_Beep(8,1,300)
_Beep(3,2,300)
_Beep(8,2,300)
_Beep(1,3,300)
_Beep(3,3,300)
_Beep(8,3,300)
Endfunc

Func _Fmajor7()
_Beep(9,2,300)
_Beep(1,3,300)
_Beep(4,3,300)
_Beep(8,3,300)
Endfunc

Func _Gmajor()
_Beep(11,1,300)
_Beep(3,2,300)
_Beep(6,2,300)
_Beep(11,2,300)
_Beep(6,3,300)
_Beep(11,3,300)
Endfunc

Func _Gmajor7()
_Beep(11,1,300)
_Beep(3,2,300)
_Beep(6,2,300)
_Beep(11,2,300)
_Beep(3,3,300)
_Beep(9,3,300)
Endfunc

Func _Dsharpminor()
_Beep(2,2,300)
_Beep(7,2,300)
_Beep(12,2,300)
_Beep(5,3,300)
_Beep(8,3,300)
_Beep(2,4,300)
Endfunc

Func _Dsharpmajor()
_Beep(2,2,300)
_Beep(7,2,300)
_Beep(12,2,300)
_Beep(5,3,300)
_Beep(9,3,300)
_Beep(2,4,300)
Endfunc

Func _GmajorBarre()
_Beep(11,1,300)
_Beep(6,2,300)
_Beep(11,2,300)
_Beep(3,3,300)
_Beep(6,3,300)
_Beep(11,3,300)
Endfunc

Func _GminorBarre()
_Beep(11,1,300)
_Beep(6,2,300)
_Beep(11,2,300)
_Beep(2,3,300)
_Beep(6,3,300)
_Beep(11,3,300)
Endfunc

;A=1
;A#=2
;B=3
;C=4
;C#=5
;D=6
;Eb=7
;E=8
;F=9
;F#=10
;G=11
;G#=12

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

cleaned the listview functionality a bit - while cluttering the code equally. Made it a little more user friendly, imho

*is there any way to control the volume of the internal system speaker (the _beep one, not the wav one)?

1) double click on chord name checks/unchecks the item AND displays the chord

2) single right click deselects all items

3) double right click selects all items

4) selecting less than 1 item will cause it to exit

4) selecting a single item loops that item until - stop

5) stop - will select all items and enable the expand button again - (so if start were pressed again all items would loop, otherwise only the previous selection would react to right click when returning to the listview)

code

Hey, I like what you've done with some of this.

1) I thought it already did this.. at least it does for me (because a double-click entails a single click)

2, 3) I'm going to use a little menu.. that way it will be more user friendly

4) I already changed that (not updated in the first post yet).. the way I did I think works a little cleaner because it doesn't exit the program.

5) I don't really see why you would want everything selected when you press stop.. ?

As for the beeps, they don't work on my computer (Win 7, 64bit desktop).. plus I can't say I was ever a huge fan of them.. I mean, my BIOS beeps at me, but I don't want a professional looking program use beeps..

I'm going to do a bit of work on this right now and release the updates in a half an hour or so..


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0