1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Private Sub Fenetre_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long, f As Long, ech As Byte, ech2 As Echantillon
Dim v As Single, vgd As Long
Const Pi As Single = 3.14159265
Const PY As Single = 2 * Pi / 44100
If Timer1.Enabled Then Exit Sub
If Not ouvert Then
MsgBox "Ouvrez d'abord une voie !"
Exit Sub
End If
If Button = vbLeftButton Then ' Bouton gauche : émettre un son
' mot de volume
v = 65535 * (y / PMa)
vgd = single2vol(v, adroite, agauche)
' table des échantillons
f = 10 ^ x
For i = 0 To 44099
ech = 128 + 127 * Sin((PY * f) * i)
Ech2Wave ech, ech2
Wave(i) = ech2
Next
If Shift = vbShiftMask Then ' shift=>dump de la table des échantillons
With Fdump.Dump
For i = 0 To 4096
.AddItem Right("0000" & Hex(i), 3) & " " & Right("00" & Hex(Wave(i).Gauche), 2) & " " & Right("00" & Hex(Wave(i).Droite), 2)
Next
End With
Fdump.Visible = True
ElseIf Shift = vbCtrlMask Then ' ctrl=> dump du mot de volume
Fdump.Entrée.Text = "Y= " & Format(y) & ", v = " & Format(v)
Fdump.Sortie.Text = "Volume= " & Right("00000000" & Hex(vgd), 8)
Fdump.Visible = True
ElseIf Shift = vbAltMask Then ' Alt=> témoin fréquence et volume
Témoin.Text = "Fréquence=" & Format(10 ^ x, "#") & vbCrLf & "Puissance=" & Hex(vg)
Témoin.Visible = True
Témoin.Top = y
Témoin.Left = x
Else
Timer1.Enabled = True
Command1.BackColor = vbRed
Joue vgd
End If
Else ' Autre bouton (droit)
If Shift = 0 Then ' bouton droit seul : son entendu
croix x, y, vbGreen
Else ' bouton droit + shift : son pas entendu
croix x, y, vbRed
End If
End If
End Sub |
Partager