Пример #1
0
def play(inst, songs, bPerM):
    pygame.mixer.init(48000, -16, 2, 1024)
    if inst == 0:
        import pysynth_b
        s0 = setSong(songs[0])
        s1 = setSong(songs[1])
        pysynth_b.make_wav(s0, fn="s0.wav", bpm=bPerM)
        pysynth_b.make_wav(s1, fn="s1.wav", bpm=bPerM)
        pygame.mixer.Channel(0).play(pygame.mixer.Sound('s0.wav'))
        pygame.mixer.Channel(1).play(pygame.mixer.Sound('s1.wav'))
        screen = pygame.display.set_mode((100, 100), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
        pygame.display.update()
    elif inst == 1:
        import pysynth_s
        s0 = setSong(songs[0])
        pysynth_s.make_wav(s0, fn="s0.wav", bpm=bPerM)
        pygame.mixer.Channel(0).play(pygame.mixer.Sound('s0.wav'))
        screen = pygame.display.set_mode((100, 100), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
        pygame.display.update()
    elif inst == 2:
        import pysynth_c
        s0 = setSong(songs[0])
        pysynth_c.make_wav(s0, fn="s0.wav", bpm=bPerM)
        pygame.mixer.Channel(0).play(pygame.mixer.Sound('s0.wav'))
        screen = pygame.display.set_mode((100, 100), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
        pygame.display.update()
Пример #2
0
 def create(self):
     notes = self.improvise()
     if self.instrument == "Piano":
         pysynth_b.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Plucked":
         pysynth_s.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Sawtooth":
         pysynth_c.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Square":
         pysynth_d.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Rhodes":
         pysynth_e.make_wav(notes, fn=self.filename, bpm=self.tempo)
Пример #3
0
 def create(self, oid):
     notes = self.improvise()
     filename = "wav/" + str(oid) + ".wav"
     if self.instrument == "Plucked":
         pysynth_s.make_wav(notes, fn=filename, bpm=self.tempo)
     elif self.instrument == "Sawtooth":
         pysynth_c.make_wav(notes, fn=filename, bpm=self.tempo)
     elif self.instrument == "Square":
         pysynth_d.make_wav(notes, fn=filename, bpm=self.tempo)
     elif self.instrument == "Rhodes":
         pysynth_e.make_wav(notes, fn=filename, bpm=self.tempo)
     else:
         pysynth_b.make_wav(notes, fn=filename, bpm=self.tempo)
     return oid
Пример #4
0
import pysynth_s as s  # ...

song = (('g', -8), ('e', 16), ('c', 4), ('e', 4), ('g', 4), ('c5', 2),
        ('e5', -8), ('d5', 16), ('c5', 4), ('e', 4), ('f#', 4), ('g', 2),
        ('g', 8), ('g', 8), ('e5', -4), ('d5', 8), ('c5', 4), ('b', 2),
        ('a', -8), ('b', 16), ('c5', 4), ('c5', 4), ('g', 4), ('e', 4), ('c',
                                                                         4))

# if you go to the website it has more full descriptions of all the synths and what they are made to represent.

#synth a (default, piano-ish)
a.make_wav(song, fn='a.wav')

# synth b (slighly more accurate piano)
b.make_wav(song, fn='b.wav')

# synth c (made to emulate bowed string (violin, cello, etc.))
c.make_wav(song, fn='c.wav')

# synth d (subtractive synth, woodwind (flute, clarinet etc.))
d.make_wav(song, fn='d.wav')

# synth e (takes significantly longer than the other to process, made to emulate electric piano)
e.make_wav(song, fn='e.wav')

# synth p (a percussion synth, no pitch, made to emulate drum. Probably wouldn't be used in our project.)
p.make_wav(song, fn='p.wav')

# synth s (made to emulate plucked strings, (guitar, ukelele)
s.make_wav(song, fn='s.wav')