COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 01-25-2018, 12:56 PM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default Convert wav to .h (ConvoEngine)

Hello,

Still i can't use convolution plugin.

I found this info...

"Ah OK... You have to copy-paste the the extractor code in a temporary CPP source file (e.g. extract.cpp), compile it, and then run it from the command line, and redirect its output to ir.h (i.e. extract ir.wav > ir.h)."

But i can't do that.

Can you give me some tips?

Thanks.
Tunca is offline   Reply With Quote
Old 01-25-2018, 01:15 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I don't understand at all what you are asking about, can you clarify?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-25-2018, 01:20 PM   #3
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Xenakios View Post
I don't understand at all what you are asking about, can you clarify?
https://forum.cockos.com/showthread....t=convo+engine

I want to convert impulse response to .h file to use with convo engine.I'm doing everything but getting errors.
Tunca is offline   Reply With Quote
Old 01-25-2018, 01:30 PM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Tunca View Post
https://forum.cockos.com/showthread....t=convo+engine

I want to convert impulse response to .h file to use with convo engine.I'm doing everything but getting errors.
Getting errors with what exactly?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-25-2018, 01:40 PM   #5
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Xenakios View Post
Getting errors with what exactly?
I created .cpp file with extractor code in IPlugConvoEngine project and compiled it.Then i opened compiled plugin with command line.Tried to convert my wav to .h but it can't extract .h file.

Did i miss something?
Tunca is offline   Reply With Quote
Old 01-25-2018, 03:24 PM   #6
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Tunca View Post
I created .cpp file with extractor code in IPlugConvoEngine project and compiled it.Then i opened compiled plugin with command line.Tried to convert my wav to .h but it can't extract .h file.

Did i miss something?
Yeah, you should create a separate CPP file (e.g. extract.cpp), and then just compile it from the command line (no need to add it to your plug-in project) i.e.:

Code:
Windows:
cl extract.cpp
extract.exe my_ir.wav > my_ir.h

macOS:
g++ -o extract extract.cpp
./extract my_ir.wav > my_ir.h
BTW, I guess I should update the extractor/convertor code to use my WaveReader class, so it will support non 32-bit floating-point WAV files.
Tale is offline   Reply With Quote
Old 01-26-2018, 02:17 AM   #7
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
Yeah, you should create a separate CPP file (e.g. extract.cpp), and then just compile it from the command line (no need to add it to your plug-in project) i.e.:

Code:
Windows:
cl extract.cpp
extract.exe my_ir.wav > my_ir.h

macOS:
g++ -o extract extract.cpp
./extract my_ir.wav > my_ir.h
BTW, I guess I should update the extractor/convertor code to use my WaveReader class, so it will support non 32-bit floating-point WAV files.
Thanks!

But still i'm doing something wrong...

I'm creating extract.cpp and compiling with command line with "g++ -o extract extract.cpp".

And then i'm using "./extract my_ir.wav > my_ir.h" to convert wav.But there is no any file.

What i'm doing wrong?

EDIT

I used only this code "/extract my_ir.wav" and it gave me values.But when i use "/extract my_ir.wav > my_ir.h" it can't export ir.h file.

Last edited by Tunca; 01-26-2018 at 02:28 AM.
Tunca is offline   Reply With Quote
Old 01-26-2018, 02:26 AM   #8
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Tunca View Post

What i'm doing wrong?
The wav to text converter doesn't have any error handling, so it's probably just silently failing on you for some reason.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-26-2018, 02:28 AM   #9
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Xenakios View Post
The wav to text converter doesn't have any error handling, so it's probably just silently failing on you for some reason.
EDIT

I used only this code "/extract my_ir.wav" and it gave me values.But when i use "/extract my_ir.wav > my_ir.h" it can't export ir.h file.
Tunca is offline   Reply With Quote
Old 01-26-2018, 02:32 AM   #10
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Oh!

Finally i converted to ir.h file!

Thanks!

But i have another problem now.

I'm seeing "nanf".

What should i do?
Tunca is offline   Reply With Quote
Old 01-26-2018, 02:41 AM   #11
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Code:
-1.10919050e-16f,
-4.09825543e-17f,
nanf,
3.12016401e-02f,
1.11114186e+36f,
nanf,
-1.58188340e+29f,
3.63949725e+29f,
-2.73374409e+38f,
1.30644203e+05f,
As you can see there is nanf...
Tunca is offline   Reply With Quote
Old 01-26-2018, 03:20 AM   #12
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

"NaN" stands for "not a number", so I guess your WAV file might not be 32-bit float, or maybe it has some additional chunks that mess up things (because the convertor code is *really* simple, so it only works for 32-bit float WAV files with no additional chunks).

Like I said earlier, I should really rewrite this using my WaveReader class, so it supports other WAV formats as well.
Tale is offline   Reply With Quote
Old 01-26-2018, 06:13 AM   #13
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
"NaN" stands for "not a number", so I guess your WAV file might not be 32-bit float, or maybe it has some additional chunks that mess up things (because the convertor code is *really* simple, so it only works for 32-bit float WAV files with no additional chunks).

Like I said earlier, I should really rewrite this using my WaveReader class, so it supports other WAV formats as well.
I tried 32-bit float but no luck.Still getting NaN.

What do you mean with "chunks"?
Tunca is offline   Reply With Quote
Old 01-26-2018, 06:15 AM   #14
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

FWIW, here is an improved version:

https://github.com/TaleTN/ir2h
Tale is offline   Reply With Quote
Old 01-26-2018, 06:17 AM   #15
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Tunca View Post
I tried 32-bit float but no luck.Still getting NaN.
You could try my updated version.

Quote:
Originally Posted by Tunca View Post
What do you mean with "chunks"?
A WAV file can hold extra info, e.g. markers etc. My simple convertor doesn't support this at all, but the newer version should automatically skip them (I think).
Tale is offline   Reply With Quote
Old 01-26-2018, 06:32 AM   #16
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
FWIW, here is an improved version:

https://github.com/TaleTN/ir2h
Thanks!

I just tried but got some issues.

Getting this error while making.

Code:
make: *** No rule to make target `ir2h.cpp', needed by `ir2h'.  Stop.
Tunca is offline   Reply With Quote
Old 01-26-2018, 06:42 AM   #17
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Sounds like you are missing ir2h.cpp...
Tale is offline   Reply With Quote
Old 01-26-2018, 06:52 AM   #18
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
Sounds like you are missing ir2h.cpp...
It's there but i tried your "how to...".No luck...

I didn't understand new one.Now older one working correctly.But i will figure new one out.

Also any tip to use multiple IR with convoengine?
Tunca is offline   Reply With Quote
Old 01-26-2018, 06:55 AM   #19
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Tunca View Post
It's there but i tried your "how to...".No luck...

I didn't understand new one.Now older one working correctly.But i will figure new one out.
Well, not important if you got the old one up and running I guess... But maybe you were running make from outside the directory where ir2h.cpp and Makefile.gcc are?

Quote:
Originally Posted by Tunca View Post
Also any tip to use multiple IR with convoengine?
Do you mean multi-channel, or switching between different IRs?
Tale is offline   Reply With Quote
Old 01-26-2018, 07:00 AM   #20
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
Well, not important if you got the old one up and running I guess... But maybe you were running make from outside the directory where ir2h.cpp and Makefile.gcc are?


Do you mean multi-channel, or switching between different IRs?
I guess i did something wrong while running make.I will check this to night.Thank you so much for new version!

I mean switching between different IRs.
Tunca is offline   Reply With Quote
Old 01-26-2018, 07:07 AM   #21
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Tunca View Post
I mean switching between different IRs.
Well, what I typically do is prepare multiple WDL_ImpulseBuffers, and then switch between them using WDL_ConvolutionEngine::SetImpulse(). I guess a nicer option would be to crossfade between two WDL_ConvolutionEngines, but then you would have to temporarily run two of them, which can be rather heavy on CPU.
Tale is offline   Reply With Quote
Old 01-26-2018, 07:54 AM   #22
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
Well, what I typically do is prepare multiple WDL_ImpulseBuffers, and then switch between them using WDL_ConvolutionEngine::SetImpulse(). I guess a nicer option would be to crossfade between two WDL_ConvolutionEngines, but then you would have to temporarily run two of them, which can be rather heavy on CPU.
As i can see,we are including ir.h file.

Can we select it with basic if/else function?

Like this;

Code:
      if (mSel == 0)
         IR = #include "ir1.h";
      else if (mSel == 1) 
         IR = #include "ir2.h";
Am i idiot?
Tunca is offline   Reply With Quote
Old 01-26-2018, 09:01 AM   #23
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

More something like this i.e. include both IRs during compile time:

Code:
static const int len = 1024;

static const float ir1[ir_len] =
{
	#include "ir1.h"
};

static const float ir2[ir_len] =
{
	#include "ir2.h"
};
And then select ir1/ir2 on runtime.

EDIT: Assuming same length here for simplicity's sake, but they don't have to be.

Quote:
Originally Posted by Tunca View Post
Am i idiot?
No comment...
Tale is offline   Reply With Quote
Old 01-26-2018, 09:13 AM   #24
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Tale View Post
More something like this i.e. include both IRs during compile time:

Code:
static const int len = 1024;

static const float ir1[ir_len] =
{
	#include "ir1.h"
};

static const float ir2[ir_len] =
{
	#include "ir2.h"
};
And then select ir1/ir2 on runtime.

EDIT: Assuming same length here for simplicity's sake, but they don't have to be.


No comment...
Thanks for reply.

I added both IRs but i can't switch. mIR and mIR1

Now playing with this.I believe i can switch IRs in here.What do you thing?

I need to add if/else function to switch IRs between mIR and mIR1.

Code:
void IPlugConvoEngine::Reset()
{
	TRACE; IMutexLock lock(this);

	// Detect a change in sample rate.
	if (GetSampleRate() != mSampleRate)
	{
		mSampleRate = GetSampleRate();

    


		const int irLength = sizeof(mIR) / sizeof(mIR[0]);
		const double irSampleRate = 44100.;
		mImpulse.SetNumChannels(1);

		#if defined(_USE_WDL_RESAMPLER)
			mResampler.SetMode(false, 0, true); // Sinc, default size
			mResampler.SetFeedMode(true); // Input driven
		#elif defined(_USE_R8BRAIN)
			if (mResampler) delete mResampler;
			mResampler = new CDSPResampler16IR(irSampleRate, mSampleRate, mBlockLength);
		#endif

		// Resample the impulse response.
		int len = mImpulse.SetLength(ResampleLength(irLength, irSampleRate, mSampleRate));
		if (len) Resample(mIR, irLength, irSampleRate, mImpulse.impulses[0].Get(), len, mSampleRate);

		// Tie the impulse response to the convolution engine.
		mEngine.SetImpulse(&mImpulse);
	}
}
Tunca is offline   Reply With Quote
Old 02-02-2018, 02:54 AM   #25
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

You will probably want to resample both IRs, and keep them around. Then you do either

Code:
mEngine.SetImpulse(&mImpulse1);
or

Code:
mEngine.SetImpulse(&mImpulse2);
to select IR 1 or 2.
Tale 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 04:41 AM.


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