Midi Signale erzeugen

OP #3525390
Lesenswert?

Hallo zusammen,
habe mich jetzt lange mit Midi beschäftigt.
Und mache jetzt so die ersten gehversuche.

Ich habe hier einen Code in Bascom.
Allerdings funktioniert nur PORTD.2.
PORTD.3 geht nicht.

Was ist an meinem Code falsch?
wäre sehr dankbar, wenn ihr mir helfen könntet!!!

Vielen Dank
Gruß
Fabi
1
$regfile = "m8def.dat"                                      ' ATMEGA8
2
$crystal = 1000000                                          ' 1 MHz
3
$baud = 31250                                               ' MIDI-Baudrate (31,25kBit)
4

5
Taster Alias Pind.2
6
Taster1 Alias Pind.3
7

8
Dim Keydown As Byte
9
Dim Keydown1 As Byte                                        ' Tasten-Merker
10

11
Init:
12
  Ddrd.1 = 1                                                ' Sendeleitung auf Output
13
  Portd.2 = 1
14
  Portd.3 = 1                                               ' internen Pull-Up aktivieren für Taster
15

16
Main:
17
  Do
18
    If Taster = 0 Then
19
      If Keydown = 1 Then
20
        Gosub Sendmidinoteon
21
        Keydown = 0
22
      End If
23
    Else
24
      If Keydown = 0 Then
25
        Gosub Sendmidinoteoff
26
        Keydown = 1
27
      End If
28
    End If
29
  Loop
30
  Do
31
    If Taster1 = 0 Then
32
      If Keydown1 = 1 Then
33
        Gosub 1sendmidinoteon
34
        Keydown1 = 0
35
      End If
36
    Else
37
      If Keydown1 = 0 Then
38
        Gosub 1sendmidinoteoff
39
        Keydown1 = 1
40
      End If
41
    End If
42
  Loop
43
  End
44

45
Sendmidinoteon:
46
  Print Chr(&B10010001);                                    ' NOTE-ON-Command
47
  Print Chr(65);                                            ' Tasten-Nummer 69 (A4)
48
  Print Chr(100);                                           ' Key-Down-Velocity 100
49
Return
50

51
Sendmidinoteoff:
52
  Print Chr(&B10000001);                                    ' NOTE-OFF-Command
53
  Print Chr(65);                                            ' Tasten-Nummer 69 (A4)
54
  Print Chr(0);                                             ' Release-Velocity 0 (Default)
55
Return
56
1sendmidinoteon:
57
  Print Chr(&B10010000);                                    ' NOTE-ON-Command
58
  Print Chr(69);                                            ' Tasten-Nummer 69 (A4)
59
  Print Chr(100);                                           ' Key-Down-Velocity 100
60
Return
61

62
1sendmidinoteoff:
63
  Print Chr(&B10000000);                                    ' NOTE-OFF-Command
64
  Print Chr(69);                                            ' Tasten-Nummer 69 (A4)
65
  Print Chr(0);                                             ' Release-Velocity 0 (Default)
66
Return
OP #3525653
Lesenswert?

Hallo,
vielen Dank!
Das war das Problem.

Code:
1
$regfile = "m8def.dat"                                      ' ATMEGA8
2
$crystal = 1000000                                          ' 1 MHz
3
$baud = 31250                                               ' MIDI-Baudrate (31,25kBit)
4

5
Taster Alias Pind.2
6
Taster1 Alias Pind.3
7
Taster2 Alias Pind.4
8
Taster3 Alias Pind.5
9

10
Dim Keydown As Byte
11
Dim Keydown1 As Byte
12
Dim Keydown2 As Byte
13
Dim Keydown3 As Byte                                        ' Tasten-Merker
14

15
Init:
16
  Ddrd.1 = 1                                                ' Sendeleitung auf Output
17
  Portd.2 = 1
18
  Portd.3 = 1
19
  Portd.4 = 1
20
  Portd.5 = 1                                               ' internen Pull-Up aktivieren für Taster
21

22
Main:
23
  Do
24
    If Taster = 0 Then
25
      If Keydown = 1 Then
26
        Gosub Sendmidinoteon
27
        Keydown = 0
28
      End If
29
    Else
30
      If Keydown = 0 Then
31
        Gosub Sendmidinoteoff
32
        Keydown = 1
33
      End If
34
    End If
35

36
    If Taster1 = 0 Then
37
      If Keydown1 = 1 Then
38
        Gosub 1sendmidinoteon
39
        Keydown1 = 0
40
      End If
41
    Else
42
      If Keydown1 = 0 Then
43
        Gosub 1sendmidinoteoff
44
        Keydown1 = 1
45
      End If
46
    End If
47

48
    If Taster2 = 0 Then
49
      If Keydown2 = 1 Then
50
        Gosub 2sendmidinoteon
51
        Keydown2 = 0
52
      End If
53
    Else
54
      If Keydown2 = 0 Then
55
        Gosub 2sendmidinoteoff
56
        Keydown2 = 1
57
      End If
58
    End If
59

60
    If Taster3 = 0 Then
61
      If Keydown3 = 1 Then
62
        Gosub 3sendmidinoteon
63
        Keydown3 = 0
64
      End If
65
    Else
66
      If Keydown3 = 0 Then
67
        Gosub 3sendmidinoteoff
68
        Keydown3 = 1
69
      End If
70
    End If
71

72
  Loop
73
  End
74

75
Sendmidinoteon:
76
  Print Chr(&B10010000);                                    ' NOTE-ON-Command
77
  Print Chr(65);                                            ' Tasten-Nummer 69 (A4)
78
  Print Chr(100);                                           ' Key-Down-Velocity 100
79
Return
80

81
Sendmidinoteoff:
82
  Print Chr(&B10000000);                                    ' NOTE-OFF-Command
83
  Print Chr(65);                                            ' Tasten-Nummer 69 (A4)
84
  Print Chr(0);                                             ' Release-Velocity 0 (Default)
85
Return
86

87
1sendmidinoteon:
88
  Print Chr(&B10010000);                                    ' NOTE-ON-Command
89
  Print Chr(69);                                            ' Tasten-Nummer 69 (A4)
90
  Print Chr(100);                                           ' Key-Down-Velocity 100
91
Return
92

93
1sendmidinoteoff:
94
  Print Chr(&B10000000);                                    ' NOTE-OFF-Command
95
  Print Chr(69);                                            ' Tasten-Nummer 69 (A4)
96
  Print Chr(0);                                             ' Release-Velocity 0 (Default)
97
Return
98

99
2sendmidinoteon:
100
  Print Chr(&B10010000);                                    ' NOTE-ON-Command
101
  Print Chr(72);                                            ' Tasten-Nummer 69 (A4)
102
  Print Chr(100);                                           ' Key-Down-Velocity 100
103
Return
104

105
2sendmidinoteoff:
106
  Print Chr(&B10000000);                                    ' NOTE-OFF-Command
107
  Print Chr(72);                                            ' Tasten-Nummer 69 (A4)
108
  Print Chr(0);                                             ' Release-Velocity 0 (Default)
109
Return
110

111
3sendmidinoteon:
112
  Print Chr(&B10010000);                                    ' NOTE-ON-Command
113
  Print Chr(77);                                            ' Tasten-Nummer 69 (A4)
114
  Print Chr(100);                                           ' Key-Down-Velocity 100
115
Return
116

117
3sendmidinoteoff:
118
  Print Chr(&B10000000);                                    ' NOTE-OFF-Command
119
  Print Chr(77);                                            ' Tasten-Nummer 69 (A4)
120
  Print Chr(0);                                             ' Release-Velocity 0 (Default)
121
Return

Vielen, vielen Dank !!!!

Gruß
Fabi

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren