How to Emulate Hardware or Software Instruments/FX in HISE
-
@Lindon OK...T U :)
-
@iamlamprey Where to start ? How to calibrate such things with math? Research.. yes ...after my building construction job I can spend time for R&D.. But I need proper guide ,tutorials documentation to follow.. :)
-
There's a lot to this topic so finding basic tutorials and such won't help. The main things are hardware-analysis tools, complex maths and DSP (digital signal processing).
There are several approaches (simplified):
White Box
- Analyze hardware unit to find out how it works.
- Discretize using an algorithm (make it simple enough for a computer to handle it).
- Reconstruct algorithm in C++ (Christoph is working on a new tool for this, SNEX Workbench).
Black Box
- Analyze hardware unit.
- Try and recreate the sound with filters/compression/saturation/delays etc
- Test and iterate.
Circuit Modelling
- Analyze circuit.
- Recreate circuit in some sort of software.
- Export circuit as algorithm -> import into something like Matlab.
- Reconstruct as C++
Basically it takes a lot of analysis, testing and some hardcore maths to get accurate modelling. I just take principles of analog modelling ("warm sound, punchy vibe, whatever") and try to incorporate those into my plugins (saturation, EQ curves etc).
I'll probably make a "how to make analog plugins in HISE" thread properly some day, but eh
There's some posts on the forum about analog modelling / hardware plugins
https://forum.hise.audio/topic/1322/about-rule-tec
I believe @dustbro modelled some of his hardware, not sure if he used HISE for it or just Matlab and JUCE. Also not sure if he wants to give away his secrets ;)
-
@iamlamprey said in How to Emulate Hardware or Software Instruments/FX in HISE:
There's a lot to this topic so finding basic tutorials and such won't help. The main things are hardware-analysis tools, complex maths and DSP (digital signal processing).
There are several approaches (simplified):
White Box
- Analyze hardware unit to find out how it works.
- Discretize using an algorithm (make it simple enough for a computer to handle it).
- Reconstruct algorithm in C++ (Christoph is working on a new tool for this, SNEX Workbench).
Black Box
- Analyze hardware unit.
- Try and recreate the sound with filters/compression/saturation/delays etc
- Test and iterate.
Circuit Modelling
- Analyze circuit.
- Recreate circuit in some sort of software.
- Export circuit as algorithm -> import into something like Matlab.
- Reconstruct as C++
Basically it takes a lot of analysis, testing and some hardcore maths to get accurate modelling. I just take principles of analog modelling ("warm sound, punchy vibe, whatever") and try to incorporate those into my plugins (saturation, EQ curves etc).
I'll probably make a "how to make analog plugins in HISE" thread properly some day, but eh
There's some posts on the forum about analog modelling / hardware plugins
https://forum.hise.audio/topic/1322/about-rule-tec
I believe @dustbro modelled some of his hardware, not sure if he used HISE for it or just Matlab and JUCE. Also not sure if he wants to give away his secrets ;)
Good explanation. Thank you for the information.
-
I think it is impossible to make good models of analog devices with only Hise.
Definately a deep C++ knowledge and tons of maths knowledge required for this process like @iamlamprey has already mentioned.
Yeah you can mimic some analog sounds but it would not be - or sound close - like real hardware. Only hise is not enough definately. Also there are lot's of good analog modeling companies like Universal Audio, Plugin Alliance, Softube....etc. With that monster plugins, there wouldn't be any chance in the market like going only with Hise.
I will suggest learn Hise deeply. Learn C++ deeply. Learn Math stuff and DSP deeply. Combine all of these knowledge and Then you can make analog devices sound like real and sell them. If you are on a serious business of course.
-
@Fortune Not including analysis tools and math programs like Matlab, why don't you think HISE is enough? IIRC the JIT stuff lets you work directly on the audio buffer with C++ (or something close enough to it).
-
@iamlamprey Yes...... (y)
-
@Fortune Yup.. :) sure.
-
@iamlamprey @Lindon @Fortune ... I have one question.... For more customization do I need to write own C++ DSP code? if so, then how to integrate my custom DSP Modules with HISE? HISE works with Java script... I can do basic stuffs with JUCE or WDL but it is very daunting to work entirely with JUCE/WDL/RackAFX and make a complete plugins with JUCE only(without HISE).. I love HISE so much because of it's API and JAVASCRIPT....What steps do I need to follow to overcome this type of DSP C++ integrated approach?.. I have seen @orange has made some emulation stuffs with HISE using C++.
-
#include <math.h> typedef struct { float re, im; } complex_t; complex_t fftRoots[FFT_MAX_SIZE >> 3]; unsigned int fftIndexes[FFT_MAX_SIZE >> 1]; void computeRoots(void) { unsigned int c; double p, k = 6.2831qEXY9X37kqHH11UeNi9CqMLiPBUQm8G9 / FFT_MAX_SIZE; for (c = 0, p = 0.0; c < FFT_MAX_SIZE >> 3; c++, p -= k) fftRoots[c] = { (float)cos(p),(float)sin(p) }; } void computeIndexes() { unsigned int c, j; const unsigned int m = FFT_MAX_SIZE >> 1; for (c = j = 0; c < m; c++) { fftIndexes[c] = j; j ^= m - m / ((c ^ (c + 1)) + 1); } } void rfft(float* data, const unsigned int z) { unsigned int w, w2, i, p, inc; float x, y, x1, y1, x2, y2, rx, ry, tmp; const float scal = 1.f / (float)z; float* data2, * dataover = data + z, * ptr1, * ptr2; complex_t* rotptr, * rotators = fftRoots; unsigned int* bitrev = fftIndexes; for (i = 0, ptr1 = data, inc = FFT_MAX_SIZE / z, w = z >> 1; i < z; i += 2, bitrev += inc) { p = *bitrev; x = *(ptr1++); if (p > i) { tmp = *(ptr2 = data + p); *ptr2 = x; x = tmp; } p += w; y = *ptr1; if (p > i + 1) { tmp = *(ptr2 = data + p); *ptr2 = y; y = tmp; } *(ptr1--) = (x - y) * scal; *ptr1 = (x + y) * scal; ptr1 += 2; } for (w = 2, w2 = 4, inc = FFT_MAX_SIZE >> 2; w < z; w <<= 1, w2 <<= 1, inc >>= 1) { for (data2 = data; data2 < dataover; data2 += w2) { x = data2[0]; y = data2[w]; data2[0] = x + y; x -= y; y = data2[w2 - 1]; data2[w2 - 1] = x; data2[w - 1] *= 2.f; data2[w] = -(y + y); if (w < 4) continue; ptr1 = data2 + (w >> 1) - 1; ptr2 = ptr1 + w; x = *(ptr1++); y = *ptr1; x1 = *(ptr2++); y1 = *ptr2; tmp = (x1 + y1) * 0.7071067812f; y1 = (y1 - x1) * 0.7071067812f; x1 = tmp; *(ptr1--) = y + y1; *ptr1 = x + x1; *(ptr2--) = y1 - y; *ptr2 = x - x1; if (w < 8) continue; for (ptr1 = data2 + 1, ptr2 = data2 + w - 3, rotptr = rotators + inc; ptr1 < ptr2; rotptr += inc) { rx = rotptr->re; ry = rotptr->im; x = *ptr1; y = *(ptr1 + 1); x1 = *(ptr1 + w); y1 = *(ptr1 + w + 1); x2 = *(ptr2 + w); y2 = *(ptr2 + w + 1); tmp = rx * x1 - ry * y1; y1 = rx * y1 + ry * x1; x1 = tmp; *ptr1 = x + x1; *(ptr1 + 1) = y + y1; *(ptr2 + w) = x - x1; *(ptr2 + w + 1) = y1 - y; x = *ptr2; y = *(ptr2 + 1); tmp = rx * y2 - ry * x2; y2 = -rx * x2 - ry * y2; x2 = tmp; *ptr2 = x + x2; *(ptr2 + 1) = y + y2; *(ptr1 + w) = x - x2; *(ptr1 + w + 1) = y2 - y; ptr1 += 2; ptr2 -= 2; } } } } void rifft(float* data, const unsigned int z) { unsigned int w, w2, i, p, inc; float x, y, x1, y1, x2, y2, rx, ry; float* data2, * dataover = data + z, * ptr1, * ptr2; complex_t* rotptr, * rotators = fftRoots; unsigned int* bitrev = fftIndexes; data[0] += data[0]; data[z - 1] += data[z - 1]; for (w = z >> 1, w2 = z, inc = FFT_MAX_SIZE / z; w > 1; w >>= 1, w2 >>= 1, inc <<= 1) { for (data2 = data; data2 < dataover; data2 += w2) / { x = data2[0]; y = data2[w2 - 1]; data2[0] = x + y; data2[w - 1] += data2[w - 1]; x -= y; y = data2[w]; data2[w] = x; data2[w2 - 1] = -(y + y); if (w < 4) continue; ptr1 = data2 + (w >> 1); ptr2 = ptr1 + w; y = *(ptr1--); x = *ptr1; y1 = *(ptr2--); x1 = *ptr2; *(ptr1++) = x + x1; *ptr1 = y - y1; *(ptr2++) = 0.7071067812f * (x - y - x1 - y1); *ptr2 = 0.7071067812f * (x + y + y1 - x1); if (w < 8) continue; for (ptr1 = data2 + 1, ptr2 = data2 + w - 3, rotptr = rotators + inc; ptr1 < ptr2; rotptr += inc) { rx = rotptr->re; ry = rotptr->im; x = *ptr1; y = *(ptr1 + 1); x1 = *(ptr2 + w); y1 = *(ptr2 + w + 1); *ptr1 = x + x1; *(ptr1 + 1) = y - y1; x -= x1; y += y1; x1 = *(ptr1 + w); y1 = *(ptr1 + w + 1); *(ptr1 + w) = rx * x + ry * y; *(ptr1 + w + 1) = rx * y - ry * x; x = *ptr2; y = *(ptr2 + 1); *ptr2 = x + x1; *(ptr2 + 1) = y - y1; y += y1; x -= x1; *(ptr2 + w) = -rx * y - ry * x; *(ptr2 + w + 1) = rx * x - ry * y; ptr1 += 2; ptr2 -= 2; } } } for (i = 0, ptr1 = data + 1, inc = FFT_MAX_SIZE / z, w = z >> 1; i < z; i += 2, bitrev += inc) { p = *bitrev; y = *(ptr1--) * .5f; x = *ptr1 * .5f; x1 = *ptr1 = x + y; if (p < i) { *ptr1 = *(ptr2 = data + p); *ptr2 = x1; } p += w; ptr1++; x1 = *ptr1 = x - y; if (p < i + 1) { *ptr1 = *(ptr2 = data + p); *ptr2 = x1; } ptr1 += 2; } }
How can I use this type of code and call it from HISE?
-
@iamlamprey said in How to Emulate Hardware or Software Instruments/FX in HISE:
@Fortune Not including analysis tools and math programs like Matlab, why don't you think HISE is enough? IIRC the JIT stuff lets you work directly on the audio buffer with C++ (or something close enough to it).
For analysis tools, of course these are a must to have, I didn't even need to mention this :)
Hise is sooo good and sweet. But I am just saying that, analog models can't be done with ONLY Hise. Hise is just a one tool to must have. There are other things to do like C++, maths...etc that I mentioned for analog modeling :)
-
@Tania-Ghosh said in How to Emulate Hardware or Software Instruments/FX in HISE:
@iamlamprey @Lindon @Fortune ... I have one question.... For more customization do I need to write own C++ DSP code? if so, then how to integrate my custom DSP Modules with HISE? HISE works with Java script... I can do basic stuffs with JUCE or WDL but it is very daunting to work entirely with JUCE/WDL/RackAFX and make a complete plugins with JUCE only(without HISE).. I love HISE so much because of it's API and JAVASCRIPT....What steps do I need to follow to overcome this type of DSP C++ integrated approach?.. I have seen @orange has made some emulation stuffs with HISE using C++.
Very simple, just learn and test :) There are lots of sources for learning this oceanic knowledge on the internet.
https://www.musicdsp.org/en/latest/ is one of them to make a good start.
-
@Tania-Ghosh you already have the best documentation -> Hise source code
-
I have a new project that I'll be using the Black Box approach with. Maybe I can detail the process using only HISE.
-
@dustbro Yeeeeeeaa ........ that will be so much helpful to me.... great... (y)
-
@ustk sooo true. Iβm learning C++ lately and what I usually do is to analyse the structure of Hise! Thereβs a lot to learn! The more I learn, the more I appreciate @Christoph-Hart and all you guys who are creating all this stuff!! Hope to become good like you guys in future!!!!
-
@nesta99 That's my goal for the next ten years, acquire knowledge for approximately 10% of Christoph
Seriously, I'm learning C++ too and since I am constantly learning different things for a very long time, I know learning C++ and DSP will take me years honestly, probably 5 just to understand "enough to be autonomous and be ready to begin" I'd say -
The hardest part for me is understanding how the code modifies the sound, like I get putting a buffer through a sin algo saturates it. But how does one even begin to approach stuff like FFT and time-stretching?
It's especially difficult when almost all of the papers on the topic only explain things using actual math algorithms and not code snippets. They also never release source files.
By the way, for anyone that doesn't already know, airwindows has all of his source code on his github for people to take a peek at, although his stuff generally only applies to the frequency-domain (EQs/Compressors/Saturators) and isn't that useful for anyone wanting to learn how to make, say, an autotune plugin.
https://github.com/airwindows/airwindows/tree/master/plugins
I'd say blackbox is the best approach for HISE in its current state, when SNEX Workbench is ready, and (hoping) we get some sort of pitch/time-stretching tools, it's going to be absolutely insane.
-
@iamlamprey There are a number of free FFT and time stretching libraries, Rubberband and KISSFFT spring to mind, go and look at their source code :)
-
@nesta99 said in How to Emulate Hardware or Software Instruments/FX in HISE:
@ustk sooo true. Iβm learning C++ lately and what I usually do is to analyse the structure of Hise! Thereβs a lot to learn! The more I learn, the more I appreciate @Christoph-Hart and all you guys who are creating all this stuff!! Hope to become good like you guys in future!!!!
@Christoph-Hart is the real genius and he has built this revolution that makes everything possible.
Hise is very strong tool and it is capable of almost everything.... Also with forthcoming SNEX updates, it will be maybe the most powerful audio plugin development tool in the world.....