Old 12-12-2014, 11:30 PM   #1
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default Need to convert "virtual analog" waveform to digital

I think it would be much easier just to ask: Can Resampler in the WDL library be used for variable rate? I have an array of ratios (one that corresponds to every sample of the array holding the waveform) that I want to send it to change and interpolate it to a new array.



Red = my current waveform.
Black = the waveform I need to get to.

The analog waveform is currently held in a vector struct

{length, amplitude}

Each sample has its own length. You could say each sample has its own samplerate... 1/length = samplerate.

Let me explain how I arrived at the "red" (pseudo analog) waveform in the first place. The analog waveform was previously a digital one. I simply took each sample (amplitude value) and stored it in the struct {length, amplitude}. Originally, of course, each length of amplitude was a fixed value of 1/samplerate. Then I simply increased or decreased the length value for every given amplitude in the vector, a.k.a. "variable rate". That being said, maybe I went ahead of myself and I should be doing things differently altogether.

Any suggestions on what API or functions or methods or algorithms or whathaveyou that will help? I know WDL has a resampler... possibly a variable rate resampler? The end result should sound good, so at some point I need some kind of interpolation going on.
Thank you!
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 12-13-2014 at 01:08 PM.
Argitoth is offline   Reply With Quote
Old 01-15-2015, 08:57 PM   #2
kaklaudioparlour
Human being with feelings
 
kaklaudioparlour's Avatar
 
Join Date: Jan 2015
Location: Vancouver
Posts: 3
Default

I don't know about Reasampler, but I imagine it could with some work.

You might want to consider converting your input data into a function that it continuos, so you can sample it like:

Code:
function getSample(x) {

  //Do interpolation here

  return y; 

}
and use interpolation (something better than linear) to fill in the gaps between sample points.

then you can loop over it to populate a fixed rate buffer:

Code:
for(var i; i<buffer_length;++i) {

    buffer[i] = getSample( i * timeStep );
}
If you want to go more deeply into it, the top answer here provides an algorithm to create a perfect reconstruction.

-kakl

The Marauder - Freeware Dynamic Distortion Plugin

Last edited by kaklaudioparlour; 01-15-2015 at 08:58 PM. Reason: sig
kaklaudioparlour is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.