Ffidlを使ってみる
をテンプレートにして作成
[
Front page
] [
Page list
|
Search
|
Recent changes
|
RSS of recent changes
]
Start:
Ffidlとはdllを直接Tclから呼び出すことのできるライブラリで...
***とりあえず使ってみる [#ea6ee58c]
package require Ffidl
ffidl::callout Beep {uint32 uint32} uint32\
[ffidl::symbol KERNEL32.DLL Beep]
Beep 500 200
ffidl::callout TclCmd名 引数型リスト 返り値型 [ffidl::sy...
のようにしてインターフェースを作るらしい。使える型は[[Ffi...
***せっかくなのでBeepで演奏してみる [#dd52ab31]
Beepだけでは芸がなさすぎるので、Beep音で音楽を流してみる...
package require Ffidl
ffidl::callout Beep {uint32 uint32} uint32\
[ffidl::symbol KERNEL32.DLL Beep]
array set m {
C2 65 C3 131 C4 262 C5 523 C6 1047
C#2 69 C#3 139 C#4 277 C#5 554 C#6 1109
D2 73 D3 147 D4 294 D5 587 D6 1175
D#2 78 D#3 156 D#4 311 D#5 622 D#6 1245
E2 82 E3 165 E4 330 E5 659 E6 1319
F2 87 F3 175 F4 349 F5 698 F6 1397
F#2 92 F#3 185 F#4 370 F#5 740 F#6 1480
G2 98 G3 196 G4 392 G5 784 G6 1568
G#2 104 G#3 208 G#4 415 G#5 831 G#6 1661
A2 110 A3 220 A4 440 A5 880 A6 1760
A#2 117 A#3 233 A#4 466 A#5 932 A#6 1865
B2 123 B3 247 B4 494 B5 988 B6 1976
Q 0
}
array set l {}
set l(1) [expr {1000 * 240 / 70}]
set l(2) [expr {$l(1) / 2}]
set l(4) [expr {$l(1) / 4}]
set l(8) [expr {$l(1) / 8}]
set l(16) [expr {$l(1) / 16}]
set l(1.) [expr {$l(1) * 3 / 2}]
set l(2.) [expr {$l(2) * 3 / 2}]
set l(4.) [expr {$l(4) * 3 / 2}]
set l(8.) [expr {$l(8) * 3 / 2}]
set l(16.) [expr {$l(16) * 3 / 2}]
set l(1..) [expr {$l(1) * 7 / 4}]
set l(2..) [expr {$l(2) * 7 / 4}]
set l(4..) [expr {$l(4) * 7 / 4}]
set l(8..) [expr {$l(8) * 7 / 4}]
set l(16..) [expr {$l(16) * 7 / 4}]
proc play {mlist} {
global m l
foreach {mq lq} $mlist {
if {$m($mq) == 0} {
after $l($lq)
} else {
Beep $m($mq) $l($lq)
}
}
}
play {
G4 16 F4 16
D#4 8. F4 16 D#4 16 Q 16 D#4 8 G4 8 A#4 8
G#4 8 C5 8 D#5 8 D#5 8. Q 16 D5 16 C5 16
A#4 8. G#4 16 G4 8 F4 8. D#4 16 F4 8
G4 2 Q 16 G4 16 F4 16
D#4 8. F4 16 D#4 8 D#4 8 G4 8 A#4 8
G#4 8 C5 8 D#5 8 D#5 8. Q 16 D5 16 C5 16
A#4 8 D#5 8 G4 8 F4 8. D#4 16 F4 16
D#4 2 Q 16 Q 16 A#4 16 G#4 16
G4 8 A#4 8 D#5 8 D#5 4 A#4 16 A#4 16
C5 8 G#4 8 D#5 16 Q 16 D#5 8. Q 16 D5 16 C5 16
A#4 8. G#4 16 G4 8 F4 8. D#4 16 F4 8
G4 2 Q 16 Q 16 G4 16 F4 16
D#4 8. F4 16 D#4 16 Q 16 D#4 8 G4 8 A#4 8
G#4 8 C5 8 D#5 8 D#5 8. Q 16 D5 16 C5 16
A#4 8 D#5 8 G4 8 F4 8. D#4 16 F4 8
D#4 2
}
***コメントをどーぞ [#ae1bc739]
#comment
----
続く・・・
----
[[CategoryTclTk]]
End:
Ffidlとはdllを直接Tclから呼び出すことのできるライブラリで...
***とりあえず使ってみる [#ea6ee58c]
package require Ffidl
ffidl::callout Beep {uint32 uint32} uint32\
[ffidl::symbol KERNEL32.DLL Beep]
Beep 500 200
ffidl::callout TclCmd名 引数型リスト 返り値型 [ffidl::sy...
のようにしてインターフェースを作るらしい。使える型は[[Ffi...
***せっかくなのでBeepで演奏してみる [#dd52ab31]
Beepだけでは芸がなさすぎるので、Beep音で音楽を流してみる...
package require Ffidl
ffidl::callout Beep {uint32 uint32} uint32\
[ffidl::symbol KERNEL32.DLL Beep]
array set m {
C2 65 C3 131 C4 262 C5 523 C6 1047
C#2 69 C#3 139 C#4 277 C#5 554 C#6 1109
D2 73 D3 147 D4 294 D5 587 D6 1175
D#2 78 D#3 156 D#4 311 D#5 622 D#6 1245
E2 82 E3 165 E4 330 E5 659 E6 1319
F2 87 F3 175 F4 349 F5 698 F6 1397
F#2 92 F#3 185 F#4 370 F#5 740 F#6 1480
G2 98 G3 196 G4 392 G5 784 G6 1568
G#2 104 G#3 208 G#4 415 G#5 831 G#6 1661
A2 110 A3 220 A4 440 A5 880 A6 1760
A#2 117 A#3 233 A#4 466 A#5 932 A#6 1865
B2 123 B3 247 B4 494 B5 988 B6 1976
Q 0
}
array set l {}
set l(1) [expr {1000 * 240 / 70}]
set l(2) [expr {$l(1) / 2}]
set l(4) [expr {$l(1) / 4}]
set l(8) [expr {$l(1) / 8}]
set l(16) [expr {$l(1) / 16}]
set l(1.) [expr {$l(1) * 3 / 2}]
set l(2.) [expr {$l(2) * 3 / 2}]
set l(4.) [expr {$l(4) * 3 / 2}]
set l(8.) [expr {$l(8) * 3 / 2}]
set l(16.) [expr {$l(16) * 3 / 2}]
set l(1..) [expr {$l(1) * 7 / 4}]
set l(2..) [expr {$l(2) * 7 / 4}]
set l(4..) [expr {$l(4) * 7 / 4}]
set l(8..) [expr {$l(8) * 7 / 4}]
set l(16..) [expr {$l(16) * 7 / 4}]
proc play {mlist} {
global m l
foreach {mq lq} $mlist {
if {$m($mq) == 0} {
after $l($lq)
} else {
Beep $m($mq) $l($lq)
}
}
}
play {
G4 16 F4 16
D#4 8. F4 16 D#4 16 Q 16 D#4 8 G4 8 A#4 8
G#4 8 C5 8 D#5 8 D#5 8. Q 16 D5 16 C5 16
A#4 8. G#4 16 G4 8 F4 8. D#4 16 F4 8
G4 2 Q 16 G4 16 F4 16
D#4 8. F4 16 D#4 8 D#4 8 G4 8 A#4 8
G#4 8 C5 8 D#5 8 D#5 8. Q 16 D5 16 C5 16
A#4 8 D#5 8 G4 8 F4 8. D#4 16 F4 16
D#4 2 Q 16 Q 16 A#4 16 G#4 16
G4 8 A#4 8 D#5 8 D#5 4 A#4 16 A#4 16
C5 8 G#4 8 D#5 16 Q 16 D#5 8. Q 16 D5 16 C5 16
A#4 8. G#4 16 G4 8 F4 8. D#4 16 F4 8
G4 2 Q 16 Q 16 G4 16 F4 16
D#4 8. F4 16 D#4 16 Q 16 D#4 8 G4 8 A#4 8
G#4 8 C5 8 D#5 8 D#5 8. Q 16 D5 16 C5 16
A#4 8 D#5 8 G4 8 F4 8. D#4 16 F4 8
D#4 2
}
***コメントをどーぞ [#ae1bc739]
#comment
----
続く・・・
----
[[CategoryTclTk]]
Page:
HTML convert time: 0.002 sec.