### Procedural music with PyAudio and NumPy

Combining two of my favorite pastimes, programming and music... This is the hacky "reduced to it's basic components" version of a library I've been working on for generating music and dealing with music theory.

Tweaking the harmonics by changing the shape of the harmonic components and ratios can produce some interesting sounds. This one only uses sine waveforms, but a square / saw generator is trivial with numpy.

It takes a second to generate, so don't turn your volume up too loud in anticipation (it may be loud).

import math

import numpy

import pyaudio

import itertools

from scipy import interpolate

from operator import itemgetter

class Note:

NOTES = ['c','c#','d','d#','e','f','f#','g','g#','a','a#','b']

def __init__(self, note, octave=4):

self.octave = octave

if isinstance(note, int):

self.index = note

self.note = Note.NOTES[note]

elif isinstance(note, st…

Tweaking the harmonics by changing the shape of the harmonic components and ratios can produce some interesting sounds. This one only uses sine waveforms, but a square / saw generator is trivial with numpy.

It takes a second to generate, so don't turn your volume up too loud in anticipation (it may be loud).

import math

import numpy

import pyaudio

import itertools

from scipy import interpolate

from operator import itemgetter

class Note:

NOTES = ['c','c#','d','d#','e','f','f#','g','g#','a','a#','b']

def __init__(self, note, octave=4):

self.octave = octave

if isinstance(note, int):

self.index = note

self.note = Note.NOTES[note]

elif isinstance(note, st…

## Comments

@TheDogeFan they're mostly used for hosting small services but I've also used them for testing network code (or stress testing other servers I'm working on).