'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1 As Button
Dim Button2 As Button
Dim EditText1 As EditText
Dim ProgressBar1 As ProgressBar
Dim notennames(15) As String
Dim Frequenz As Double
Dim Label1 As Label
Dim Tim As Timer
Dim direction As Boolean
Dim Increment As Float
ProgressBar1.Initialize(ProgressBar1)
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Notennamen")
EditText1.Text="440"
Label1.Text="A"
Frequenz=440
ProgressBar1.Progress=50
notennames(1)="A"
notennames(2)="A#"
notennames(3)="H"
notennames(4)="C"
notennames(5)="C#"
notennames(6)="D"
notennames(7)="D#"
notennames(8)="E"
notennames(9)="F"
notennames(10)="F#"
notennames(11)="G"
notennames(12)="G#"
notennames(13)="A"
notennames(14)="A#"
If FirstTime Then
Tim.Initialize("Tim",50)
End If
direction=True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Tim.Enabled=False
Tim.Interval=50
End Sub
Sub Notenname(Freq As Double) As String
'Dim namenindex As Int
Dim findex As Int
Dim fff As Double
Dim zwwert As Double
Dim Notennamet As String
Dim intwert As Int
Notennamet = ""
Increment = Power(10,(0.4343*Logarithm(Freq,2.7182818)))/1000
fff = ff(Freq)
zwwert = (fff Mod 12) + 0.5
intwert=(zwwert*100) Mod 100
ProgressBar1.Progress=intwert
findex = Round2((fff Mod 12),0)
If findex >= 0 Then
Notennamet = notennames(findex+1)
End If
Return Notennamet
End Sub
Sub Rundung(Wert As Double) As Int
If Frequenz<10000 Then
Return 5-Logarithm(Frequenz,10)
Else
Return 0
End If
End Sub
Sub ff(Freq As Double) As Double
Dim Testfrequenz As Double
Dim dd As Double
Testfrequenz= 6.875
dd = ((12.0 * Logarithm(Freq,10.0)) / Logarithm(2.0,10.0)) - ((12.0 * Logarithm(Testfrequenz,10.0)) / Logarithm(2.0,10.0))
Return dd
End Sub
Sub EditText1_TextChanged (Old As String, New As String)
Dim nn As String
If IsNumber( EditText1.Text) Then
Frequenz=New
nn=Notenname(New)
Label1.Text = nn
End If
End Sub
Sub Button2_Down
Frequenz=Frequenz-Increment
EditText1.Text=Round2(Frequenz,Rundung(Frequenz))
direction=False
End Sub
Sub Button2_up
Tim.Enabled=False
End Sub
Sub Button1_up
Tim.Enabled=False
End Sub
Sub Button1_Down
Frequenz=Frequenz+Increment
EditText1.Text=Round2(Frequenz,Rundung(Frequenz))
direction=True
End Sub
Sub Button2_LongClick
Tim.Enabled=True
direction=False
End Sub
Sub Button1_LongClick
Tim.Enabled=True
direction=True
End Sub
Sub Tim_Tick
If Frequenz>0 AND Increment>0 Then
If direction Then
Frequenz=Frequenz+Increment
EditText1.Text=Round2(Frequenz,Rundung(Frequenz))
Else
Frequenz=Frequenz-Increment
EditText1.Text=Round2(Frequenz,Rundung(Frequenz))
End If
End If
End Sub