Skip to content

Commit

Permalink
Closes #8.
Browse files Browse the repository at this point in the history
  • Loading branch information
james1236 authored Jan 12, 2023
1 parent a3bc248 commit fc92a0f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions buzzer_music.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,28 @@ def tick(self):
i = 0
for pwm in self.pwms:
if (i >= len(self.playingNotes)):
pwm.duty_u16(0)
if hasattr(pwm, 'duty_u16'):
pwm.duty_u16(0)
else:
pwm.duty(0)
else:
#Play note
pwm.duty_u16(self.duty)
if hasattr(pwm, 'duty_u16'):
pwm.duty_u16(self.duty)
else:
pwm.duty(self.duty)
pwm.freq(tones[self.playingNotes[i]])
i = i + 1


#Play arp of all playing notes
if (len(self.playingNotes) > len(self.pwms)):
self.pwms[len(self.pwms)-1].duty_u16(self.duty)
p = self.pwms[len(self.pwms)-1];
if hasattr(p, 'duty_u16'):
p.duty_u16(self.duty)
else:
p.duty(self.duty)

if (self.arpnote > len(self.playingNotes)-len(self.pwms)):
self.arpnote = 0
self.pwms[len(self.pwms)-1].freq(tones[self.playingNotes[self.arpnote+(len(self.pwms)-1)]])
Expand Down

0 comments on commit fc92a0f

Please sign in to comment.