Wavetable | A Rust library for wavetable handling
kandi X-RAY | Wavetable Summary
kandi X-RAY | Wavetable Summary
This is a library for generating and using wavetables. It is currently used in the Yazz software synthesizer. The library offers support for importing wavetables from wave files, bandlimiting the tables to avoid aliasing, storing tables in a compressed format and getting samples from the tables. While functional, this is not yet in a very useful state. The code is currently being reworked into a library and needs a lot of refactoring, testing and optimization. There is not much documentation yet, and some features are still missing.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Wavetable
Wavetable Key Features
Wavetable Examples and Code Snippets
Community Discussions
Trending Discussions on Wavetable
QUESTION
I've such a code:
...ANSWER
Answered 2021-Apr-13 at 20:45Your code is not too efficient for multiple reasons.
You’re setting individual lanes of SIMD vectors with scalar code. Processors can’t quite do that, but the compiler pretends they can. Unfortunately, these compiler-implemented workarounds are slow, typically they do that with a rountrip to memory and back.
Generally, you should avoid writing loops of very small lengths of 2 or 4. Sometimes compiler unrolls and you’re OK, but other time they don’t and the CPU is mispredicting way too many branches.
Finally, processors can load 64-bit values with a single instruction. You’re loading consecutive pairs from the table, can use 64-bit loads instead of two 32-bit ones.
Here’s a fixed version (untested). This assumes you’re building for PCs i.e. using SSE SIMD.
QUESTION
For context, I'm working in c++ on a stm32f ucontroller doing embedded audio and trying to avoid dynamic allocation.
One of the classes I've written is a wavetable oscillator that is, for the scope of my question, essentially just a bunch of c-style arrays.
I have these files, among others, in a separate folder from the specific project that is using them so I can reuse them across projects with no rewriting or copy/pasting.
The values that fill the arrays are calculated during an initialization routine rather than being hardcoded so that, if I change the "#define tableLength 256" statement at the top that sets the size of the arrays from 256 to some other value, the waveforms will be recalculated properly the next time I compile and flash the program onto the chip.
Since I'm working with limited memory resources, some programs that use this wavetable oscillator may necessitate that these tables be of a smaller size.
Is there a way of specifying the size of these arrays from a given project's main program file so that nothing needs to be changed in the shared wavetable oscillator file?
I'm still pretty early into my programming journey, but my intuition tells me there must be some sort of mechanism to accomplish this since the size of the arrays will still be known at compile time?
I'm trying to avoid changing the array size directly in the shared file, because any file that gets modified since the last flashing gets recompiled during the flashing process.
This means I would have to remember to change the value every time I needed to flash a different product or work on a different project.
For further context, I'm building and uploading the programs using a makefile.
My knowledge of using them is very minimal, so maybe there's a way to specify the size to be used for the arrays from the project's makefile?
Thanks for the help.
...ANSWER
Answered 2020-Dec-18 at 01:26Since you include the c++
tag in your question and c++
language includes templates, then you can parametrize the size of a static array declared in another file from a MAIN.cpp file like this:
In MYCLASS.cpp (declared in MYCLASS.h)
QUESTION
I referenced the Pygame MIDI documentation and this code to try to get MIDI input to work. The MIDI Interface (Avid Eleven Rack) receives MIDI data from my MIDI controller just fine in my audio software (Pro Tools). Using Pygame, however, I can not seem to read any information at all.
Source Code ...ANSWER
Answered 2020-Nov-20 at 16:04I got an answer in another forum. It turns out that there is an example file which shows how to get the code to work. So if someone else stumbles over this problem here is the useful part of example code:
QUESTION
I've been using math equations to do some basic synthesis for android. The problem with that the formulas keep and keep getting more complicated. So i'm starting to use wavetable synthesis.
So far i can play a single note based on an array of bytes and a predetermined frequency. However when looking for formulas to resample the samples and change the pitch of the wavetable... i just couldn't find a simple solution. There are whole libraries that do this. But it feels like it should be a simple formula to change the sample frequency by downsampling or oversampling.
Is there an easy way of doing that?
Ex: Input is [0,0.5,1,0.5,0...]
let's pretend it's a C4
To make it a C3 the expected output should be [0,0.25,0.5,0.75,1,0.75,0.5,0.25,0...]
Basically it's and android's audiopool "rate" property but just the formula that resamples the bytes, which i haven't found anywhere
EDIT:
Thank you to Phil Freihofner for guiding me to the answer. However the original formula he provided didn't smoothed out the end in case of oversampling. But it was a really nice start and i only had to smooth the end. I will attach my end code in case anyone wants a simple function to "Stretch out" a float array.
...ANSWER
Answered 2020-Oct-19 at 19:07Let's say you have a wave table in floats.
What you can then do is create a "cursor" to iterate through the table. This cursor does NOT have to be an integer, it can be a float. When your cursor lands on a value that is in between two elements your wave table, you can use linear interpolation to calculate a "good enough" value to return.
Consider the first wave table the have. It plays C4 when you use a cursor with an increment of 1. If you make the increment 0.5 and use linear interpolation, the values that you would be returning would be the same as contents of your table that is an octave lower.
But you could chose any increment value, and even change it over time (to get glissandos).
The exact size of the increment for the cursor will depend on the size of the wave table and the sample rate as well as the desired pitch.
I am using wavetables for an FM synthesizer I coded. The sine wave table has 1024 increments for a single wave, float resolution. It seems to be working well. Sounds are quite clear--definitely less quantization noise than I get with my old Yamaha DX7 or the second generation DX7S.
Here is the code I'm currently using for returning the wave table value for a given cursor value, using linear interpolation:
QUESTION
Trying to do some basic wavetable synthesis (developing an addon for p5.sound) – and wondering if it's possible to dynamically change the waveform of an oscillator while it's playing (constant tone rather than note duration)? In my basic testing, the setPeriodicWave()
function has to be called before the oscillator is connected to the AudioContext output then started. Hoping to do some dynamic wavetable synth (with two hard panned channels) for feeding into the X-Y mode of an oscilloscope (for vector visuals based on audio signals). The workflow above, constantly creating a new oscillator with every wavetable change, causes lots of artifacts and phase-shifting issues... it would be great if I could start two oscillators and just update their waveform. Any tips on workflow for doing so? My abstracted workflow:
- create oscillator with 'custom' type (inited with a flat/silent wave)
- custom
setWavetable()
which uses functions from dsp.js tocreatePeriodicWave()
with array values - re-init oscillator with this wave (stop oscil, disconnect/trash oscil, init new oscil w/ wave, connect + start oscil)
ANSWER
Answered 2020-Jul-10 at 15:01What issues are you having? As an example, this works for me. I can clearly hear the sound change:
QUESTION
My program has 30 duplicate symbols errors for the methods length()
and table()
from the struct
below.
This struct can be instantiated in four ways. Each of them is identical but for the table each instantiation refers to and, potentially, the length of that table.
This needs to be known at compile time in order that I can construct an array in the following fashion.
std::array, N> oscillators;
.
Could someone please help me to see my error?
...ANSWER
Answered 2020-May-10 at 07:35Fully specialized template functions in a header file should be declared inline
QUESTION
I'm currently working on a very basic wavetable synthesizer. I'll try my best to give an understandable overview.
I have a single lookup-waveform with 4096 points, which is sampled by the audio thread. In general, however, a single oscillator has multiple waveforms, which can be morphed by a position
parameter. For example, let's take two sine waves where the second one has half the period of the first one. When we play those back at frequency = 440Hz
and position = 0.5
, we would hear two equally loud tones at 440Hz and 880Hz. Here's a link to the audio (See Sidenote 2).
Due to performance reasons I generate the lookup table on another thread whenever the position parameter changes. And therein lies my problem. Even when I don't change the table position and just periodically generate my lookup table, I get weird, unpredictable glitches. Since the audio data in the table doesn't change in this case, I can only explain this by torn reads. Is that correct? And if so, how do I get around it? Do I use a double-buffer with an atomic pointer-swap after I finish generating the data?
Again, here's the audio for this recording (See Sidenote 2). Also, some oscilloscope data:
Sidenote 1: Populating my lookup table takes ~50,000ns
without optimizations and ~10,000ns
with optimizations. But the glitches seem to happen with the same probability.
Sidenote 2: The website I uploaded the audio to seems to have introduced some weird harmonics, which are not audible in my video. Just so you know.
...ANSWER
Answered 2020-Mar-18 at 18:23Found it! I accidentally set an old scanner position after generating my lookup table. If the latter took too long my position was basically reset to a few microseconds earlier, which explains the visual setback in the oscilloscope.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Wavetable
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page