-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiler.py
83 lines (67 loc) · 2.43 KB
/
profiler.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import pygame
from pygame.locals import *
import random
import math
import numpy
import time
import sys
import cProfile
import globs
from globs import *
import crazySynth
from crazySynth import *
import waveform_visualizer
import keyboard
from keyboard import *
import slider
from slider import *
import sequencer
import mixer
import button
from button import *
import clickable_grid
from clickable_grid import *
import synthepyzer_utils
from synthepyzer_utils import *
pygame.mixer.quit()
pygame.mixer.pre_init(sample_rate, -bits, 1)
pygame.init()
# size = (600, 400)
size = (1024, 600)
screen = pygame.display.set_mode(size, pygame.HWSURFACE | pygame.DOUBLEBUF)
fpsClock = pygame.time.Clock()
def main():
megaSynth = crazySynth()
megaSynth.addPiece(whiteNoiseGenerator,0,0,.05)
megaSynth.addPiece(generators.sinGenerator,0,0,1)
megaSynth.addPiece(generators.triangleGenerator,0,0,0)
megaSynth.addPiece(generators.sawtoothGenerator,0,0,1)
megaSynth.addPiece(generators.squareGenerator,0,0,0)
megaSynth1 = crazySynth()
megaSynth1.addPiece(whiteNoiseGenerator,0,0,0)
megaSynth1.addPiece(generators.sinGenerator,0,0,1)
megaSynth1.addPiece(generators.triangleGenerator,0,0,1)
megaSynth1.addPiece(generators.sawtoothGenerator,0,0,0)
megaSynth1.addPiece(generators.squareGenerator,0,0,0)
megaSynth2 = crazySynth()
megaSynth2.addPiece(whiteNoiseGenerator,0,0,0)
megaSynth2.addPiece(generators.sinGenerator,0,0,.5)
megaSynth2.addPiece(generators.triangleGenerator,.5,0,.5)
megaSynth2.addPiece(generators.sawtoothGenerator,0,0,1)
megaSynth2.addPiece(generators.squareGenerator,0,0,.3)
globMixer = mixer.Mixer()
globSequencer = sequencer.Sequencer(80,4)
globMixer.addInstrument(megaSynth,1)
globMixer.addInstrument(megaSynth1,1)
globMixer.addInstrument(megaSynth2,1)
globSequencer.addTrack(globMixer.instruments[0].instrumentID, 32)
globSequencer.addTrack(globMixer.instruments[1].instrumentID, 32)
globSequencer.addTrack(globMixer.instruments[2].instrumentID, 32)
for i in range(40):
note = getNewNoteBySemitones(16.35, 8)*(2**3)
sound = bufferNextFrequency(note,.1,globMixer.instruments[0].generator,100,500,.5)
soundSound = pygame.sndarray.make_sound(sound)
soundSound.play()
cProfile.run('generators = Generators()')
cProfile.run('main()')
pygame.quit()