Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
eed5e3aa
Commit
eed5e3aa
authored
Oct 26, 2022
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update verblib.
parent
bec0aa74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
22 deletions
+98
-22
extras/nodes/ma_reverb_node/verblib.h
extras/nodes/ma_reverb_node/verblib.h
+98
-22
No files found.
extras/nodes/ma_reverb_node/verblib.h
View file @
eed5e3aa
/* Reverb Library
/* Reverb Library
* Verblib version 0.
4 - 2021-01-23
* Verblib version 0.
5 - 2022-10-25
*
*
* Philip Bennefall - philip@blastbay.com
* Philip Bennefall - philip@blastbay.com
*
*
...
@@ -87,6 +87,14 @@ extern "C" {
...
@@ -87,6 +87,14 @@ extern "C" {
/* Get the volume of the dry signal. */
/* Get the volume of the dry signal. */
float
verblib_get_dry
(
const
verblib
*
verb
);
float
verblib_get_dry
(
const
verblib
*
verb
);
/* Set the stereo width of the input signal sent to the reverb, 0.0 or greater.
* Values less than 1.0 narrow the signal, 1.0 sends the input signal unmodified, values greater than 1.0 widen the signal.
*/
void
verblib_set_input_width
(
verblib
*
verb
,
float
value
);
/* Get the stereo width of the input signal sent to the reverb. */
float
verblib_get_input_width
(
const
verblib
*
verb
);
/* Set the mode of the reverb, where values below 0.5 mean normal and values above mean frozen. */
/* Set the mode of the reverb, where values below 0.5 mean normal and values above mean frozen. */
void
verblib_set_mode
(
verblib
*
verb
,
float
value
);
void
verblib_set_mode
(
verblib
*
verb
,
float
value
);
...
@@ -137,6 +145,7 @@ extern "C" {
...
@@ -137,6 +145,7 @@ extern "C" {
#define verblib_initialwet 1.0f/verblib_scalewet
#define verblib_initialwet 1.0f/verblib_scalewet
#define verblib_initialdry 0.0f
#define verblib_initialdry 0.0f
#define verblib_initialwidth 1.0f
#define verblib_initialwidth 1.0f
#define verblib_initialinputwidth 0.0f
#define verblib_initialmode 0.0f
#define verblib_initialmode 0.0f
#define verblib_freezemode 0.5f
#define verblib_freezemode 0.5f
#define verblib_stereospread 23
#define verblib_stereospread 23
...
@@ -180,6 +189,7 @@ extern "C" {
...
@@ -180,6 +189,7 @@ extern "C" {
float
wet
,
wet1
,
wet2
;
float
wet
,
wet1
,
wet2
;
float
dry
;
float
dry
;
float
width
;
float
width
;
float
input_width
;
float
mode
;
float
mode
;
/*
/*
...
@@ -247,6 +257,8 @@ extern "C" {
...
@@ -247,6 +257,8 @@ extern "C" {
#endif
#endif
#endif
#endif
#define verblib_max(x, y) (((x) > (y)) ? (x) : (y))
#define undenormalise(sample) sample+=1.0f; sample-=1.0f;
#define undenormalise(sample) sample+=1.0f; sample-=1.0f;
/* Allpass filter */
/* Allpass filter */
...
@@ -451,6 +463,7 @@ int verblib_initialize ( verblib* verb, unsigned long sample_rate, unsigned int
...
@@ -451,6 +463,7 @@ int verblib_initialize ( verblib* verb, unsigned long sample_rate, unsigned int
verblib_set_dry
(
verb
,
verblib_initialdry
);
verblib_set_dry
(
verb
,
verblib_initialdry
);
verblib_set_damping
(
verb
,
verblib_initialdamp
);
verblib_set_damping
(
verb
,
verblib_initialdamp
);
verblib_set_width
(
verb
,
verblib_initialwidth
);
verblib_set_width
(
verb
,
verblib_initialwidth
);
verblib_set_input_width
(
verb
,
verblib_initialinputwidth
);
verblib_set_mode
(
verb
,
verblib_initialmode
);
verblib_set_mode
(
verb
,
verblib_initialmode
);
/* The buffers will be full of rubbish - so we MUST mute them. */
/* The buffers will be full of rubbish - so we MUST mute them. */
...
@@ -493,32 +506,82 @@ void verblib_process ( verblib* verb, const float* input_buffer, float* output_b
...
@@ -493,32 +506,82 @@ void verblib_process ( verblib* verb, const float* input_buffer, float* output_b
}
}
else
if
(
verb
->
channels
==
2
)
else
if
(
verb
->
channels
==
2
)
{
{
while
(
frames
--
>
0
)
if
(
verb
->
input_width
>
0
.
0
f
)
/* Stereo input is widened or narrowed. */
{
{
outL
=
outR
=
0
.
0
f
;
input
=
(
input_buffer
[
0
]
+
input_buffer
[
1
]
)
*
verb
->
gain
;
/* Accumulate comb filters in parallel. */
/*
for
(
i
=
0
;
i
<
verblib_numcombs
;
i
++
)
* The stereo mid/side code is derived from:
* https://www.musicdsp.org/en/latest/Effects/256-stereo-width-control-obtained-via-transfromation-matrix.html
* The description of the code on the above page says:
*
* This work is hereby placed in the public domain for all purposes, including
* use in commercial applications.
*/
const
float
tmp
=
1
/
verblib_max
(
1
+
verb
->
input_width
,
2
);
const
float
coef_mid
=
1
*
tmp
;
const
float
coef_side
=
verb
->
input_width
*
tmp
;
while
(
frames
--
>
0
)
{
{
outL
+=
verblib_comb_process
(
&
verb
->
combL
[
i
],
input
);
const
float
mid
=
(
input_buffer
[
0
]
+
input_buffer
[
1
]
)
*
coef_mid
;
outR
+=
verblib_comb_process
(
&
verb
->
combR
[
i
],
input
);
const
float
side
=
(
input_buffer
[
1
]
-
input_buffer
[
0
]
)
*
coef_side
;
const
float
input_left
=
(
mid
-
side
)
*
(
verb
->
gain
*
2
.
0
f
);
const
float
input_right
=
(
mid
+
side
)
*
(
verb
->
gain
*
2
.
0
f
);
outL
=
outR
=
0
.
0
f
;
/* Accumulate comb filters in parallel. */
for
(
i
=
0
;
i
<
verblib_numcombs
;
i
++
)
{
outL
+=
verblib_comb_process
(
&
verb
->
combL
[
i
],
input_left
);
outR
+=
verblib_comb_process
(
&
verb
->
combR
[
i
],
input_right
);
}
/* Feed through allpasses in series. */
for
(
i
=
0
;
i
<
verblib_numallpasses
;
i
++
)
{
outL
=
verblib_allpass_process
(
&
verb
->
allpassL
[
i
],
outL
);
outR
=
verblib_allpass_process
(
&
verb
->
allpassR
[
i
],
outR
);
}
/* Calculate output REPLACING anything already there. */
output_buffer
[
0
]
=
outL
*
verb
->
wet1
+
outR
*
verb
->
wet2
+
input_buffer
[
0
]
*
verb
->
dry
;
output_buffer
[
1
]
=
outR
*
verb
->
wet1
+
outL
*
verb
->
wet2
+
input_buffer
[
1
]
*
verb
->
dry
;
/* Increment sample pointers. */
input_buffer
+=
2
;
output_buffer
+=
2
;
}
}
}
/* Feed through allpasses in series. */
else
/* Stereo input is summed to mono. */
for
(
i
=
0
;
i
<
verblib_numallpasses
;
i
++
)
{
while
(
frames
--
>
0
)
{
{
outL
=
verblib_allpass_process
(
&
verb
->
allpassL
[
i
],
outL
);
outL
=
outR
=
0
.
0
f
;
outR
=
verblib_allpass_process
(
&
verb
->
allpassR
[
i
],
outR
);
input
=
(
input_buffer
[
0
]
+
input_buffer
[
1
]
)
*
verb
->
gain
;
/* Accumulate comb filters in parallel. */
for
(
i
=
0
;
i
<
verblib_numcombs
;
i
++
)
{
outL
+=
verblib_comb_process
(
&
verb
->
combL
[
i
],
input
);
outR
+=
verblib_comb_process
(
&
verb
->
combR
[
i
],
input
);
}
/* Feed through allpasses in series. */
for
(
i
=
0
;
i
<
verblib_numallpasses
;
i
++
)
{
outL
=
verblib_allpass_process
(
&
verb
->
allpassL
[
i
],
outL
);
outR
=
verblib_allpass_process
(
&
verb
->
allpassR
[
i
],
outR
);
}
/* Calculate output REPLACING anything already there. */
output_buffer
[
0
]
=
outL
*
verb
->
wet1
+
outR
*
verb
->
wet2
+
input_buffer
[
0
]
*
verb
->
dry
;
output_buffer
[
1
]
=
outR
*
verb
->
wet1
+
outL
*
verb
->
wet2
+
input_buffer
[
1
]
*
verb
->
dry
;
/* Increment sample pointers. */
input_buffer
+=
2
;
output_buffer
+=
2
;
}
}
/* Calculate output REPLACING anything already there. */
output_buffer
[
0
]
=
outL
*
verb
->
wet1
+
outR
*
verb
->
wet2
+
input_buffer
[
0
]
*
verb
->
dry
;
output_buffer
[
1
]
=
outR
*
verb
->
wet1
+
outL
*
verb
->
wet2
+
input_buffer
[
1
]
*
verb
->
dry
;
/* Increment sample pointers. */
input_buffer
+=
2
;
output_buffer
+=
2
;
}
}
}
}
}
}
...
@@ -577,6 +640,16 @@ float verblib_get_width ( const verblib* verb )
...
@@ -577,6 +640,16 @@ float verblib_get_width ( const verblib* verb )
return
verb
->
width
;
return
verb
->
width
;
}
}
void
verblib_set_input_width
(
verblib
*
verb
,
float
value
)
{
verb
->
input_width
=
value
;
}
float
verblib_get_input_width
(
const
verblib
*
verb
)
{
return
verb
->
input_width
;
}
void
verblib_set_mode
(
verblib
*
verb
,
float
value
)
void
verblib_set_mode
(
verblib
*
verb
,
float
value
)
{
{
verb
->
mode
=
value
;
verb
->
mode
=
value
;
...
@@ -610,6 +683,9 @@ unsigned long verblib_get_decay_time_in_frames ( const verblib* verb )
...
@@ -610,6 +683,9 @@ unsigned long verblib_get_decay_time_in_frames ( const verblib* verb )
/* REVISION HISTORY
/* REVISION HISTORY
*
*
* Version 0.5 - 2022-10-25
* Added two functions called verblib_set_input_width and verblib_get_input_width.
*
* Version 0.4 - 2021-01-23
* Version 0.4 - 2021-01-23
* Added a function called verblib_get_decay_time_in_frames.
* Added a function called verblib_get_decay_time_in_frames.
*
*
...
@@ -628,7 +704,7 @@ unsigned long verblib_get_decay_time_in_frames ( const verblib* verb )
...
@@ -628,7 +704,7 @@ unsigned long verblib_get_decay_time_in_frames ( const verblib* verb )
This software is available under 2 licenses -- choose whichever you prefer.
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
ALTERNATIVE A - MIT No Attribution License
ALTERNATIVE A - MIT No Attribution License
Copyright (c) 202
1
Philip Bennefall
Copyright (c) 202
2
Philip Bennefall
Permission is hereby granted, free of charge, to any person obtaining a copy of
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
this software and associated documentation files (the "Software"), to deal in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment