harveyormston / osc_gen Goto Github PK
View Code? Open in Web Editor NEWPython package to create and manage oscillator wavetables
License: GNU General Public License v3.0
Python package to create and manage oscillator wavetables
License: GNU General Public License v3.0
Is it possible to?
For example lets say I create a wavetable with a sine and another wavetable with a sample, can I then morph between these?
`#Variables
wt_size_var = 100
wt_window_var = 2048
wt_output = wavetable.WaveTable(num_waves=wt_size_var)
wt_1 = wavetable.WaveTable(num_waves=wt_size_var)
wt_2 = wavetable.WaveTable(num_waves=wt_size_var)
sig_gen_1 = sig.SigGen()
sig_gen_1.num_points = 2048
cycle_1 = sig_gen_1.sin()
wt_1.waves = [cycle_1 for _ in range(100)]
wt_2 = wavetable.WaveTable().from_wav('key.wav', resynthesize=False)`
From here, take wt_1 and wt_2 and morph them?
Trying to create a cycle size of 2048. The resulting cycle is written as 128.
wt = wavetable.WaveTable(num_waves=100)
sg = sig.SigGen()
sig.num_points = 2048
from numpy.random import uniform
random_wave = uniform(-1, 1, 2048)
wt.waves = [sg.arb(random_wave)]
wavfile.write_wavetable(wt, 'osc_gen_random.wav')
Running the random generation example I get an error.
`from osc_gen import wavetable
from osc_gen import zosc
from osc_gen import sig
from osc_gen import dsp
from random import uniform
sg = sig.SigGen()
wt = wavetable.WaveTable(num_waves=16)
random_wave = (uniform(-1, 1) for _ in range(128))
m = sg.arb(random_wave)
wt.waves = [m]
zosc.write_wavetable(wt,'osc_gen_random.h2p')`
I would like to be able to save the generated wavetable files into another path, in this case a sub directory of the working directory. When the name contains a full path, the script generates an error:
AttributeError: 'Wave_write' object has no attribute '_file'
doesn't work:
output_subdir = 'tables'
output_dir = os.getcwd() + '\' + output_subdir
output_file_name = output_dir + '\' + wt_name + "" + str(wt_window_var) + "w" + str(wt_size_var) + "s_" + str(wt_increment) + '.wav'
works:
output_file_name = wt_name + "" + str(wt_window_var) + "w" + str(wt_size_var) + "s_" + str(wt_increment) + '.wav'
wavfile.write_wavetable(wt_output, output_file_name)
updates should be consistent everywhere to avoid confusion
Hi,
Just pointing out the pip installer is not up to date with the version in the repository.
Would help a lot in ensuring proper cycles
Looking at using this in an application, would be important to know.
I am not 100% sure this is an issue, apologies beforehand if it is not and simply an error in my code but am getting a small glitch.
Noticed that by default if I use the code below without setting phase, the wavetable starts at the lowest point, I would like instead to start at the zero crossing.
Using the code below works as I intend, but I end up with a one sample offset at the end of the wave, see attached screenshot. Each cycle results in what seems to be 2047 samples and not 2048.
`wt_name = 'my_wave.wav'
wt_size = 100
wt_window = 2048
wt = wavetable.WaveTable(num_waves=wt_size)
sig_gen = sig.SigGen()
sig_gen.num_points = wt_window
sig_gen.phase = (2 * np.pi)/4
wt.waves = sig.morph((sig_gen.sin(), sig_gen.tri()), 100)
wavfile.write_wavetable(wt, wt_name)`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.