Skip to main content

Posts

Showing posts with the label numpy

Numeric Javascript

I just recently found this javascript library. So far it's looking pretty good. I've always wanted some sort of Javascript equivalent to NumPy and while this isn't anywhere near that extreme, it does offer some pretty handy features . Here's a jsFiddle I put together to show it performing a simple implementation of PCA (Principle Component Analysis) on a fictional dataset. The first component should have a slope of approximately 0.357 Here's a quick snippet, the actual PCA function using numericjs... function  pca ( X )  {      /*          Return matrix of all principle components as column vectors      */              var  m  =  X . length ;      var  sigma  =  numeric . div ( numeric . dot ( numeric . transpose ( X ) ,  X ) ,  m ) ;      return  numeric . svd ( sigma ) . U ; }

Python musical update

Based on my procedural music project I had been working on here . I've made some improvements. Abstracted the playback some, can now play through numpy, oss, or pyaudio. The plan is to default to the best playback method, right now it just uses the first one that seems available. I did this because I got dozens of complaints about using just pyaudio. Can save audio to wave files, other formats would be nice but are not worth my time right now. It's got a few example files to give some idea of usage, but no documentation. Google code project page is up: http://code.google.com/p/python-musical/ Download link: http://python-musical.googlecode.com/files/python-musical.tar.gz Examples include: arpeggiated chord progression randomly generated lead (with chorus effect) basic example of waveform generating If you want to take a listen without running it, I saved the audio output of examples 1 and 2... Example-01.wav Example-02.wav

My new musical instrument: Python

It's still very young, but here is the library I've been working on for generating music in (nothing but) Python . "test.py" is an example of what you can do. The real purpose isn't to code your music out this way, it's intended as a backend for generating / manipulating music. My end goal is a tab-based editor that plays back with this, but I'm going to keep working on this backend and hope some brave snake wrestler comes along and has the itch to write a proper interface (and if that doesn't happen, I'll start on the interface when I feel satisfied with the backend). The Timeline and Hit classes are just ideas right now. I'm not sure they'll stay in the form they are (I'm thinking a guitar-oriented timeline, holding fret/string/amplitude per hit, is more along the lines of what I need). I'm also on the hunt for efficient numpy/scipy implemented effects and sound sources. I've been playing around some with generating Karplus-S...

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 isin...