pax_global_header00006660000000000000000000000064112363261440014514gustar00rootroot0000000000000052 comment=917e324132573f4d3159a503c08129d839eacf1f invada-studio-plugins-0.3.1/000077500000000000000000000000001123632614400157435ustar00rootroot00000000000000invada-studio-plugins-0.3.1/COPYING000066400000000000000000000431101123632614400167750ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. invada-studio-plugins-0.3.1/CREDITS000066400000000000000000000007571123632614400167740ustar00rootroot00000000000000The author would like to thank the following people for their help, support, comments, suggestions, patches etc. Denise Faulkner - for putting up with me :) Big thanks to the people making the host applications - without which this software would be useless: Ardour [http://ardour.org] Hydrogen [http://www.hydrogen-music.org/] Jack-Rack [http://jack-rack.sourceforge.net/] LMMS [http://lmms.sourceforge.net/] Muse [http://muse-sequencer.org/] Rosegarden [http://www.rosegardenmusic.com/] invada-studio-plugins-0.3.1/Makefile000066400000000000000000000050421123632614400174040ustar00rootroot00000000000000# Copyright (C) 2007 Fraser Stuart # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # ##################################################################### # PLEASE CHANGE THIS to your preferred installation location! # # Change this if you want to install somewhere else. In particular # you may wish to remove the middle "local/" part of the path. INSTALL_PLUGINS_DIR = /usr/local/lib/ladspa/ INSTALL_LRDF_DIR = /usr/local/share/ladspa/rdf/ # NO EDITING below this line is required # if all you want to do is install and use the plugins. ##################################################################### # GENERAL CC = gcc LD = ld CFLAGS = -I. -O3 -Wall -fomit-frame-pointer -fstrength-reduce -funroll-loops -ffast-math -c -fPIC -DPIC LDFLAGS = -shared -lc -lm -L. -linv_common PLUGINS = libinv_common.a \ inv_compressor.so \ inv_erreverb.so \ inv_filter.so \ inv_input.so \ inv_tube.so \ all: $(PLUGINS) # RULES TO BUILD PLUGINS FROM C CODE libinv_common.a: libinv_common.o libinv_common.h inv_compressor.so: inv_compressor.o inv_compressor.h inv_erreverb.so: inv_erreverb.o inv_erreverb.h inv_filter.so: inv_filter.o inv_filter.h inv_input.so: inv_input.o inv_input.h inv_tube.so: inv_tube.o inv_tube.h # OTHER TARGETS install: targets -mkdir -p $(INSTALL_PLUGINS_DIR) cp *.so $(INSTALL_PLUGINS_DIR) -mkdir -p $(INSTALL_LRDF_DIR) cp inv_plugins.rdf $(INSTALL_LRDF_DIR) targets: $(PLUGINS) always: clean: -rm -f `find . -name "*.so"` -rm -f `find . -name "*.a"` -rm -f `find . -name "*.o"` -rm -f `find .. -name "*~"` %.o: %.c @echo "Compiling $<" @$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ %.so: %.o @echo "Creating $@" @$(LD) -o $@ $< $(LDFLAGS) %.a: %.o @echo "Creating $@" @ar rcs $@ $< invada-studio-plugins-0.3.1/README000066400000000000000000000054521123632614400166310ustar00rootroot00000000000000INTRODUCTION ============ Thanks for taking the time to try out these plugins. Feedback / comments welcome. CONTENTS ======== The following plugins are included: Utility Plugins * Input Module => alter gain, balance, width, phase on a stereo signal Filter Plugins * Low Pass Mono => gentle low pass filter * Low Pass Stereo => gentle low pass filter * High Pass Mono => gentle high pass filter * High Pass Stereo => gentle high pass filter Simulation Plugins * Tube - Mono => Valve warmth/distortion simulation * Tube - Stereo => Valve warmth/distortion simulation Dynamics Plugins * Compressor - Mono => Peak/RMS softclipping compressor * Compressor - Stereo => Peak/RMS softclipping compressor Reverb Plugins * ER Reverb - Mono In => Early reflection based reverb * ER Reverb - Sum L+R In => Early reflection based reverb INSTALLATION ============ No binaries are included, you'll need to compile the plugins yourself. BUILDING ======== To build the plugins the you'll need the following items installed: * a working build environment with core includes * the ladspa header file (ladspa.h) Go to the directory that was created when you unpacked this archive and then run: make (as root) make install The plugins will install into "/usr/local" by default. (change the Makefile if you'd like to have them in an alternate location) BUILDING (Debian and derivatives) ================================= Packages for Debian and derivatives (Ubuntu etc) can have deb packages built from this archive. You'll need a Debian build environment. To install the build environment and package dependencies run the following: sudo apt-get install build-essential debhelper fakeroot ladspa-sdk Go to the directory that was created when you unpacked this archive and then run: dpkg-buildpackage -rfakeroot -tc Once done you'll find a 'deb' package for your system in the directory above. Use your favourite package manager to install. The plugins will install into "/usr" by default. KNOWN ISSUES ============ * Some applications don't obey the 'LOGARITHMIC' hint which makes selecting low values on the ports that need it a bit of a PITA. * The compressor has a gain reduction meter but only two applications I know of support the 'output control' port type - Ardour & Hydrogen. * I'd love to supply presents but I'm either to stupid to work out how to do it, the lrdf library is broken, or no host applications support it yet. If anyone knows how please drop me an email. * the 'DC Offset' in the tube plugins can do strange things to your meters (but nice things to the sound) - whenever I use it I send the output through Steve Harris's 'DC Offset remover' to clean it back up. One day I'll figure out how to remove the DC after it's gone through the tube. Enjoy! fraser@arkhostings.com https://launchpad.net/invada-studio invada-studio-plugins-0.3.1/inv_compressor.c000066400000000000000000000602401123632614400211610ustar00rootroot00000000000000/* This LADSPA plugin provides a mono and stereo compressor. (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "libinv_common.h" #include "inv_compressor.h" /* The port numbers for the plugin: */ #define ICOMP_RMS 0 #define ICOMP_ATTACK 1 #define ICOMP_RELEASE 2 #define ICOMP_THRESH 3 #define ICOMP_RATIO 4 #define ICOMP_GAIN 5 #define ICOMP_NOCLIP 6 #define ICOMP_METER 7 #define ICOMP_AUDIO_INPUT1 8 #define ICOMP_AUDIO_OUTPUT1 9 #define ICOMP_AUDIO_INPUT2 10 /* not used in mono mode */ #define ICOMP_AUDIO_OUTPUT2 11 /* not used in mono mode */ /* The structure used to hold port connection information and state */ typedef struct { unsigned long SampleRate; /* Ports */ LADSPA_Data * ControlRms; LADSPA_Data * ControlAttack; LADSPA_Data * ControlRelease; LADSPA_Data * ControlThresh; LADSPA_Data * ControlRatio; LADSPA_Data * ControlGain; LADSPA_Data * ControlNoClip; LADSPA_Data * ControlMeter; LADSPA_Data * AudioInputBuffer1; LADSPA_Data * AudioOutputBuffer1; LADSPA_Data * AudioInputBuffer2; LADSPA_Data * AudioOutputBuffer2; /* these params are used to remember the control values and the converted (internal) value to save a bit of cpu converting them every run */ LADSPA_Data LastRms; LADSPA_Data LastAttack; LADSPA_Data LastRelease; LADSPA_Data LastThresh; LADSPA_Data LastRatio; LADSPA_Data LastGain; LADSPA_Data LastNoClip; LADSPA_Data ConvertedRms; LADSPA_Data ConvertedAttack; LADSPA_Data ConvertedRelease; LADSPA_Data ConvertedThresh; LADSPA_Data ConvertedRatio; LADSPA_Data ConvertedGain; LADSPA_Data ConvertedNoClip; /* this stuff needs to be remembered between run calls */ LADSPA_Data Envelope; LADSPA_Data Rms; } Icomp; /* Construct a new plugin instance. */ LADSPA_Handle instantiateIcomp(const LADSPA_Descriptor * Descriptor, unsigned long SampleRate) { LADSPA_Handle Instance; Icomp * plug; if((Instance=malloc(sizeof(Icomp)))==NULL) return NULL; /* set some initial params */ plug = (Icomp *)Instance; /* should check SampleRate > 0 */ plug->SampleRate=SampleRate; return Instance; } /* Connect a port to a data location. */ void connectPortToIcomp(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data * DataLocation) { Icomp * plug; plug = (Icomp *)Instance; switch (Port) { case ICOMP_RMS: plug->ControlRms = DataLocation; break; case ICOMP_ATTACK: plug->ControlAttack = DataLocation; break; case ICOMP_RELEASE: plug->ControlRelease = DataLocation; break; case ICOMP_THRESH: plug->ControlThresh = DataLocation; break; case ICOMP_RATIO: plug->ControlRatio = DataLocation; break; case ICOMP_GAIN: plug->ControlGain = DataLocation; break; case ICOMP_NOCLIP: plug->ControlNoClip = DataLocation; break; case ICOMP_METER: plug->ControlMeter = DataLocation; break; case ICOMP_AUDIO_INPUT1: plug->AudioInputBuffer1 = DataLocation; break; case ICOMP_AUDIO_OUTPUT1: plug->AudioOutputBuffer1 = DataLocation; break; case ICOMP_AUDIO_INPUT2: plug->AudioInputBuffer2 = DataLocation; break; case ICOMP_AUDIO_OUTPUT2: plug->AudioOutputBuffer2 = DataLocation; break; } } void activateIcomp(LADSPA_Handle Instance) { Icomp * plug; plug = (Icomp *)Instance; plug->Envelope=0; plug->Rms=0; /* default values */ plug->LastRms =0.5; plug->LastAttack =0.01; plug->LastRelease=1; plug->LastThresh =0; plug->LastRatio =1; plug->LastGain =0; plug->LastNoClip =1; plug->ConvertedRms =convertParam(ICOMP_RMS, plug->LastRms, plug->SampleRate); plug->ConvertedAttack =convertParam(ICOMP_ATTACK, plug->LastAttack, plug->SampleRate); plug->ConvertedRelease=convertParam(ICOMP_RELEASE, plug->LastRelease, plug->SampleRate); plug->ConvertedThresh =convertParam(ICOMP_THRESH, plug->LastThresh, plug->SampleRate); plug->ConvertedRatio =convertParam(ICOMP_RATIO, plug->LastRatio, plug->SampleRate); plug->ConvertedGain =convertParam(ICOMP_GAIN, plug->LastGain, plug->SampleRate); plug->ConvertedNoClip =convertParam(ICOMP_NOCLIP, plug->LastNoClip, plug->SampleRate); } void runMonoIcomp(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioOutput1; LADSPA_Data fAudio1,fEnvelope,fRms,fRmsSize; LADSPA_Data fAttack,fRelease,fThresh,fRatio,fGain,fCompGain,fNoClip; Icomp * plug; unsigned long lSampleIndex; plug = (Icomp *)Instance; pParamFunc = &convertParam; /* see if any params have changed */ checkParamChange(ICOMP_RMS, plug->ControlRms, &(plug->LastRms), &(plug->ConvertedRms), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_ATTACK, plug->ControlAttack, &(plug->LastAttack), &(plug->ConvertedAttack), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_RELEASE,plug->ControlRelease,&(plug->LastRelease),&(plug->ConvertedRelease),plug->SampleRate, pParamFunc); checkParamChange(ICOMP_THRESH, plug->ControlThresh, &(plug->LastThresh), &(plug->ConvertedThresh), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_RATIO, plug->ControlRatio, &(plug->LastRatio), &(plug->ConvertedRatio), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fRmsSize = plug->ConvertedRms; fAttack = plug->ConvertedAttack; fRelease = plug->ConvertedRelease; fThresh = plug->ConvertedThresh; fRatio = plug->ConvertedRatio; fGain = plug->ConvertedGain; fNoClip = plug->ConvertedNoClip; fEnvelope = plug->Envelope; fRms = plug->Rms; fCompGain = 1; // this is set before it is used unless we are given no samples in which case it doesn't matter pfAudioInput1 = plug->AudioInputBuffer1; pfAudioOutput1 = plug->AudioOutputBuffer1; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1=*(pfAudioInput1++); // work out the rms fRms = sqrt(( (fRmsSize-1)*fRms*fRms + fAudio1*fAudio1 ) / fRmsSize); // work out the envelope fEnvelope += (fRms > fEnvelope) ? fAttack * (fRms - fEnvelope) : fRelease * (fRms - fEnvelope); // work out the gain fCompGain = (fEnvelope > fThresh) ? (pow((fEnvelope/fThresh), ((1.0/fRatio)-1.0) )) : 1; *(pfAudioOutput1++) = fNoClip > 0 ? InoClip(fAudio1*fCompGain * fGain ) : fAudio1*fCompGain * fGain ; } // remember for next time round plug->Envelope = (fabs(fEnvelope)<1.0e-10) ? 0.f : fEnvelope; plug->Rms = (fabs(fRms)<1.0e-10) ? 0.f : fRms; // update the meter. 0.015848932=-36dB (the max gain reduction this compressor can do) *(plug->ControlMeter)=(fCompGain > 0.015848932) ? 20*log10(fCompGain) : -36.0; } void runStereoIcomp(LADSPA_Handle Instance,unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioInput2; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data fAudio1,fAudio2,fMaxAudio,fEnvelope,fRms,fRmsSize; LADSPA_Data fAttack,fRelease,fThresh,fRatio,fGain,fCompGain,fNoClip; Icomp * plug; unsigned long lSampleIndex; plug = (Icomp *)Instance; pParamFunc = &convertParam; /* see if any params have changed */ checkParamChange(ICOMP_RMS, plug->ControlRms, &(plug->LastRms), &(plug->ConvertedRms), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_ATTACK, plug->ControlAttack, &(plug->LastAttack), &(plug->ConvertedAttack), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_RELEASE,plug->ControlRelease,&(plug->LastRelease),&(plug->ConvertedRelease),plug->SampleRate, pParamFunc); checkParamChange(ICOMP_THRESH, plug->ControlThresh, &(plug->LastThresh), &(plug->ConvertedThresh), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_RATIO, plug->ControlRatio, &(plug->LastRatio), &(plug->ConvertedRatio), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(ICOMP_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fRmsSize = plug->ConvertedRms; fAttack = plug->ConvertedAttack; fRelease = plug->ConvertedRelease; fThresh = plug->ConvertedThresh; fRatio = plug->ConvertedRatio; fGain = plug->ConvertedGain; fNoClip = plug->ConvertedNoClip; fEnvelope = plug->Envelope; fRms = plug->Rms; fCompGain = 1; // this is set before it is used pfAudioInput1 = plug->AudioInputBuffer1; pfAudioInput2 = plug->AudioInputBuffer2; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1=*(pfAudioInput1++); fAudio2=*(pfAudioInput2++); // work out the rms fMaxAudio = fabs(fAudio1) > fabs(fAudio2) ? fAudio1 : fAudio2; fRms = sqrt(( (fRmsSize-1)*fRms*fRms + fMaxAudio*fMaxAudio ) / fRmsSize); // work out the envelope fEnvelope += (fRms > fEnvelope) ? fAttack * (fRms - fEnvelope) : fRelease * (fRms - fEnvelope); // work out the gain fCompGain = (fEnvelope > fThresh) ? (pow((fEnvelope/fThresh), ((1.0/fRatio)-1.0))) : 1; *(pfAudioOutput1++) = fNoClip > 0 ? InoClip(fAudio1*fCompGain*fGain) : fAudio1*fCompGain*fGain ; *(pfAudioOutput2++) = fNoClip > 0 ? InoClip(fAudio2*fCompGain*fGain) : fAudio2*fCompGain*fGain ; } // remember for next time round plug->Envelope = (fabs(fEnvelope)<1.0e-10) ? 0.f : fEnvelope; plug->Rms = (fabs(fRms)<1.0e-10) ? 0.f : fRms; // update the meter *(plug->ControlMeter)=(fCompGain > 0.015848932) ? 20*log10(fCompGain) : -36.0; } void cleanupIcomp(LADSPA_Handle Instance) { free(Instance); } LADSPA_Descriptor * g_psMonoCompDescriptor = NULL; LADSPA_Descriptor * g_psStereoCompDescriptor = NULL; void _init() { char ** pcPortNames; LADSPA_PortDescriptor * piPortDescriptors; LADSPA_PortRangeHint * psPortRangeHints; g_psMonoCompDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); g_psStereoCompDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); if (g_psMonoCompDescriptor) { g_psMonoCompDescriptor->UniqueID = 3308; g_psMonoCompDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psMonoCompDescriptor->Label = strdup("invada_mono_compressor_module_0_1"); g_psMonoCompDescriptor->Name = strdup(":: Invada :: Compressor - Mono"); g_psMonoCompDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psMonoCompDescriptor->Copyright = strdup("(c) Invada Records"); g_psMonoCompDescriptor->PortCount = 10; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(10, sizeof(LADSPA_PortDescriptor)); g_psMonoCompDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[ICOMP_RMS] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_ATTACK] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_RELEASE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_THRESH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_RATIO] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_METER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_AUDIO_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ICOMP_AUDIO_OUTPUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(10, sizeof(char *)); g_psMonoCompDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[ICOMP_RMS] = strdup("Tight / Sloppy"); pcPortNames[ICOMP_ATTACK] = strdup("Attack (ms)"); pcPortNames[ICOMP_RELEASE] = strdup("Release (ms)"); pcPortNames[ICOMP_THRESH] = strdup("Threshold (dB)"); pcPortNames[ICOMP_RATIO] = strdup("Ratio"); pcPortNames[ICOMP_GAIN] = strdup("Gain (dB)"); pcPortNames[ICOMP_NOCLIP] = strdup("Soft Clip"); pcPortNames[ICOMP_METER] = strdup("Gain Reduction"); pcPortNames[ICOMP_AUDIO_INPUT1] = strdup("Input"); pcPortNames[ICOMP_AUDIO_OUTPUT1] = strdup("Output"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(10, sizeof(LADSPA_PortRangeHint))); g_psMonoCompDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[ICOMP_RMS].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[ICOMP_RMS].LowerBound = 0; psPortRangeHints[ICOMP_RMS].UpperBound = 1; psPortRangeHints[ICOMP_ATTACK].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_MINIMUM ); psPortRangeHints[ICOMP_ATTACK].LowerBound = 0.01; psPortRangeHints[ICOMP_ATTACK].UpperBound = 750; psPortRangeHints[ICOMP_RELEASE].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_MINIMUM ); psPortRangeHints[ICOMP_RELEASE].LowerBound = 1; psPortRangeHints[ICOMP_RELEASE].UpperBound = 5000; psPortRangeHints[ICOMP_THRESH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[ICOMP_THRESH].LowerBound = -36; psPortRangeHints[ICOMP_THRESH].UpperBound = 0; psPortRangeHints[ICOMP_RATIO].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_1 ); psPortRangeHints[ICOMP_RATIO].LowerBound = 1; psPortRangeHints[ICOMP_RATIO].UpperBound = 20; psPortRangeHints[ICOMP_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[ICOMP_GAIN].LowerBound = -6; psPortRangeHints[ICOMP_GAIN].UpperBound = 36; psPortRangeHints[ICOMP_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_1); psPortRangeHints[ICOMP_METER].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE); psPortRangeHints[ICOMP_METER].LowerBound = -36; psPortRangeHints[ICOMP_METER].UpperBound = 0; psPortRangeHints[ICOMP_AUDIO_INPUT1].HintDescriptor = 0; psPortRangeHints[ICOMP_AUDIO_OUTPUT1].HintDescriptor = 0; g_psMonoCompDescriptor->instantiate = instantiateIcomp; g_psMonoCompDescriptor->connect_port = connectPortToIcomp; g_psMonoCompDescriptor->activate = activateIcomp; g_psMonoCompDescriptor->run = runMonoIcomp; g_psMonoCompDescriptor->run_adding = NULL; g_psMonoCompDescriptor->set_run_adding_gain = NULL; g_psMonoCompDescriptor->deactivate = NULL; g_psMonoCompDescriptor->cleanup = cleanupIcomp; } if (g_psStereoCompDescriptor) { g_psStereoCompDescriptor->UniqueID = 3309; g_psStereoCompDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psStereoCompDescriptor->Label = strdup("invada_stereo_compressor_module_0_1"); g_psStereoCompDescriptor->Name = strdup(":: Invada :: Compressor - Stereo"); g_psStereoCompDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psStereoCompDescriptor->Copyright = strdup("(c) Invada Records"); g_psStereoCompDescriptor->PortCount = 12; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(12, sizeof(LADSPA_PortDescriptor)); g_psStereoCompDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[ICOMP_RMS] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_ATTACK] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_RELEASE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_THRESH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_RATIO] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_METER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ICOMP_AUDIO_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ICOMP_AUDIO_OUTPUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ICOMP_AUDIO_INPUT2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ICOMP_AUDIO_OUTPUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(12, sizeof(char *)); g_psStereoCompDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[ICOMP_RMS] = strdup("Tight / Sloppy"); pcPortNames[ICOMP_ATTACK] = strdup("Attack (ms)"); pcPortNames[ICOMP_RELEASE] = strdup("Release (ms)"); pcPortNames[ICOMP_THRESH] = strdup("Threshold (dB)"); pcPortNames[ICOMP_RATIO] = strdup("Ratio"); pcPortNames[ICOMP_GAIN] = strdup("Gain (dB)"); pcPortNames[ICOMP_NOCLIP] = strdup("Soft Clip"); pcPortNames[ICOMP_METER] = strdup("Gain Reduction"); pcPortNames[ICOMP_AUDIO_INPUT1] = strdup("Input (Left)"); pcPortNames[ICOMP_AUDIO_OUTPUT1] = strdup("Output (Left)"); pcPortNames[ICOMP_AUDIO_INPUT2] = strdup("Input (Right)"); pcPortNames[ICOMP_AUDIO_OUTPUT2] = strdup("Output (Right)"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(12, sizeof(LADSPA_PortRangeHint))); g_psStereoCompDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[ICOMP_RMS].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[ICOMP_RMS].LowerBound = 0; psPortRangeHints[ICOMP_RMS].UpperBound = 1; psPortRangeHints[ICOMP_ATTACK].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_MINIMUM ); psPortRangeHints[ICOMP_ATTACK].LowerBound = 0.01; psPortRangeHints[ICOMP_ATTACK].UpperBound = 300; psPortRangeHints[ICOMP_RELEASE].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_MINIMUM ); psPortRangeHints[ICOMP_RELEASE].LowerBound = 1; psPortRangeHints[ICOMP_RELEASE].UpperBound = 2000; psPortRangeHints[ICOMP_THRESH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[ICOMP_THRESH].LowerBound = -36; psPortRangeHints[ICOMP_THRESH].UpperBound = 0; psPortRangeHints[ICOMP_RATIO].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_1 ); psPortRangeHints[ICOMP_RATIO].LowerBound = 1; psPortRangeHints[ICOMP_RATIO].UpperBound = 20; psPortRangeHints[ICOMP_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[ICOMP_GAIN].LowerBound = -6; psPortRangeHints[ICOMP_GAIN].UpperBound = 36; psPortRangeHints[ICOMP_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_1); psPortRangeHints[ICOMP_METER].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE); psPortRangeHints[ICOMP_METER].LowerBound = -36; psPortRangeHints[ICOMP_METER].UpperBound = 0; psPortRangeHints[ICOMP_AUDIO_INPUT1].HintDescriptor = 0; psPortRangeHints[ICOMP_AUDIO_OUTPUT1].HintDescriptor = 0; psPortRangeHints[ICOMP_AUDIO_INPUT2].HintDescriptor = 0; psPortRangeHints[ICOMP_AUDIO_OUTPUT2].HintDescriptor = 0; g_psStereoCompDescriptor->instantiate = instantiateIcomp; g_psStereoCompDescriptor->connect_port = connectPortToIcomp; g_psStereoCompDescriptor->activate = activateIcomp ; g_psStereoCompDescriptor->run = runStereoIcomp; g_psStereoCompDescriptor->run_adding = NULL; g_psStereoCompDescriptor->set_run_adding_gain = NULL; g_psStereoCompDescriptor->deactivate = NULL; g_psStereoCompDescriptor->cleanup = cleanupIcomp; } } void deleteDescriptor(LADSPA_Descriptor * psDescriptor) { unsigned long lIndex; if (psDescriptor) { free((char *)psDescriptor->Label); free((char *)psDescriptor->Name); free((char *)psDescriptor->Maker); free((char *)psDescriptor->Copyright); free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) free((char *)(psDescriptor->PortNames[lIndex])); free((char **)psDescriptor->PortNames); free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); free(psDescriptor); } } /* _fini() is called automatically when the library is unloaded. */ void _fini() { deleteDescriptor(g_psMonoCompDescriptor); deleteDescriptor(g_psStereoCompDescriptor); } /* Return a descriptor of the requested plugin type. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index) { switch (Index) { case 0: return g_psMonoCompDescriptor; case 1: return g_psStereoCompDescriptor; default: return NULL; } } LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr) { /* some conversion formulae are shared so the bounds are the min/max across all ports */ LADSPA_Data result; switch(param) { case ICOMP_RMS: if(value<0) result= 1; else if (value < 1) result= (pow(value,3) * (LADSPA_Data)sr/20)+1; else result= ((LADSPA_Data)sr/20)+1; break; case ICOMP_ATTACK: case ICOMP_RELEASE: if(value<0.01) result= 1 - pow(10, -301.0301 / ((LADSPA_Data)sr * 0.01)); else if (value <5000) result= 1 - pow(10, -301.0301 / ((LADSPA_Data)sr * value)); else result= 1 - pow(10, -301.0301 / ((LADSPA_Data)sr * 5000)); break; case ICOMP_THRESH: case ICOMP_RATIO: case ICOMP_GAIN: if(value<-36) result= pow(10, -1.8); else if (value < 36) result= pow(10, value/20); else result= pow(10, 1.8); break; case ICOMP_NOCLIP: if(value<0.5) result= 0; else result= 1; break; default: result=0; break; } return result; } invada-studio-plugins-0.3.1/inv_compressor.h000066400000000000000000000014761123632614400211740ustar00rootroot00000000000000/* (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr); invada-studio-plugins-0.3.1/inv_erreverb.c000066400000000000000000001346011123632614400206040ustar00rootroot00000000000000/* This LADSPA plugin provides an early reflection reverb from a mono source (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Some Notes: =========== This plugin is not your classic sort of reverb that makes long washy spaces. It simulates a room by calculating the early reflections that occur off the walls/roof etc. It's useful for: a) putting dry signals in a 'natural' space so they sit with sounds recorded with 'room' anbience in them. b) thickening strings, vocals etc without softening or washing out. c) as a singal preprocess for reverb that does not have early reflections. d) accurate stereo placement by setting the 'source' LR the same as any panning the dry signle has. This is because the early reflections from the off-center single reinforce the location of the sound rather than contradicting it as a normal reverb would do. Parameter description: RoomLength,RoomWidth,RoomHeight - the dimensions (in meters) of the room SourceLR, SourceFB (FB=Front/Back) - where the sound source is in the room (always the back half) DestLR, DestFB (FB=Front/Back) - where the destination (or listener) is in the room (always the front half) HPF - roll off some bottom end Warmth - roll off top end (amount depends on reflection count) Diffusion - makes the relections less perfect to simulate objects in the room. */ #include #include #include #include #include "libinv_common.h" #include "inv_erreverb.h" /* The port numbers for the plugin: */ #define IERR_ROOMLENGTH 0 #define IERR_ROOMWIDTH 1 #define IERR_ROOMHEIGHT 2 #define IERR_SOURCELR 3 #define IERR_SOURCEFB 4 #define IERR_DESTLR 5 #define IERR_DESTFB 6 #define IERR_HPF 7 #define IERR_WARMTH 8 #define IERR_DIFFUSION 9 #define IERR_AUDIO_OUT1 10 #define IERR_AUDIO_OUT2 11 #define IERR_AUDIO_IN1 12 #define IERR_AUDIO_IN2 13 /* not used in mono in mode */ /* The structure used to hold port connection information and state. */ typedef struct { unsigned long SampleRate; /* Ports */ LADSPA_Data * ControlRoomLength; LADSPA_Data * ControlRoomWidth; LADSPA_Data * ControlRoomHeight; LADSPA_Data * ControlSourceLR; LADSPA_Data * ControlSourceFB; LADSPA_Data * ControlDestLR; LADSPA_Data * ControlDestFB; LADSPA_Data * ControlHPF; LADSPA_Data * ControlWarmth; LADSPA_Data * ControlDiffusion; LADSPA_Data * AudioOutputBuffer1; LADSPA_Data * AudioOutputBuffer2; LADSPA_Data * AudioInputBuffer1; LADSPA_Data * AudioInputBuffer2; /* Stuff to remember to avoid recalculating the delays every run */ LADSPA_Data LastRoomLength; LADSPA_Data LastRoomWidth; LADSPA_Data LastRoomHeight; LADSPA_Data LastSourceLR; LADSPA_Data LastSourceFB; LADSPA_Data LastDestLR; LADSPA_Data LastDestFB; LADSPA_Data LastHPF; LADSPA_Data LastWarmth; LADSPA_Data LastDiffusion; LADSPA_Data ConvertedHPF; LADSPA_Data ConvertedWarmth; /* Delay Data */ unsigned int er_size; struct ERunit * er; unsigned long SpaceSize; LADSPA_Data * SpaceL; LADSPA_Data * SpaceR; LADSPA_Data * SpaceLCur; LADSPA_Data * SpaceRCur; LADSPA_Data * SpaceLEnd; LADSPA_Data * SpaceREnd; LADSPA_Data AudioHPFLast; LADSPA_Data AudioIn1Last; LADSPA_Data AudioIn2Last; LADSPA_Data AudioIn3Last; LADSPA_Data AudioIn4Last; } IreverbER; /*****************************************************************************/ /* Construct a new plugin instance. */ LADSPA_Handle instantiateIreverbER(const LADSPA_Descriptor * Descriptor, unsigned long SampleRate) { LADSPA_Handle Instance; IreverbER * plug; if((Instance=malloc(sizeof(IreverbER)))==NULL) return NULL; /* set some initial params */ plug = (IreverbER *)Instance; /* should check SampleRate > 0 */ plug->SampleRate=SampleRate; plug->SpaceSize = REVERB_SPACE_SIZE * SampleRate; /* the delay space */ if((plug->SpaceL = (LADSPA_Data *)malloc(sizeof(LADSPA_Data) * plug->SpaceSize))==NULL) return NULL; if((plug->SpaceR = (LADSPA_Data *)malloc(sizeof(LADSPA_Data) * plug->SpaceSize))==NULL) return NULL; /* the delays */ if((plug->er = (struct ERunit *)malloc(sizeof(struct ERunit) * MAX_ER))==NULL) return NULL; return Instance; } /*****************************************************************************/ /* Connect a port to a data location. */ void connectPortToIreverbER(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data * DataLocation) { IreverbER * plug; plug = (IreverbER *)Instance; switch (Port) { case IERR_ROOMLENGTH: plug->ControlRoomLength = DataLocation; break; case IERR_ROOMWIDTH: plug->ControlRoomWidth = DataLocation; break; case IERR_ROOMHEIGHT: plug->ControlRoomHeight = DataLocation; break; case IERR_SOURCELR: plug->ControlSourceLR = DataLocation; break; case IERR_SOURCEFB: plug->ControlSourceFB = DataLocation; break; case IERR_DESTLR: plug->ControlDestLR = DataLocation; break; case IERR_DESTFB: plug->ControlDestFB = DataLocation; break; case IERR_HPF: plug->ControlHPF = DataLocation; break; case IERR_WARMTH: plug->ControlWarmth = DataLocation; break; case IERR_DIFFUSION: plug->ControlDiffusion = DataLocation; break; case IERR_AUDIO_OUT1: plug->AudioOutputBuffer1 = DataLocation; break; case IERR_AUDIO_OUT2: plug->AudioOutputBuffer2 = DataLocation; break; case IERR_AUDIO_IN1: plug->AudioInputBuffer1 = DataLocation; break; case IERR_AUDIO_IN2: plug->AudioInputBuffer2 = DataLocation; break; } } void activateIreverbER(LADSPA_Handle Instance) { unsigned long i; LADSPA_Data * p; LADSPA_Data * q; IreverbER * plug; plug = (IreverbER *)Instance; //set ourselves at the beginning of space plug->SpaceLCur=plug->SpaceL; plug->SpaceRCur=plug->SpaceR; // clear space p=plug->SpaceL; q=plug->SpaceR; for(i=0; i < plug->SpaceSize; i++) { *(p++)=0; *(q++)=0; } plug->SpaceLEnd=--p; plug->SpaceREnd=--q; //set defaults plug->LastRoomLength = 26.5; plug->LastRoomWidth = 26.5; plug->LastRoomHeight = 9.75; plug->LastSourceLR = 0.5; plug->LastSourceFB = 0.775; plug->LastDestLR = 0.5; plug->LastDestFB = 0.225; plug->LastHPF = 0.001; plug->LastWarmth = 0.5; plug->LastDiffusion = 0.5; plug->AudioHPFLast=0; plug->AudioIn1Last=0; plug->AudioIn2Last=0; plug->AudioIn3Last=0; plug->AudioIn4Last=0; plug->ConvertedHPF = convertParam(IERR_HPF, plug->LastHPF, plug->SampleRate); plug->ConvertedWarmth = convertParam(IERR_WARMTH, plug->LastWarmth, plug->SampleRate); calculateIreverbER(Instance); } void runIMonoreverbER(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data AudioIn,AudioHPF,AudioIn1,AudioIn2,AudioIn3,AudioIn4,AudioProc; LADSPA_Data HPFsamples,WarmthSamples; IreverbER * plug; struct ERunit * er; unsigned long lSampleIndex; unsigned int i; unsigned int er_size; unsigned long SpaceSize; plug = (IreverbER *)Instance; pParamFunc = &convertParam; LADSPA_Data * SpaceLStr; LADSPA_Data * SpaceRStr; LADSPA_Data * SpaceLCur; LADSPA_Data * SpaceRCur; LADSPA_Data * SpaceLEnd; LADSPA_Data * SpaceREnd; /* see if the room has changed and recalculate the reflection details if needed */ if(*(plug->ControlRoomLength) != plug->LastRoomLength || *(plug->ControlRoomWidth) != plug->LastRoomWidth || *(plug->ControlRoomHeight) != plug->LastRoomHeight || *(plug->ControlSourceLR) != plug->LastSourceLR || *(plug->ControlSourceFB) != plug->LastSourceFB || *(plug->ControlDestLR) != plug->LastDestLR || *(plug->ControlDestFB) != plug->LastDestFB || *(plug->ControlDiffusion) != plug->LastDiffusion ) { plug->LastRoomLength = *(plug->ControlRoomLength); plug->LastRoomWidth = *(plug->ControlRoomWidth); plug->LastRoomHeight = *(plug->ControlRoomHeight); plug->LastSourceLR = *(plug->ControlSourceLR); plug->LastSourceFB = *(plug->ControlSourceFB); plug->LastDestLR = *(plug->ControlDestLR); plug->LastDestFB = *(plug->ControlDestFB); plug->LastDiffusion = *(plug->ControlDiffusion); calculateIreverbER(Instance); } /* check if any other params have changed */ checkParamChange(IERR_WARMTH, plug->ControlWarmth, &(plug->LastWarmth), &(plug->ConvertedWarmth), plug->SampleRate, pParamFunc); checkParamChange(IERR_HPF, plug->ControlHPF, &(plug->LastHPF), &(plug->ConvertedHPF), plug->SampleRate, pParamFunc); WarmthSamples = plug->ConvertedWarmth; HPFsamples = plug->ConvertedHPF; er_size =plug->er_size; SpaceSize =plug->SpaceSize; SpaceLStr =plug->SpaceL; SpaceRStr =plug->SpaceR; SpaceLCur =plug->SpaceLCur; SpaceRCur =plug->SpaceRCur; SpaceLEnd =plug->SpaceLEnd; SpaceREnd =plug->SpaceREnd; AudioHPF=plug->AudioHPFLast; AudioIn1=plug->AudioIn1Last; AudioIn2=plug->AudioIn2Last; AudioIn3=plug->AudioIn3Last; AudioIn4=plug->AudioIn4Last; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { AudioIn=*(pfAudioInput1++); // apply HPF as bottom end in reverbs sounds crap AudioHPF = ((HPFsamples-1) * AudioHPF + AudioIn) / HPFsamples; AudioIn = AudioIn - AudioHPF; // apply simple LPF filter repeatedly to audio to simluate frequency loss with each reflection AudioIn1=((WarmthSamples-1) * AudioIn1 + AudioIn) / WarmthSamples; AudioIn2=((WarmthSamples-1) * AudioIn2 + AudioIn1) / WarmthSamples; AudioIn3=((WarmthSamples-1) * AudioIn3 + AudioIn2) / WarmthSamples; AudioIn4=((WarmthSamples-1) * AudioIn4 + AudioIn3) / WarmthSamples; er = plug->er; // now calculate the reflections for(i=0;iReflections) { case 0: AudioProc=AudioIn; break; case 1: AudioProc=AudioIn1; break; case 2: AudioProc=AudioIn2; break; case 3: AudioProc=AudioIn3; break; case 4: default: AudioProc=AudioIn4; break; } // add the reflection into the delay space if(SpaceLCur+er->Delay > SpaceLEnd) *(SpaceLCur+er->Delay-SpaceSize)+=AudioProc*er->GainL*(1-er->DelayOffset); else *(SpaceLCur+er->Delay)+=AudioProc*er->GainL*(1-er->DelayOffset); if(SpaceLCur+er->Delay+1 > SpaceLEnd) *(SpaceLCur+er->Delay-SpaceSize+1)+=AudioProc*er->GainL*er->DelayOffset; else *(SpaceLCur+er->Delay+1)+=AudioProc*er->GainL*er->DelayOffset; if(SpaceRCur+er->Delay > SpaceREnd) *(SpaceRCur+er->Delay-SpaceSize)+=AudioProc*er->GainR*(1-er->DelayOffset); else *(SpaceRCur+er->Delay)+=AudioProc*er->GainR*(1-er->DelayOffset); if(SpaceRCur+er->Delay+1 > SpaceREnd) *(SpaceRCur+er->Delay-SpaceSize+1)+=AudioProc*er->GainR*er->DelayOffset; else *(SpaceRCur+er->Delay+1)+=AudioProc*er->GainR*er->DelayOffset; er++; } // read the audio out of the delay space *(pfAudioOutput1++) = *(SpaceLCur); *(pfAudioOutput2++) = *(SpaceRCur); // zero the spot we just read *(SpaceLCur)=0; *(SpaceRCur)=0; // advance the pointer to the next spot SpaceLCur = SpaceLCur < SpaceLEnd ? SpaceLCur + 1 : SpaceLStr; SpaceRCur = SpaceRCur < SpaceREnd ? SpaceRCur + 1 : SpaceRStr; } // remember for next run plug->SpaceLCur=SpaceLCur; plug->SpaceRCur=SpaceRCur; plug->AudioHPFLast=(fabs(AudioHPF)<1.0e-10) ? 0.f : AudioHPF; plug->AudioIn1Last=(fabs(AudioIn1)<1.0e-10) ? 0.f : AudioIn1; plug->AudioIn2Last=(fabs(AudioIn2)<1.0e-10) ? 0.f : AudioIn2; plug->AudioIn3Last=(fabs(AudioIn3)<1.0e-10) ? 0.f : AudioIn3; plug->AudioIn4Last=(fabs(AudioIn4)<1.0e-10) ? 0.f : AudioIn4; } void runISumreverbER(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioInput2; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data AudioIn,AudioHPF,AudioIn1,AudioIn2,AudioIn3,AudioIn4,AudioProc; LADSPA_Data HPFsamples,WarmthSamples; IreverbER * plug; struct ERunit * er; unsigned long lSampleIndex; unsigned int i; unsigned int er_size; unsigned long SpaceSize; plug = (IreverbER *)Instance; pParamFunc = &convertParam; LADSPA_Data * SpaceLStr; LADSPA_Data * SpaceRStr; LADSPA_Data * SpaceLCur; LADSPA_Data * SpaceRCur; LADSPA_Data * SpaceLEnd; LADSPA_Data * SpaceREnd; /* see if the room has changed and recalculate the refeclection details if needed */ if(*(plug->ControlRoomLength) != plug->LastRoomLength || *(plug->ControlRoomWidth) != plug->LastRoomWidth || *(plug->ControlRoomHeight) != plug->LastRoomHeight || *(plug->ControlSourceLR) != plug->LastSourceLR || *(plug->ControlSourceFB) != plug->LastSourceFB || *(plug->ControlDestLR) != plug->LastDestLR || *(plug->ControlDestFB) != plug->LastDestFB || *(plug->ControlDiffusion) != plug->LastDiffusion ) { plug->LastRoomLength = *(plug->ControlRoomLength); plug->LastRoomWidth = *(plug->ControlRoomWidth); plug->LastRoomHeight = *(plug->ControlRoomHeight); plug->LastSourceLR = *(plug->ControlSourceLR); plug->LastSourceFB = *(plug->ControlSourceFB); plug->LastDestLR = *(plug->ControlDestLR); plug->LastDestFB = *(plug->ControlDestFB); plug->LastDiffusion = *(plug->ControlDiffusion); calculateIreverbER(Instance); } /* check if any other params have changed */ checkParamChange(IERR_WARMTH, plug->ControlWarmth, &(plug->LastWarmth), &(plug->ConvertedWarmth), plug->SampleRate, pParamFunc); checkParamChange(IERR_HPF, plug->ControlHPF, &(plug->LastHPF), &(plug->ConvertedHPF), plug->SampleRate, pParamFunc); WarmthSamples = plug->ConvertedWarmth; HPFsamples = plug->ConvertedHPF; er_size =plug->er_size; SpaceSize =plug->SpaceSize; SpaceLStr =plug->SpaceL; SpaceRStr =plug->SpaceR; SpaceLCur =plug->SpaceLCur; SpaceRCur =plug->SpaceRCur; SpaceLEnd =plug->SpaceLEnd; SpaceREnd =plug->SpaceREnd; AudioHPF=plug->AudioHPFLast; AudioIn1=plug->AudioIn1Last; AudioIn2=plug->AudioIn2Last; AudioIn3=plug->AudioIn3Last; AudioIn4=plug->AudioIn4Last; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioInput2 = plug->AudioInputBuffer2; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { AudioIn=( *(pfAudioInput1++) + *(pfAudioInput2++) )/2; // apply HPF as bottom end in reverbs sounds crap AudioHPF = ((HPFsamples-1) * AudioHPF + AudioIn) / HPFsamples; AudioIn = AudioIn - AudioHPF; // apply simple filter repeatedly to audio to simluate frequency loss with each reflection AudioIn1=((WarmthSamples-1) * AudioIn1 + AudioIn) / WarmthSamples; AudioIn2=((WarmthSamples-1) * AudioIn2 + AudioIn1) / WarmthSamples; AudioIn3=((WarmthSamples-1) * AudioIn3 + AudioIn2) / WarmthSamples; AudioIn4=((WarmthSamples-1) * AudioIn4 + AudioIn3) / WarmthSamples; er = plug->er; // now calculate the reflections for(i=0;iReflections) { case 0: AudioProc=AudioIn; break; case 1: AudioProc=AudioIn1; break; case 2: AudioProc=AudioIn2; break; case 3: AudioProc=AudioIn3; break; case 4: default: AudioProc=AudioIn4; break; } // add the reflection into the delay space if(SpaceLCur+er->Delay > SpaceLEnd) *(SpaceLCur+er->Delay-SpaceSize)+=AudioProc*er->GainL*(1-er->DelayOffset); else *(SpaceLCur+er->Delay)+=AudioProc*er->GainL*(1-er->DelayOffset); if(SpaceLCur+er->Delay+1 > SpaceLEnd) *(SpaceLCur+er->Delay-SpaceSize+1)+=AudioProc*er->GainL*er->DelayOffset; else *(SpaceLCur+er->Delay+1)+=AudioProc*er->GainL*er->DelayOffset; if(SpaceRCur+er->Delay > SpaceREnd) *(SpaceRCur+er->Delay-SpaceSize)+=AudioProc*er->GainR*(1-er->DelayOffset); else *(SpaceRCur+er->Delay)+=AudioProc*er->GainR*(1-er->DelayOffset); if(SpaceRCur+er->Delay+1 > SpaceREnd) *(SpaceRCur+er->Delay-SpaceSize+1)+=AudioProc*er->GainR*er->DelayOffset; else *(SpaceRCur+er->Delay+1)+=AudioProc*er->GainR*er->DelayOffset; er++; } // read the audio out of the delay space *(pfAudioOutput1++) = *(SpaceLCur); *(pfAudioOutput2++) = *(SpaceRCur); // zero the spot we just read *(SpaceLCur)=0; *(SpaceRCur)=0; // advance the pointer to the next spot SpaceLCur = SpaceLCur < SpaceLEnd ? SpaceLCur + 1 : SpaceLStr; SpaceRCur = SpaceRCur < SpaceREnd ? SpaceRCur + 1 : SpaceRStr; } // remember for next run plug->SpaceLCur=SpaceLCur; plug->SpaceRCur=SpaceRCur; plug->AudioHPFLast=(fabs(AudioHPF)<1.0e-10) ? 0.f : AudioHPF; plug->AudioIn1Last=(fabs(AudioIn1)<1.0e-10) ? 0.f : AudioIn1; plug->AudioIn2Last=(fabs(AudioIn2)<1.0e-10) ? 0.f : AudioIn2; plug->AudioIn3Last=(fabs(AudioIn3)<1.0e-10) ? 0.f : AudioIn3; plug->AudioIn4Last=(fabs(AudioIn4)<1.0e-10) ? 0.f : AudioIn4; } /* Throw away a reverb. */ void cleanupIreverbER(LADSPA_Handle Instance) { IreverbER * plug; plug = (IreverbER *)Instance; free(plug->er); free(plug->SpaceL); free(plug->SpaceR); free(Instance); } LADSPA_Descriptor * g_psMonoReverbDescriptor = NULL; LADSPA_Descriptor * g_psSumReverbDescriptor = NULL; /* _init() is called automatically when the plugin library is first loaded. */ void _init() { char ** pcPortNames; LADSPA_PortDescriptor * piPortDescriptors; LADSPA_PortRangeHint * psPortRangeHints; g_psMonoReverbDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); g_psSumReverbDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); if (g_psMonoReverbDescriptor) { g_psMonoReverbDescriptor->UniqueID = 3311; g_psMonoReverbDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psMonoReverbDescriptor->Label = strdup("invada_mono_reverbER_module_0_1"); g_psMonoReverbDescriptor->Name = strdup(":: Invada :: ER Reverb - Mono In"); g_psMonoReverbDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psMonoReverbDescriptor->Copyright = strdup("(c) Invada Records"); g_psMonoReverbDescriptor->PortCount = 13; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(13, sizeof(LADSPA_PortDescriptor)); g_psMonoReverbDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IERR_ROOMLENGTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_ROOMWIDTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_ROOMHEIGHT] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_SOURCELR] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_SOURCEFB] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_DESTLR] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_DESTFB] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_HPF] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_WARMTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_DIFFUSION] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IERR_AUDIO_OUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IERR_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(13, sizeof(char *)); g_psMonoReverbDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IERR_ROOMLENGTH] = strdup("Room Length"); pcPortNames[IERR_ROOMWIDTH] = strdup("Room Width"); pcPortNames[IERR_ROOMHEIGHT] = strdup("Room Height"); pcPortNames[IERR_SOURCELR] = strdup("Source (L/R)"); pcPortNames[IERR_SOURCEFB] = strdup("Source (F/B)"); pcPortNames[IERR_DESTLR] = strdup("Listener (L/R)"); pcPortNames[IERR_DESTFB] = strdup("Listener (F/B)"); pcPortNames[IERR_HPF] = strdup("HPF (Hz)"); pcPortNames[IERR_WARMTH] = strdup("Warmth"); pcPortNames[IERR_DIFFUSION] = strdup("Diffusion"); pcPortNames[IERR_AUDIO_OUT1] = strdup("Output (Left)"); pcPortNames[IERR_AUDIO_OUT2] = strdup("Output (Right)"); pcPortNames[IERR_AUDIO_IN1] = strdup("Input"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(13, sizeof(LADSPA_PortRangeHint))); g_psMonoReverbDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IERR_ROOMLENGTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[IERR_ROOMLENGTH].LowerBound = 3; psPortRangeHints[IERR_ROOMLENGTH].UpperBound = 100; psPortRangeHints[IERR_ROOMWIDTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[IERR_ROOMWIDTH].LowerBound = 3; psPortRangeHints[IERR_ROOMWIDTH].UpperBound = 100; psPortRangeHints[IERR_ROOMHEIGHT].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[IERR_ROOMHEIGHT].LowerBound = 3; psPortRangeHints[IERR_ROOMHEIGHT].UpperBound = 30; psPortRangeHints[IERR_SOURCELR].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_SOURCELR].LowerBound = 0.01; psPortRangeHints[IERR_SOURCELR].UpperBound = 0.99; psPortRangeHints[IERR_SOURCEFB].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_SOURCEFB].LowerBound = 0.55; psPortRangeHints[IERR_SOURCEFB].UpperBound = 1; psPortRangeHints[IERR_DESTLR].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_DESTLR].LowerBound = 0.01; psPortRangeHints[IERR_DESTLR].UpperBound = 0.99; psPortRangeHints[IERR_DESTFB].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_DESTFB].LowerBound = 0; psPortRangeHints[IERR_DESTFB].UpperBound = 0.45; psPortRangeHints[IERR_HPF].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_MINIMUM); psPortRangeHints[IERR_HPF].LowerBound = 0.001; psPortRangeHints[IERR_HPF].UpperBound = 0.05; psPortRangeHints[IERR_WARMTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_WARMTH].LowerBound = 0; psPortRangeHints[IERR_WARMTH].UpperBound = 1; psPortRangeHints[IERR_DIFFUSION].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_DIFFUSION].LowerBound = 0; psPortRangeHints[IERR_DIFFUSION].UpperBound = 1; psPortRangeHints[IERR_AUDIO_OUT1].HintDescriptor = 0; psPortRangeHints[IERR_AUDIO_OUT2].HintDescriptor = 0; psPortRangeHints[IERR_AUDIO_IN1].HintDescriptor = 0; g_psMonoReverbDescriptor->instantiate = instantiateIreverbER; g_psMonoReverbDescriptor->connect_port = connectPortToIreverbER; g_psMonoReverbDescriptor->activate = activateIreverbER; g_psMonoReverbDescriptor->run = runIMonoreverbER; g_psMonoReverbDescriptor->run_adding = NULL; g_psMonoReverbDescriptor->set_run_adding_gain = NULL; g_psMonoReverbDescriptor->deactivate = NULL; g_psMonoReverbDescriptor->cleanup = cleanupIreverbER; } if (g_psSumReverbDescriptor) { g_psSumReverbDescriptor->UniqueID = 3312; g_psSumReverbDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psSumReverbDescriptor->Label = strdup("invada_sum_reverbER_module_0_1"); g_psSumReverbDescriptor->Name = strdup(":: Invada :: ER Reverb - Sum L+R In"); g_psSumReverbDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psSumReverbDescriptor->Copyright = strdup("(c) Invada Records"); g_psSumReverbDescriptor->PortCount = 14; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(14, sizeof(LADSPA_PortDescriptor)); g_psSumReverbDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IERR_ROOMLENGTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_ROOMWIDTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_ROOMHEIGHT] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_SOURCELR] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_SOURCEFB] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_DESTLR] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_DESTFB] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_HPF] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_WARMTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_DIFFUSION] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IERR_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IERR_AUDIO_OUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IERR_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IERR_AUDIO_IN2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(14, sizeof(char *)); g_psSumReverbDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IERR_ROOMLENGTH] = strdup("Room Length"); pcPortNames[IERR_ROOMWIDTH] = strdup("Room Width"); pcPortNames[IERR_ROOMHEIGHT] = strdup("Room Height"); pcPortNames[IERR_SOURCELR] = strdup("Source (L/R)"); pcPortNames[IERR_SOURCEFB] = strdup("Source (F/B)"); pcPortNames[IERR_DESTLR] = strdup("Listener (L/R)"); pcPortNames[IERR_DESTFB] = strdup("Listener (F/B)"); pcPortNames[IERR_HPF] = strdup("HPF (Hz)"); pcPortNames[IERR_WARMTH] = strdup("Warmth"); pcPortNames[IERR_DIFFUSION] = strdup("Diffusion"); pcPortNames[IERR_AUDIO_OUT1] = strdup("Output (Left)"); pcPortNames[IERR_AUDIO_OUT2] = strdup("Output (Right)"); pcPortNames[IERR_AUDIO_IN1] = strdup("Input (Left)"); pcPortNames[IERR_AUDIO_IN2] = strdup("Input (Right)"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(14, sizeof(LADSPA_PortRangeHint))); g_psSumReverbDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IERR_ROOMLENGTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[IERR_ROOMLENGTH].LowerBound = 3; psPortRangeHints[IERR_ROOMLENGTH].UpperBound = 100; psPortRangeHints[IERR_ROOMWIDTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[IERR_ROOMWIDTH].LowerBound = 3; psPortRangeHints[IERR_ROOMWIDTH].UpperBound = 100; psPortRangeHints[IERR_ROOMHEIGHT].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW); psPortRangeHints[IERR_ROOMHEIGHT].LowerBound = 3; psPortRangeHints[IERR_ROOMHEIGHT].UpperBound = 30; psPortRangeHints[IERR_SOURCELR].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_SOURCELR].LowerBound = 0.01; psPortRangeHints[IERR_SOURCELR].UpperBound = 0.99; psPortRangeHints[IERR_SOURCEFB].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_SOURCEFB].LowerBound = 0.55; psPortRangeHints[IERR_SOURCEFB].UpperBound = 1; psPortRangeHints[IERR_DESTLR].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_DESTLR].LowerBound = 0.01; psPortRangeHints[IERR_DESTLR].UpperBound = 0.99; psPortRangeHints[IERR_DESTFB].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_DESTFB].LowerBound = 0; psPortRangeHints[IERR_DESTFB].UpperBound = 0.45; psPortRangeHints[IERR_HPF].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_MINIMUM); psPortRangeHints[IERR_HPF].LowerBound = 0.001; psPortRangeHints[IERR_HPF].UpperBound = 0.05; psPortRangeHints[IERR_WARMTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_WARMTH].LowerBound = 0; psPortRangeHints[IERR_WARMTH].UpperBound = 1; psPortRangeHints[IERR_DIFFUSION].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IERR_DIFFUSION].LowerBound = 0; psPortRangeHints[IERR_DIFFUSION].UpperBound = 1; psPortRangeHints[IERR_AUDIO_OUT1].HintDescriptor = 0; psPortRangeHints[IERR_AUDIO_OUT2].HintDescriptor = 0; psPortRangeHints[IERR_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[IERR_AUDIO_IN2].HintDescriptor = 0; g_psSumReverbDescriptor->instantiate = instantiateIreverbER; g_psSumReverbDescriptor->connect_port = connectPortToIreverbER; g_psSumReverbDescriptor->activate = activateIreverbER; g_psSumReverbDescriptor->run = runISumreverbER; g_psSumReverbDescriptor->run_adding = NULL; g_psSumReverbDescriptor->set_run_adding_gain = NULL; g_psSumReverbDescriptor->deactivate = NULL; g_psSumReverbDescriptor->cleanup = cleanupIreverbER; } } void deleteDescriptor(LADSPA_Descriptor * psDescriptor) { unsigned long lIndex; if (psDescriptor) { free((char *)psDescriptor->Label); free((char *)psDescriptor->Name); free((char *)psDescriptor->Maker); free((char *)psDescriptor->Copyright); free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) free((char *)(psDescriptor->PortNames[lIndex])); free((char **)psDescriptor->PortNames); free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); free(psDescriptor); } } /* _fini() is called automatically when the library is unloaded. */ void _fini() { deleteDescriptor(g_psMonoReverbDescriptor); deleteDescriptor(g_psSumReverbDescriptor); } /* Return a descriptor of the requested plugin type. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index) { switch (Index) { case 0: return g_psMonoReverbDescriptor; case 1: return g_psSumReverbDescriptor; default: return NULL; } } void calculateIreverbER(LADSPA_Handle Instance) { IreverbER * plug; plug = (IreverbER *)Instance; LADSPA_Data SourceToLeft,SourceToRight,SourceToRear,SourceToFront; LADSPA_Data DestToLeft,DestToRight,DestToRear,DestToFront; LADSPA_Data RoofHeight,FloorDepth; LADSPA_Data DirectLength,DirectWidth,DirectHeight,DirectDistanceSQRD,DirectDistance; LADSPA_Data ERLength,ERWidth,ERHeight,MaxGain; LADSPA_Data convertedWidth,convertedLength,convertedHeight,convertedSourceLR,convertedSourceFB,convertedDestLR,convertedDestFB,convertedDiffusion; struct ERunit *er, *er2;; unsigned int TotalNum,Num,i; if (plug->LastRoomWidth < 3.0) convertedWidth = 3.0; else if (plug->LastRoomWidth <= 100.0) convertedWidth = plug->LastRoomWidth; else convertedWidth = 100.0; if (plug->LastRoomLength < 3.0) convertedLength = 3.0; else if (plug->LastRoomLength <= 100.0) convertedLength = plug->LastRoomLength; else convertedLength = 100.0; if (plug->LastRoomHeight < 3.0) convertedHeight = 3.0; else if (plug->LastRoomHeight <= 30.0) convertedHeight = plug->LastRoomHeight; else convertedHeight = 30.0; if (plug->LastSourceLR < -0.99) convertedSourceLR = -0.99; else if (plug->LastSourceLR <= 0.99) convertedSourceLR = plug->LastSourceLR; else convertedSourceLR = 0.99; if (plug->LastSourceFB < 0.51) convertedSourceFB = 0.51; else if (plug->LastSourceFB <= 0.99) convertedSourceFB = plug->LastSourceFB; else convertedSourceFB = 0.99; if (plug->LastDestLR < -0.99) convertedDestLR = -0.99; else if (plug->LastDestLR <= 0.99) convertedDestLR = plug->LastDestLR; else convertedDestLR = 0.99; if (plug->LastDestFB < 0.01) convertedDestFB = 0.01; else if (plug->LastDestFB <= 0.49) convertedDestFB = plug->LastDestFB; else convertedDestFB = 0.49; if (plug->LastDiffusion < 0.0) convertedDiffusion = 0.0; else if (plug->LastDiffusion <= 1.0) convertedDiffusion = plug->LastDiffusion; else convertedDiffusion = 1.0; SourceToLeft = convertedSourceLR * convertedWidth; SourceToRight= (1-convertedSourceLR) * convertedWidth; SourceToFront= convertedSourceFB * convertedLength; SourceToRear = (1>convertedSourceFB) * convertedLength; DestToLeft = convertedDestLR * convertedWidth; DestToRight= (1-convertedDestLR) * convertedWidth; DestToFront= convertedDestFB * convertedLength; DestToRear = (1-convertedDestFB) * convertedLength; RoofHeight = convertedHeight - OBJECT_HEIGHT; FloorDepth = OBJECT_HEIGHT; DirectLength = SourceToFront-DestToFront; DirectWidth = SourceToLeft-DestToLeft; DirectHeight =0; // both the source and the lisenter are at the same height DirectDistanceSQRD = pow(DirectLength,2)+pow(DirectWidth,2) < 1 ? 1 : pow(DirectLength,2)+pow(DirectWidth,2); DirectDistance = sqrt(DirectDistanceSQRD) < 1 ? 1 : sqrt(DirectDistanceSQRD); er=plug->er; Num=0; MaxGain=0.000000000001; /* this is used to scale up the reflections so that the loudest one has a gain of 1 (0db) */ /* seed the random sequence with a version of the diffusion */ srand48(314159265); // reflections from the left wall // 0: S->Left->D ERLength = DirectLength; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 1, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 1: S->BackWall->Left->D ERLength = SourceToRear + DestToRear; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 2: S->Right->Left->D ERLength = DirectLength; ERWidth = -(SourceToRight + convertedWidth + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 3: S->BackWall->Right->Left->D ERLength = SourceToRear + DestToRear; ERWidth = -(SourceToRight + convertedWidth + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 4: S->Left->Rigtht->Left->D ERLength = DirectLength; ERWidth = -(SourceToLeft + (2 * convertedWidth) + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 5: S->BackWall->Left->Right->Left->D ERLength = SourceToRear + DestToRear; ERWidth = -(SourceToLeft + (2 * convertedWidth) + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 4, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // reflections from the right wall // 6: S->Right->D ERLength = DirectLength; ERWidth = SourceToRight + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 1, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 7: S->BackWall->Right->D ERLength = SourceToRear + DestToRear; ERWidth = SourceToRight + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 8: S->Left->Right->D ERLength = DirectLength; ERWidth = SourceToLeft + convertedWidth + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 9: S->BackWall->Left->Right->D ERLength = SourceToRear + DestToRear; ERWidth = SourceToLeft + convertedWidth + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 10: S->Right->Left->Right->D ERLength = DirectLength; ERWidth = SourceToRight + (2 * convertedWidth) + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 11: S->BackWall->Right->Left->Right->D ERLength = SourceToRear + DestToRear; ERWidth = SourceToRight + (2 * convertedWidth) + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 4, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // reflections from the rear wall // 12: S->BackWall->D ERLength = SourceToRear + DestToRear; ERWidth = DirectWidth; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 1, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 13: S->NearWall->BackWall->D ERLength = SourceToFront + convertedLength + DestToRear; ERWidth = DirectWidth; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 14: S->Left->NearWall->BackWall->D ERLength = SourceToFront + convertedLength + DestToRear; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 15: S->Right->NearWall->BackWall->D ERLength = SourceToFront + convertedLength + DestToRear; ERWidth = SourceToRight + DestToRight; ERHeight = DirectHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // reflections from the roof // 16: S->Roof->Left->D ERLength = DirectLength; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = 2*RoofHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 17: S->Roof->Right->D ERLength = DirectLength; ERWidth = SourceToRight + DestToRight; ERHeight = 2*RoofHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 1, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 18: S->BackWall->Roof->Left->D ERLength = SourceToRear + DestToRear; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = 2*RoofHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 19: S->BackWall->Roof->Right->D ERLength = SourceToRear + DestToRear; ERWidth = SourceToRight + DestToRight; ERHeight = 2*RoofHeight; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // reflections from the floor // 20: S->Floor->Left->D ERLength = DirectLength; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = 2*FloorDepth; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 21: S->Floor->Right->D ERLength = DirectLength; ERWidth = SourceToRight + DestToRight; ERHeight = 2*FloorDepth; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, 1, 2, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // reflections from roof and floor // 22: S->Roof->Left->Floor->D ERLength = DirectLength; ERWidth = -(SourceToLeft + DestToLeft); ERHeight = 2*RoofHeight + 2*FloorDepth; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 23: S->Roof->Right->Floor->D ERLength = DirectLength; ERWidth = SourceToRight + DestToRight; ERHeight = 2*RoofHeight + 2*FloorDepth; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 3, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 24: S->Roof->Left->Floor->Right->Roof->D ERLength = DirectLength; ERWidth = -(SourceToLeft + DirectWidth + DestToLeft); ERHeight = 4*RoofHeight + 2*FloorDepth; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 5, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; // 25: S->Roof->Right->Floor->Left->Roof->D ERLength = DirectLength; ERWidth = SourceToRight + DirectWidth + DestToRight; ERHeight = 4*RoofHeight + 2*FloorDepth; calculateSingleIreverbER(er, ERWidth, ERLength, ERHeight, -1, 5, DirectDistance, plug->SampleRate); if(er->AbsGain > MaxGain) MaxGain=er->AbsGain; er++; Num++; er2=er; er=plug->er; TotalNum=Num; for(i=0;i 0 && 4*er->AbsGain/MaxGain > 1-convertedDiffusion) { er2->Active=1; er2->rand=er->rand; er2->DelayActual=er->DelayActual*(1.085+(er->rand*convertedDiffusion/7)); er2->Delay = (unsigned long)er2->DelayActual; er2->DelayOffset = er2->DelayActual - (float)er2->Delay; er2->Reflections=er->Reflections; er2->AbsGain=er->AbsGain*convertedDiffusion*0.6/MaxGain; er2->GainL=er->GainL*convertedDiffusion*0.6/MaxGain; er2->GainR=er->GainR*convertedDiffusion*0.6/MaxGain; TotalNum++; er2++; } //scale up reflection and calculate sample delay er->DelayActual=er->DelayActual*(1.01+(er->rand*convertedDiffusion/14)); er->Delay = (unsigned long)er->DelayActual; er->DelayOffset = er->DelayActual - (float)er->Delay; er->AbsGain=er->AbsGain/MaxGain; er->GainL=er->GainL/MaxGain; er->GainR=er->GainR/MaxGain; er++; } plug->er_size = TotalNum; } void calculateSingleIreverbER(struct ERunit * er, LADSPA_Data Width, LADSPA_Data Length, LADSPA_Data Height, int Phase, unsigned int Reflections, LADSPA_Data DDist, unsigned long sr) { LADSPA_Data ERAngle,ERDistanceSQRD,ERDistance,ERRelDelayActual,ERRelGain,ERRelGainL,ERRelGainR; ERAngle = atan(Width/Length); ERDistanceSQRD = pow(Length,2) + pow(Width,2)+ pow(Height,2); ERDistance = sqrt(ERDistanceSQRD); ERRelDelayActual = ((ERDistance-DDist) * (float)sr /SPEED_OF_SOUND); ERRelGain = Phase / ERDistanceSQRD; ERRelGainL = (ERRelGain * (1 - (ERAngle/PI_ON_2)))/2; ERRelGainR = (ERRelGain * (1 + (ERAngle/PI_ON_2)))/2; er->Active=1; er->rand=drand48(); er->DelayActual=ERRelDelayActual; er->Reflections=Reflections; er->AbsGain=fabs(ERRelGain); er->GainL=ERRelGainL; er->GainR=ERRelGainR; } LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr) { LADSPA_Data temp; LADSPA_Data result; switch(param) { case IERR_HPF: temp = value / (LADSPA_Data)sr; if (temp < 0.001) result = 500; else if (temp <= 0.05) result = 1/(2*temp); else result=10; break; case IERR_WARMTH: if(value<0) result= 1; else if (value < 1) result = pow(2,value*2); else result= 4; break; break; default: result=0; break; } return result; } invada-studio-plugins-0.3.1/inv_erreverb.h000066400000000000000000000032231123632614400206040ustar00rootroot00000000000000/* (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define REVERB_SPACE_SIZE 2 /* size in seconds */ #define MAX_ER 60 /* maximun number of early reflections to calculate */ #define SPEED_OF_SOUND 330 /* speed of sound in air in meters/second */ #define OBJECT_HEIGHT 1.5 /* the height of the sound source and the listener */ struct ERunit { int Active; LADSPA_Data rand; LADSPA_Data DelayActual; LADSPA_Data DelayOffset; unsigned long Delay; unsigned int Reflections; LADSPA_Data AbsGain; LADSPA_Data GainL; LADSPA_Data GainR; }; /* works out the reflection details */ void calculateIreverbER(LADSPA_Handle Instance); /* works out a single reflection */ void calculateSingleIreverbER(struct ERunit * er, LADSPA_Data Width, LADSPA_Data Length, LADSPA_Data Height, int Phase, unsigned int reflections, LADSPA_Data DDist, unsigned long sr); /* control conversion function */ LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr); invada-studio-plugins-0.3.1/inv_filter.c000066400000000000000000000640631123632614400202610ustar00rootroot00000000000000/* This LADSPA plugin provides mono and stereo filters (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "libinv_common.h" #include "inv_filter.h" /* The port numbers for the plugin: */ #define IFILTER_FREQ 0 #define IFILTER_GAIN 1 #define IFILTER_NOCLIP 2 #define IFILTER_AUDIO_IN1 3 #define IFILTER_AUDIO_OUT1 4 #define IFILTER_AUDIO_IN2 5 /* not used in mono mode */ #define IFILTER_AUDIO_OUT2 6 /* not used in mono mode */ /* The structure used to hold port connection information and state. */ typedef struct { unsigned long SampleRate; /* Ports */ LADSPA_Data * ControlFreq; LADSPA_Data * ControlGain; LADSPA_Data * ControlNoClip; LADSPA_Data * AudioInputBuffer1; LADSPA_Data * AudioOutputBuffer1; LADSPA_Data * AudioInputBuffer2; LADSPA_Data * AudioOutputBuffer2; /* stuff we need to remember to reduce cpu */ LADSPA_Data LastFreq; LADSPA_Data LastGain; LADSPA_Data LastNoClip; LADSPA_Data ConvertedFreq; LADSPA_Data ConvertedGain; LADSPA_Data ConvertedNoClip; /* stuff we need to remember between calls */ LADSPA_Data Audio1Last; LADSPA_Data Audio2Last; } Ifilter; /* Construct a new plugin instance. */ LADSPA_Handle instantiateIfilter(const LADSPA_Descriptor * Descriptor,unsigned long SampleRate) { LADSPA_Handle Instance; Ifilter * plug; if((Instance=malloc(sizeof(Ifilter)))==NULL) return NULL; /* set some initial params */ plug = (Ifilter *)Instance; /* should check SampleRate > 0 */ plug->SampleRate=SampleRate; return Instance; } /* Connect a port to a data location. */ void connectPortToIfilter(LADSPA_Handle Instance,unsigned long Port, LADSPA_Data * DataLocation) { Ifilter * plug; plug = (Ifilter *)Instance; switch (Port) { case IFILTER_FREQ: plug->ControlFreq = DataLocation; break; case IFILTER_GAIN: plug->ControlGain = DataLocation; break; case IFILTER_NOCLIP: plug->ControlNoClip = DataLocation; break; case IFILTER_AUDIO_IN1: plug->AudioInputBuffer1 = DataLocation; break; case IFILTER_AUDIO_OUT1: plug->AudioOutputBuffer1 = DataLocation; break; case IFILTER_AUDIO_IN2: plug->AudioInputBuffer2 = DataLocation; break; case IFILTER_AUDIO_OUT2: plug->AudioOutputBuffer2 = DataLocation; break; } } void activateIfilter(LADSPA_Handle Instance) { Ifilter * plug; plug = (Ifilter *)Instance; plug->Audio1Last = 0; plug->Audio2Last = 0; /* defaults */ plug->LastFreq = 0.015811388; // middle on a logarithmic scale plug->LastGain = 0; plug->LastNoClip = 0; plug->ConvertedFreq = convertParam(IFILTER_FREQ, plug->LastFreq, plug->SampleRate); plug->ConvertedGain = convertParam(IFILTER_GAIN, plug->LastGain, plug->SampleRate); plug->ConvertedNoClip = convertParam(IFILTER_NOCLIP, plug->LastNoClip, plug->SampleRate); } void runMonoLPFIfilter(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioOutput1; LADSPA_Data fSamples,fGain,fNoClip; LADSPA_Data fAudio1,fAudio1Sum; Ifilter * plug; unsigned long lSampleIndex; plug = (Ifilter *)Instance; pParamFunc = &convertParam; checkParamChange(IFILTER_FREQ, plug->ControlFreq, &(plug->LastFreq), &(plug->ConvertedFreq), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fSamples = plug->ConvertedFreq; fGain = plug->ConvertedGain; fNoClip = plug->ConvertedNoClip; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioOutput1 = plug->AudioOutputBuffer1; fAudio1Sum = plug->Audio1Last; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1Sum = ((fSamples-1) * fAudio1Sum + *(pfAudioInput1++)) / fSamples; fAudio1 = fAudio1Sum*fGain; *(pfAudioOutput1++)=fNoClip > 0 ? InoClip(fAudio1) : fAudio1; } plug->Audio1Last = (fabs(fAudio1Sum)<1.0e-10) ? 0.f : fAudio1Sum; // and store values for next loop } void runMonoHPFIfilter(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioOutput1; LADSPA_Data fSamples,fGain,fNoClip; LADSPA_Data fAudio1,fAudio1Sum; Ifilter * plug; unsigned long lSampleIndex; plug = (Ifilter *)Instance; pParamFunc = &convertParam; checkParamChange(IFILTER_FREQ, plug->ControlFreq, &(plug->LastFreq), &(plug->ConvertedFreq), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fSamples = plug->ConvertedFreq; fGain = plug->ConvertedGain; fNoClip = plug->ConvertedNoClip; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioOutput1 = plug->AudioOutputBuffer1; fAudio1Sum = plug->Audio1Last; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1 = *(pfAudioInput1++); fAudio1Sum = ((fSamples-1) * fAudio1Sum + fAudio1) / fSamples; fAudio1 = (fAudio1 - fAudio1Sum)*fGain; *(pfAudioOutput1++)=fNoClip > 0 ? InoClip(fAudio1) : fAudio1; } plug->Audio1Last = (fabs(fAudio1Sum)<1.0e-10) ? 0.f : fAudio1Sum; // and store values for next loop } void runStereoLPFIfilter(LADSPA_Handle Instance,unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioInput2; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data fSamples,fGain,fNoClip; LADSPA_Data fAudio1,fAudio2,fAudio1Sum,fAudio2Sum; Ifilter * plug; unsigned long lSampleIndex; plug = (Ifilter *)Instance; pParamFunc = &convertParam; checkParamChange(IFILTER_FREQ, plug->ControlFreq, &(plug->LastFreq), &(plug->ConvertedFreq), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fSamples = plug->ConvertedFreq; fGain = plug->ConvertedGain; fNoClip = plug->ConvertedNoClip; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioInput2 = plug->AudioInputBuffer2; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; fAudio1Sum = plug->Audio1Last; fAudio2Sum = plug->Audio2Last; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1Sum = ((fSamples-1) * fAudio1Sum + *(pfAudioInput1++)) / fSamples; fAudio2Sum = ((fSamples-1) * fAudio2Sum + *(pfAudioInput2++)) / fSamples; fAudio1 = fAudio1Sum*fGain; fAudio2 = fAudio2Sum*fGain; *(pfAudioOutput1++)=fNoClip > 0 ? InoClip(fAudio1) : fAudio1; *(pfAudioOutput2++)=fNoClip > 0 ? InoClip(fAudio2) : fAudio2; } plug->Audio1Last = (fabs(fAudio1Sum)<1.0e-10) ? 0.f : fAudio1Sum; // and store values for next loop plug->Audio2Last = (fabs(fAudio2Sum)<1.0e-10) ? 0.f : fAudio2Sum; // and store values for next loop } void runStereoHPFIfilter(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioInput2; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data fSamples,fGain,fNoClip; LADSPA_Data fAudio1,fAudio2,fAudio1Sum,fAudio2Sum; Ifilter * plug; unsigned long lSampleIndex; plug = (Ifilter *)Instance; pParamFunc = &convertParam; checkParamChange(IFILTER_FREQ, plug->ControlFreq, &(plug->LastFreq), &(plug->ConvertedFreq), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(IFILTER_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fSamples = plug->ConvertedFreq; fGain = plug->ConvertedGain; fNoClip = plug->ConvertedNoClip; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioInput2 = plug->AudioInputBuffer2; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; fAudio1Sum = plug->Audio1Last; fAudio2Sum = plug->Audio2Last; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1 = *(pfAudioInput1++); fAudio2 = *(pfAudioInput2++); fAudio1Sum = ((fSamples-1) * fAudio1Sum + fAudio1) / fSamples; fAudio2Sum = ((fSamples-1) * fAudio2Sum + fAudio2) / fSamples; fAudio1 = (fAudio1 - fAudio1Sum)*fGain; fAudio2 = (fAudio2 - fAudio2Sum)*fGain; *(pfAudioOutput1++)=fNoClip > 0 ? InoClip(fAudio1) : fAudio1; *(pfAudioOutput2++)=fNoClip > 0 ? InoClip(fAudio2) : fAudio2; } plug->Audio1Last = (fabs(fAudio1Sum)<1.0e-10) ? 0.f : fAudio1Sum; // and store values for next loop plug->Audio2Last = (fabs(fAudio2Sum)<1.0e-10) ? 0.f : fAudio2Sum; // and store values for next loop } /* Throw away. */ void cleanupIfilter(LADSPA_Handle Instance) { free(Instance); } LADSPA_Descriptor * g_psMonoLPFDescriptor = NULL; LADSPA_Descriptor * g_psMonoHPFDescriptor = NULL; LADSPA_Descriptor * g_psStereoLPFDescriptor = NULL; LADSPA_Descriptor * g_psStereoHPFDescriptor = NULL; /* _init() is called automatically when the plugin library is first loaded. */ void _init() { char ** pcPortNames; LADSPA_PortDescriptor * piPortDescriptors; LADSPA_PortRangeHint * psPortRangeHints; g_psMonoLPFDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); g_psMonoHPFDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); g_psStereoLPFDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); g_psStereoHPFDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); if (g_psMonoLPFDescriptor) { g_psMonoLPFDescriptor->UniqueID = 3302; g_psMonoLPFDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psMonoLPFDescriptor->Label = strdup("invada_lp_mono_filter_module_0_1"); g_psMonoLPFDescriptor->Name = strdup(":: Invada :: Filter - Low Pass Mono"); g_psMonoLPFDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psMonoLPFDescriptor->Copyright = strdup("(c) Invada Records"); g_psMonoLPFDescriptor->PortCount = 5; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(5, sizeof(LADSPA_PortDescriptor)); g_psMonoLPFDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IFILTER_FREQ] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(5, sizeof(char *)); g_psMonoLPFDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IFILTER_FREQ] = strdup("Frequency (Hz)"); pcPortNames[IFILTER_GAIN] = strdup("Gain (dB)"); pcPortNames[IFILTER_NOCLIP] = strdup("Soft Clip"); pcPortNames[IFILTER_AUDIO_IN1] = strdup("Input"); pcPortNames[IFILTER_AUDIO_OUT1] = strdup("Output"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(5, sizeof(LADSPA_PortRangeHint))); g_psMonoLPFDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IFILTER_FREQ].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IFILTER_FREQ].LowerBound = 0.0005; psPortRangeHints[IFILTER_FREQ].UpperBound = 0.5; psPortRangeHints[IFILTER_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IFILTER_GAIN].LowerBound = 0; psPortRangeHints[IFILTER_GAIN].UpperBound = 12; psPortRangeHints[IFILTER_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IFILTER_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_OUT1].HintDescriptor = 0; g_psMonoLPFDescriptor->instantiate = instantiateIfilter; g_psMonoLPFDescriptor->connect_port = connectPortToIfilter; g_psMonoLPFDescriptor->activate = activateIfilter; g_psMonoLPFDescriptor->run = runMonoLPFIfilter; g_psMonoLPFDescriptor->run_adding = NULL; g_psMonoLPFDescriptor->set_run_adding_gain = NULL; g_psMonoLPFDescriptor->deactivate = NULL; g_psMonoLPFDescriptor->cleanup = cleanupIfilter; } if (g_psMonoHPFDescriptor) { g_psMonoHPFDescriptor->UniqueID = 3303; g_psMonoHPFDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psMonoHPFDescriptor->Label = strdup("invada_hp_mono_filter_module_0_1"); g_psMonoHPFDescriptor->Name = strdup(":: Invada :: Filter - High Pass Mono"); g_psMonoHPFDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psMonoHPFDescriptor->Copyright = strdup("(c) Invada Records"); g_psMonoHPFDescriptor->PortCount = 5; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(5, sizeof(LADSPA_PortDescriptor)); g_psMonoHPFDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IFILTER_FREQ] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(5, sizeof(char *)); g_psMonoHPFDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IFILTER_FREQ] = strdup("Frequency (Hz)"); pcPortNames[IFILTER_GAIN] = strdup("Gain (dB)"); pcPortNames[IFILTER_NOCLIP] = strdup("Soft Clip"); pcPortNames[IFILTER_AUDIO_IN1] = strdup("Input"); pcPortNames[IFILTER_AUDIO_OUT1] = strdup("Output"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(5, sizeof(LADSPA_PortRangeHint))); g_psMonoHPFDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IFILTER_FREQ].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IFILTER_FREQ].LowerBound = 0.0005; psPortRangeHints[IFILTER_FREQ].UpperBound = 0.5; psPortRangeHints[IFILTER_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IFILTER_GAIN].LowerBound = 0; psPortRangeHints[IFILTER_GAIN].UpperBound = 12; psPortRangeHints[IFILTER_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IFILTER_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_OUT1].HintDescriptor = 0; g_psMonoHPFDescriptor->instantiate = instantiateIfilter; g_psMonoHPFDescriptor->connect_port = connectPortToIfilter; g_psMonoHPFDescriptor->activate = activateIfilter; g_psMonoHPFDescriptor->run = runMonoHPFIfilter; g_psMonoHPFDescriptor->run_adding = NULL; g_psMonoHPFDescriptor->set_run_adding_gain = NULL; g_psMonoHPFDescriptor->deactivate = NULL; g_psMonoHPFDescriptor->cleanup = cleanupIfilter; } if (g_psStereoLPFDescriptor) { g_psStereoLPFDescriptor->UniqueID = 3304; g_psStereoLPFDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psStereoLPFDescriptor->Label = strdup("invada_lp_stereo_filter_module_0_1"); g_psStereoLPFDescriptor->Name = strdup(":: Invada :: Filter - Low Pass Stereo"); g_psStereoLPFDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psStereoLPFDescriptor->Copyright = strdup("(c) Invada Records"); g_psStereoLPFDescriptor->PortCount = 7; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(7, sizeof(LADSPA_PortDescriptor)); g_psStereoLPFDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IFILTER_FREQ] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_IN2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_OUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(7, sizeof(char *)); g_psStereoLPFDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IFILTER_FREQ] = strdup("Frequency (Hz)"); pcPortNames[IFILTER_GAIN] = strdup("Gain (dB)"); pcPortNames[IFILTER_NOCLIP] = strdup("Soft Clip"); pcPortNames[IFILTER_AUDIO_IN1] = strdup("Input (Left)"); pcPortNames[IFILTER_AUDIO_OUT1] = strdup("Output (Left)"); pcPortNames[IFILTER_AUDIO_IN2] = strdup("Input (Right)"); pcPortNames[IFILTER_AUDIO_OUT2] = strdup("Output (Right)"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(7, sizeof(LADSPA_PortRangeHint))); g_psStereoLPFDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IFILTER_FREQ].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IFILTER_FREQ].LowerBound = 0.0005; psPortRangeHints[IFILTER_FREQ].UpperBound = 0.5; psPortRangeHints[IFILTER_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IFILTER_GAIN].LowerBound = 0; psPortRangeHints[IFILTER_GAIN].UpperBound = 12; psPortRangeHints[IFILTER_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IFILTER_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_OUT1].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_IN2].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_OUT2].HintDescriptor = 0; g_psStereoLPFDescriptor->instantiate = instantiateIfilter; g_psStereoLPFDescriptor->connect_port = connectPortToIfilter; g_psStereoLPFDescriptor->activate = activateIfilter; g_psStereoLPFDescriptor->run = runStereoLPFIfilter; g_psStereoLPFDescriptor->run_adding = NULL; g_psStereoLPFDescriptor->set_run_adding_gain = NULL; g_psStereoLPFDescriptor->deactivate = NULL; g_psStereoLPFDescriptor->cleanup = cleanupIfilter; } if (g_psStereoHPFDescriptor) { g_psStereoHPFDescriptor->UniqueID = 3305; g_psStereoHPFDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psStereoHPFDescriptor->Label = strdup("invada_hp_stereo_filter_module_0_1"); g_psStereoHPFDescriptor->Name = strdup(":: Invada :: Filter - High Pass Stereo"); g_psStereoHPFDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psStereoHPFDescriptor->Copyright = strdup("(c) Invada Records"); g_psStereoHPFDescriptor->PortCount = 7; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(7, sizeof(LADSPA_PortDescriptor)); g_psStereoHPFDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IFILTER_FREQ] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IFILTER_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_IN2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IFILTER_AUDIO_OUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(7, sizeof(char *)); g_psStereoHPFDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IFILTER_FREQ] = strdup("Frequency (Hz)"); pcPortNames[IFILTER_GAIN] = strdup("Gain (dB)"); pcPortNames[IFILTER_NOCLIP] = strdup("Soft Clip"); pcPortNames[IFILTER_AUDIO_IN1] = strdup("Input (Left)"); pcPortNames[IFILTER_AUDIO_OUT1] = strdup("Output (Left)"); pcPortNames[IFILTER_AUDIO_IN2] = strdup("Input (Right)"); pcPortNames[IFILTER_AUDIO_OUT2] = strdup("Output (Right)"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(7, sizeof(LADSPA_PortRangeHint))); g_psStereoHPFDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IFILTER_FREQ].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_MIDDLE); psPortRangeHints[IFILTER_FREQ].LowerBound = 0.0005; psPortRangeHints[IFILTER_FREQ].UpperBound = 0.5; psPortRangeHints[IFILTER_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IFILTER_GAIN].LowerBound = 0; psPortRangeHints[IFILTER_GAIN].UpperBound = 12; psPortRangeHints[IFILTER_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IFILTER_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_OUT1].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_IN2].HintDescriptor = 0; psPortRangeHints[IFILTER_AUDIO_OUT2].HintDescriptor = 0; g_psStereoHPFDescriptor->instantiate = instantiateIfilter; g_psStereoHPFDescriptor->connect_port = connectPortToIfilter; g_psStereoHPFDescriptor->activate = activateIfilter; g_psStereoHPFDescriptor->run = runStereoHPFIfilter; g_psStereoHPFDescriptor->run_adding = NULL; g_psStereoHPFDescriptor->set_run_adding_gain = NULL; g_psStereoHPFDescriptor->deactivate = NULL; g_psStereoHPFDescriptor->cleanup = cleanupIfilter; } } void deleteDescriptor(LADSPA_Descriptor * psDescriptor) { unsigned long lIndex; if (psDescriptor) { free((char *)psDescriptor->Label); free((char *)psDescriptor->Name); free((char *)psDescriptor->Maker); free((char *)psDescriptor->Copyright); free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) free((char *)(psDescriptor->PortNames[lIndex])); free((char **)psDescriptor->PortNames); free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); free(psDescriptor); } } /* _fini() is called automatically when the library is unloaded. */ void _fini() { deleteDescriptor(g_psMonoLPFDescriptor); deleteDescriptor(g_psMonoHPFDescriptor); deleteDescriptor(g_psStereoLPFDescriptor); deleteDescriptor(g_psStereoHPFDescriptor); } /* Return a descriptor of the requested plugin type. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index) { switch (Index) { case 0: return g_psMonoLPFDescriptor; case 1: return g_psMonoHPFDescriptor; case 2: return g_psStereoLPFDescriptor; case 3: return g_psStereoHPFDescriptor; default: return NULL; } } LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr) { LADSPA_Data temp; LADSPA_Data result; switch(param) { case IFILTER_FREQ: temp = value / (LADSPA_Data)sr; if (temp < 0.0005) result = 1000; else if (temp <= 0.5) result = 1/(2*temp); else result=1; break; case IFILTER_GAIN: if(value<0) result= 1; else if (value < 12) result = pow(10,value/20); else result= pow(10,0.6); break; case IFILTER_NOCLIP: if(value<0.5) result= 0; else result= 1; break; default: result=0; break; } return result; } invada-studio-plugins-0.3.1/inv_filter.h000066400000000000000000000015351123632614400202610ustar00rootroot00000000000000/* (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* control conversion function */ LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr); invada-studio-plugins-0.3.1/inv_input.c000066400000000000000000000322251123632614400201260ustar00rootroot00000000000000/* This LADSPA plugin provides a stereo input module (c) Fraser Stuart 2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "libinv_common.h" #include "inv_input.h" /* The port numbers for the plugin: */ #define IINPUT_PHASE1 0 #define IINPUT_PHASE2 1 #define IINPUT_GAIN 2 #define IINPUT_PAN 3 #define IINPUT_WIDTH 4 #define IINPUT_NOCLIP 5 #define IINPUT_AUDIO_IN1 6 #define IINPUT_AUDIO_IN2 7 #define IINPUT_AUDIO_OUT1 8 #define IINPUT_AUDIO_OUT2 9 /* The structure used to hold port connection information and state */ typedef struct { unsigned long SampleRate; /* Ports */ LADSPA_Data * ControlPhase1; LADSPA_Data * ControlPhase2; LADSPA_Data * ControlGain; LADSPA_Data * ControlPan; LADSPA_Data * ControlWidth; LADSPA_Data * ControlNoClip; LADSPA_Data * AudioInputBuffer1; LADSPA_Data * AudioInputBuffer2; LADSPA_Data * AudioOutputBuffer1; LADSPA_Data * AudioOutputBuffer2; /* stuff we need to remember to reduce cpu */ LADSPA_Data LastPhase1; LADSPA_Data LastPhase2; LADSPA_Data LastGain; LADSPA_Data LastPan; LADSPA_Data LastWidth; LADSPA_Data LastNoClip; LADSPA_Data ConvertedPhase1; LADSPA_Data ConvertedPhase2; LADSPA_Data ConvertedGain; LADSPA_Data ConvertedPan; LADSPA_Data ConvertedWidth; LADSPA_Data ConvertedNoClip; } Iinput; /* Construct a new plugin instance. */ LADSPA_Handle instantiateIinput(const LADSPA_Descriptor * Descriptor,unsigned long SampleRate) { LADSPA_Handle Instance; Iinput * plug; if((Instance=malloc(sizeof(Iinput)))==NULL) return NULL; /* set some initial params */ plug = (Iinput *)Instance; /* should check SampleRate > 0 */ plug->SampleRate=SampleRate; return Instance; } /* Connect a port to a data location. */ void connectPortToIinput(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data * DataLocation) { Iinput * plug; plug = (Iinput *)Instance; switch (Port) { case IINPUT_PHASE1: plug->ControlPhase1 = DataLocation; break; case IINPUT_PHASE2: plug->ControlPhase2 = DataLocation; break; case IINPUT_GAIN: plug->ControlGain = DataLocation; break; case IINPUT_PAN: plug->ControlPan = DataLocation; break; case IINPUT_WIDTH: plug->ControlWidth = DataLocation; break; case IINPUT_NOCLIP: plug->ControlNoClip = DataLocation; break; case IINPUT_AUDIO_IN1: plug->AudioInputBuffer1 = DataLocation; break; case IINPUT_AUDIO_IN2: plug->AudioInputBuffer2 = DataLocation; break; case IINPUT_AUDIO_OUT1: plug->AudioOutputBuffer1 = DataLocation; break; case IINPUT_AUDIO_OUT2: plug->AudioOutputBuffer2 = DataLocation; break; } } void activateIinput(LADSPA_Handle Instance) { Iinput * plug; plug = (Iinput *)Instance; /* these values force the conversion to take place */ plug->LastPhase1 = 0; plug->LastPhase2 = 0; plug->LastGain = 0; plug->LastPan = 0; plug->LastWidth = 0; plug->LastNoClip = 0; plug->ConvertedPhase1 = convertParam(IINPUT_PHASE1, plug->LastPhase1, plug->SampleRate); plug->ConvertedPhase2 = convertParam(IINPUT_PHASE2, plug->LastPhase2, plug->SampleRate); plug->ConvertedGain = convertParam(IINPUT_GAIN, plug->LastGain, plug->SampleRate); plug->ConvertedPan = convertParam(IINPUT_PAN, plug->LastPan, plug->SampleRate); plug->ConvertedWidth = convertParam(IINPUT_WIDTH, plug->LastWidth, plug->SampleRate); plug->ConvertedNoClip = convertParam(IINPUT_NOCLIP, plug->LastNoClip, plug->SampleRate); } void runStereoIinput(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioInput2; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data fPhase1,fPhase2,fGain,fPan,fLPan,fRPan,fWidth,fMono,fStereoL,fStereoR,fNoClip; LADSPA_Data fAudio1,fAudio2; Iinput * plug; unsigned long lSampleIndex; plug = (Iinput *)Instance; pParamFunc = &convertParam; checkParamChange(IINPUT_PHASE1, plug->ControlPhase1, &(plug->LastPhase1), &(plug->ConvertedPhase1), plug->SampleRate, pParamFunc); checkParamChange(IINPUT_PHASE2, plug->ControlPhase2, &(plug->LastPhase2), &(plug->ConvertedPhase2), plug->SampleRate, pParamFunc); checkParamChange(IINPUT_GAIN, plug->ControlGain, &(plug->LastGain), &(plug->ConvertedGain), plug->SampleRate, pParamFunc); checkParamChange(IINPUT_PAN, plug->ControlPan, &(plug->LastPan), &(plug->ConvertedPan), plug->SampleRate, pParamFunc); checkParamChange(IINPUT_WIDTH, plug->ControlWidth, &(plug->LastWidth), &(plug->ConvertedWidth), plug->SampleRate, pParamFunc); checkParamChange(IINPUT_NOCLIP, plug->ControlNoClip, &(plug->LastNoClip), &(plug->ConvertedNoClip), plug->SampleRate, pParamFunc); fPhase1 = plug->ConvertedPhase1; fPhase2 = plug->ConvertedPhase2; fGain = plug->ConvertedGain; fPan = plug->ConvertedPan; fWidth = plug->ConvertedWidth; fNoClip = plug->ConvertedNoClip; fLPan=1-fPan; fRPan=1+fPan; pfAudioInput1 = plug->AudioInputBuffer1; pfAudioInput2 = plug->AudioInputBuffer2; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1 = fPhase1 > 0 ? -(*(pfAudioInput1++)) : *(pfAudioInput1++) ; fAudio2 = fPhase2 > 0 ? -(*(pfAudioInput2++)) : *(pfAudioInput2++) ; fAudio1 *= fGain; fAudio2 *= fGain; fAudio1 *= fLPan; fAudio2 *= fRPan; if(fWidth<=0) { fMono = (fAudio1 + fAudio2) / 2; fAudio1 = (1+fWidth)*fAudio1 - fWidth*fMono; fAudio2 = (1+fWidth)*fAudio2 - fWidth*fMono; } else { fStereoL = (fAudio1 - fAudio2) / 2; fStereoR = (fAudio2 - fAudio1) / 2; fAudio1 = (1-fWidth)*fAudio1 + fWidth*fStereoL; fAudio2 = (1-fWidth)*fAudio2 + fWidth*fStereoR; } fAudio1 = fNoClip > 0 ? InoClip(fAudio1) : fAudio1; fAudio2 = fNoClip > 0 ? InoClip(fAudio2) : fAudio2; *(pfAudioOutput1++) = fAudio1; *(pfAudioOutput2++) = fAudio2; } } void cleanupIinput(LADSPA_Handle Instance) { free(Instance); } LADSPA_Descriptor * g_psStereoDescriptor = NULL; /* _init() is called automatically when the plugin library is first loaded. */ void _init() { char ** pcPortNames; LADSPA_PortDescriptor * piPortDescriptors; LADSPA_PortRangeHint * psPortRangeHints; g_psStereoDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); if (g_psStereoDescriptor) { g_psStereoDescriptor->UniqueID = 3301; g_psStereoDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psStereoDescriptor->Label = strdup("invada_stereo_input_module_0_1"); g_psStereoDescriptor->Name = strdup(":: Invada :: Input Module"); g_psStereoDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psStereoDescriptor->Copyright = strdup("(c) Invada Records"); g_psStereoDescriptor->PortCount = 10; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(10, sizeof(LADSPA_PortDescriptor)); g_psStereoDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[IINPUT_PHASE1] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IINPUT_PHASE2] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IINPUT_GAIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IINPUT_PAN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IINPUT_WIDTH] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IINPUT_NOCLIP] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[IINPUT_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IINPUT_AUDIO_IN2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IINPUT_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[IINPUT_AUDIO_OUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(10, sizeof(char *)); g_psStereoDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[IINPUT_PHASE1] = strdup("Phase Reverse (Left)"); pcPortNames[IINPUT_PHASE2] = strdup("Phase Reverse (Right)"); pcPortNames[IINPUT_GAIN] = strdup("Gain (dB)"); pcPortNames[IINPUT_PAN] = strdup("Pan (L-R)"); pcPortNames[IINPUT_WIDTH] = strdup("Width (M-S)"); pcPortNames[IINPUT_NOCLIP] = strdup("Soft Clip"); pcPortNames[IINPUT_AUDIO_IN1] = strdup("Input (Left)"); pcPortNames[IINPUT_AUDIO_IN2] = strdup("Input (Right)"); pcPortNames[IINPUT_AUDIO_OUT1] = strdup("Output (Left)"); pcPortNames[IINPUT_AUDIO_OUT2] = strdup("Output (Right)"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(10, sizeof(LADSPA_PortRangeHint))); g_psStereoDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[IINPUT_PHASE1].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IINPUT_PHASE2].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IINPUT_GAIN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IINPUT_GAIN].LowerBound = -24; psPortRangeHints[IINPUT_GAIN].UpperBound = 24; psPortRangeHints[IINPUT_PAN].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IINPUT_PAN].LowerBound = -1.0; psPortRangeHints[IINPUT_PAN].UpperBound = 1.0; psPortRangeHints[IINPUT_WIDTH].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[IINPUT_WIDTH].LowerBound = -1.0; psPortRangeHints[IINPUT_WIDTH].UpperBound = 1.0; psPortRangeHints[IINPUT_NOCLIP].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[IINPUT_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[IINPUT_AUDIO_IN2].HintDescriptor = 0; psPortRangeHints[IINPUT_AUDIO_OUT1].HintDescriptor = 0; psPortRangeHints[IINPUT_AUDIO_OUT2].HintDescriptor = 0; g_psStereoDescriptor->instantiate = instantiateIinput; g_psStereoDescriptor->connect_port = connectPortToIinput; g_psStereoDescriptor->activate = activateIinput; g_psStereoDescriptor->run = runStereoIinput; g_psStereoDescriptor->run_adding = NULL; g_psStereoDescriptor->set_run_adding_gain = NULL; g_psStereoDescriptor->deactivate = NULL; g_psStereoDescriptor->cleanup = cleanupIinput; } } /*****************************************************************************/ void deleteDescriptor(LADSPA_Descriptor * psDescriptor) { unsigned long lIndex; if (psDescriptor) { free((char *)psDescriptor->Label); free((char *)psDescriptor->Name); free((char *)psDescriptor->Maker); free((char *)psDescriptor->Copyright); free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) free((char *)(psDescriptor->PortNames[lIndex])); free((char **)psDescriptor->PortNames); free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); free(psDescriptor); } } /* _fini() is called automatically when the library is unloaded. */ void _fini() { deleteDescriptor(g_psStereoDescriptor); } /* Return a descriptor of the requested plugin type. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index) { switch (Index) { case 0: return g_psStereoDescriptor; default: return NULL; } } LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr) { LADSPA_Data result; switch(param) { case IINPUT_PHASE1: case IINPUT_PHASE2: if(value<0.5) result= 0; else result= 1; break; case IINPUT_GAIN: if(value<-24) result= pow(10, -24/20); else if (value < 24) result= pow(10, value/20); else result= pow(10, 1.2); break; case IINPUT_PAN: case IINPUT_WIDTH: if(value < -1) result= -1; else if (value < 1) result= value; else result= 1; break; case IINPUT_NOCLIP: if(value<0.5) result= 0; else result= 1; break; default: result=0; break; } return result; } invada-studio-plugins-0.3.1/inv_input.h000066400000000000000000000015361123632614400201340ustar00rootroot00000000000000/* (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* control conversion function */ LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr); invada-studio-plugins-0.3.1/inv_plugins.rdf000066400000000000000000000064451123632614400210060ustar00rootroot00000000000000 ]> :: Invada :: Input Module Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Filter - Low Pass Mono Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Filter - High Pass Mono Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Filter - Low Pass Stereo Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Filter - High Pass Stereo Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Tube - Mono Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Tube - Stereo Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Compressor - Mono Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: Compressor - Stereo Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: ER Reverb - Mono In Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later :: Invada :: ER Reverb - Sum L+R In Fraser At Invada Records dot Com GNU General Public Licence Version 2 or Later invada-studio-plugins-0.3.1/inv_tube.c000066400000000000000000000421021123632614400177210ustar00rootroot00000000000000/* This LADSPA plugin provides tube distortion (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "libinv_common.h" #include "inv_tube.h" /* The port numbers for the plugin: */ #define ITUBE_DRIVE 0 #define ITUBE_DCOFFSET 1 #define ITUBE_PHASE 2 #define ITUBE_MIX 3 #define ITUBE_AUDIO_IN1 4 #define ITUBE_AUDIO_OUT1 5 #define ITUBE_AUDIO_IN2 6 /* not used in mono mode */ #define ITUBE_AUDIO_OUT2 7 /* not used in mono mode */ /* The structure used to hold port connection information and state (actually gain controls require no further state). */ typedef struct { unsigned long SampleRate; /* Ports */ LADSPA_Data * ControlDrive; LADSPA_Data * ControlDcoffset; LADSPA_Data * ControlPhase; LADSPA_Data * ControlMix; LADSPA_Data * AudioInputBuffer1; LADSPA_Data * AudioOutputBuffer1; LADSPA_Data * AudioInputBuffer2; LADSPA_Data * AudioOutputBuffer2; /* params with complex conversions get remembered */ LADSPA_Data LastDrive; LADSPA_Data LastDcoffset; LADSPA_Data LastPhase; LADSPA_Data LastMix; LADSPA_Data ConvertedDrive; LADSPA_Data ConvertedDcoffset; LADSPA_Data ConvertedPhase; LADSPA_Data ConvertedMix; } Itube; /*****************************************************************************/ /* Construct a new plugin instance. */ LADSPA_Handle instantiateItube(const LADSPA_Descriptor * Descriptor, unsigned long SampleRate) { LADSPA_Handle Instance; Itube * plug; if((Instance=malloc(sizeof(Itube)))==NULL) return NULL; /* set some initial params */ plug = (Itube *)Instance; /* should check SampleRate > 0 */ plug->SampleRate=SampleRate; return Instance; } /*****************************************************************************/ /* Connect a port to a data location. */ void connectPortToItube(LADSPA_Handle Instance,unsigned long Port,LADSPA_Data * DataLocation) { Itube * plug; plug = (Itube *)Instance; switch (Port) { case ITUBE_DRIVE: plug->ControlDrive = DataLocation; break; case ITUBE_DCOFFSET: plug->ControlDcoffset = DataLocation; break; case ITUBE_PHASE: plug->ControlPhase = DataLocation; break; case ITUBE_MIX: plug->ControlMix = DataLocation; break; case ITUBE_AUDIO_IN1: plug->AudioInputBuffer1 = DataLocation; break; case ITUBE_AUDIO_OUT1: plug->AudioOutputBuffer1 = DataLocation; break; case ITUBE_AUDIO_IN2: plug->AudioInputBuffer2 = DataLocation; break; case ITUBE_AUDIO_OUT2: plug->AudioOutputBuffer2 = DataLocation; break; } } void activateItube(LADSPA_Handle Instance) { Itube * plug; plug = (Itube *)Instance; /* set some defaults */ plug->LastDrive=0; plug->LastDcoffset=0; plug->LastPhase=0; plug->LastMix=75; plug->ConvertedDrive = convertParam(ITUBE_DRIVE, plug->LastDrive, plug->SampleRate); plug->ConvertedDcoffset = convertParam(ITUBE_DCOFFSET, plug->LastDcoffset, plug->SampleRate); plug->ConvertedPhase = convertParam(ITUBE_PHASE, plug->LastPhase, plug->SampleRate); plug->ConvertedMix = convertParam(ITUBE_MIX, plug->LastMix, plug->SampleRate); } void runMonoItube(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioOutput1; LADSPA_Data fAudio1, fDrive, fDCOffset, fPhase, fMix, fDCOffsetADJ; Itube * plug; unsigned long lSampleIndex; plug = (Itube *)Instance; pParamFunc = &convertParam; /* check for any params changes */ checkParamChange(ITUBE_DRIVE, plug->ControlDrive, &(plug->LastDrive), &(plug->ConvertedDrive), plug->SampleRate, pParamFunc); checkParamChange(ITUBE_DCOFFSET, plug->ControlDcoffset, &(plug->LastDcoffset), &(plug->ConvertedDcoffset), plug->SampleRate, pParamFunc); checkParamChange(ITUBE_PHASE, plug->ControlPhase, &(plug->LastPhase), &(plug->ConvertedPhase), plug->SampleRate, pParamFunc); checkParamChange(ITUBE_MIX, plug->ControlMix, &(plug->LastMix), &(plug->ConvertedMix), plug->SampleRate, pParamFunc); fDrive = plug->ConvertedDrive; fDCOffset = plug->ConvertedDcoffset; fPhase = plug->ConvertedPhase; fMix = plug->ConvertedMix; fDCOffsetADJ = ITube(fDCOffset,fDrive); pfAudioInput1 = plug->AudioInputBuffer1; pfAudioOutput1 = plug->AudioOutputBuffer1; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1=*(pfAudioInput1++); *(pfAudioOutput1++) = fPhase <= 0 ? (fAudio1*(1-fMix)) + (ITube(fAudio1 + fDCOffset,fDrive)-fDCOffsetADJ)*fMix : (fAudio1*(1-fMix)) - (ITube(fAudio1 + fDCOffset,fDrive)-fDCOffsetADJ)*fMix ; } } void runStereoItube(LADSPA_Handle Instance, unsigned long SampleCount) { LADSPA_Data (*pParamFunc)(unsigned long, LADSPA_Data, unsigned long) = NULL; LADSPA_Data * pfAudioInput1; LADSPA_Data * pfAudioInput2; LADSPA_Data * pfAudioOutput1; LADSPA_Data * pfAudioOutput2; LADSPA_Data fAudio1, fAudio2, fDrive, fDCOffset, fPhase, fMix, fDCOffsetADJ; Itube * plug; unsigned long lSampleIndex; plug = (Itube *)Instance; pParamFunc = &convertParam; /* check for any params changes */ checkParamChange(ITUBE_DRIVE, plug->ControlDrive, &(plug->LastDrive), &(plug->ConvertedDrive), plug->SampleRate, pParamFunc); checkParamChange(ITUBE_DCOFFSET, plug->ControlDcoffset, &(plug->LastDcoffset), &(plug->ConvertedDcoffset), plug->SampleRate, pParamFunc); checkParamChange(ITUBE_PHASE, plug->ControlPhase, &(plug->LastPhase), &(plug->ConvertedPhase), plug->SampleRate, pParamFunc); checkParamChange(ITUBE_MIX, plug->ControlMix, &(plug->LastMix), &(plug->ConvertedMix), plug->SampleRate, pParamFunc); fDrive = plug->ConvertedDrive; fDCOffset = plug->ConvertedDcoffset; fPhase = plug->ConvertedPhase; fMix = plug->ConvertedMix; fDCOffsetADJ = ITube(fDCOffset,fDrive); pfAudioInput1 = plug->AudioInputBuffer1; pfAudioInput2 = plug->AudioInputBuffer2; pfAudioOutput1 = plug->AudioOutputBuffer1; pfAudioOutput2 = plug->AudioOutputBuffer2; for (lSampleIndex = 0; lSampleIndex < SampleCount; lSampleIndex++) { fAudio1=*(pfAudioInput1++); *(pfAudioOutput1++) = fPhase <= 0 ? (fAudio1*(1-fMix)) + (ITube(fAudio1 + fDCOffset,fDrive)-fDCOffsetADJ)*fMix : (fAudio1*(1-fMix)) - (ITube(fAudio1 + fDCOffset,fDrive)-fDCOffsetADJ)*fMix ; fAudio2=*(pfAudioInput2++); *(pfAudioOutput2++) = fPhase <= 0 ? (fAudio2*(1-fMix)) + (ITube(fAudio2 + fDCOffset,fDrive)-fDCOffsetADJ)*fMix : (fAudio2*(1-fMix)) - (ITube(fAudio2 + fDCOffset,fDrive)-fDCOffsetADJ)*fMix ; } } void cleanupItube(LADSPA_Handle Instance) { free(Instance); } LADSPA_Descriptor * g_psMonoTubeDescriptor = NULL; LADSPA_Descriptor * g_psStereoTubeDescriptor = NULL; /* _init() is called automatically when the plugin library is first loaded. */ void _init() { char ** pcPortNames; LADSPA_PortDescriptor * piPortDescriptors; LADSPA_PortRangeHint * psPortRangeHints; g_psMonoTubeDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); g_psStereoTubeDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); if (g_psMonoTubeDescriptor) { g_psMonoTubeDescriptor->UniqueID = 3306; g_psMonoTubeDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psMonoTubeDescriptor->Label = strdup("invada_mono_tube_module_0_1"); g_psMonoTubeDescriptor->Name = strdup(":: Invada :: Tube - Mono"); g_psMonoTubeDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psMonoTubeDescriptor->Copyright = strdup("(c) Invada Records"); g_psMonoTubeDescriptor->PortCount = 6; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(6, sizeof(LADSPA_PortDescriptor)); g_psMonoTubeDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[ITUBE_DRIVE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_DCOFFSET] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_PHASE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_MIX] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ITUBE_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(6, sizeof(char *)); g_psMonoTubeDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[ITUBE_DRIVE] = strdup("Drive (dB)"); pcPortNames[ITUBE_DCOFFSET] = strdup("DC Offset"); pcPortNames[ITUBE_PHASE] = strdup("Phase"); pcPortNames[ITUBE_MIX] = strdup("Wet/Dry Mix (%)"); pcPortNames[ITUBE_AUDIO_IN1] = strdup("Input"); pcPortNames[ITUBE_AUDIO_OUT1] = strdup("Output"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(6, sizeof(LADSPA_PortRangeHint))); g_psMonoTubeDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[ITUBE_DRIVE].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0); psPortRangeHints[ITUBE_DRIVE].LowerBound = 0; psPortRangeHints[ITUBE_DRIVE].UpperBound = 18; psPortRangeHints[ITUBE_DCOFFSET].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[ITUBE_DCOFFSET].LowerBound = -1; psPortRangeHints[ITUBE_DCOFFSET].UpperBound = 1; psPortRangeHints[ITUBE_PHASE].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[ITUBE_MIX].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_HIGH ); psPortRangeHints[ITUBE_MIX].LowerBound = 0; psPortRangeHints[ITUBE_MIX].UpperBound = 100; psPortRangeHints[ITUBE_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[ITUBE_AUDIO_OUT1].HintDescriptor = 0; g_psMonoTubeDescriptor->instantiate = instantiateItube; g_psMonoTubeDescriptor->connect_port = connectPortToItube; g_psMonoTubeDescriptor->activate = activateItube; g_psMonoTubeDescriptor->run = runMonoItube; g_psMonoTubeDescriptor->run_adding = NULL; g_psMonoTubeDescriptor->set_run_adding_gain = NULL; g_psMonoTubeDescriptor->deactivate = NULL; g_psMonoTubeDescriptor->cleanup = cleanupItube; } if (g_psStereoTubeDescriptor) { g_psStereoTubeDescriptor->UniqueID = 3307; g_psStereoTubeDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; g_psStereoTubeDescriptor->Label = strdup("invada_stereo_tube_module_0_1"); g_psStereoTubeDescriptor->Name = strdup(":: Invada :: Tube - Stereo"); g_psStereoTubeDescriptor->Maker = strdup("Fraser At Invada Records dot Com"); g_psStereoTubeDescriptor->Copyright = strdup("(c) Invada Records"); g_psStereoTubeDescriptor->PortCount = 8; piPortDescriptors = (LADSPA_PortDescriptor *)calloc(8, sizeof(LADSPA_PortDescriptor)); g_psStereoTubeDescriptor->PortDescriptors = (const LADSPA_PortDescriptor *)piPortDescriptors; piPortDescriptors[ITUBE_DRIVE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_DCOFFSET] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_PHASE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_MIX] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; piPortDescriptors[ITUBE_AUDIO_IN1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ITUBE_AUDIO_OUT1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ITUBE_AUDIO_IN2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; piPortDescriptors[ITUBE_AUDIO_OUT2] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; pcPortNames = (char **)calloc(8, sizeof(char *)); g_psStereoTubeDescriptor->PortNames = (const char **)pcPortNames; pcPortNames[ITUBE_DRIVE] = strdup("Drive (dB)"); pcPortNames[ITUBE_DCOFFSET] = strdup("DC Offset"); pcPortNames[ITUBE_PHASE] = strdup("Phase"); pcPortNames[ITUBE_MIX] = strdup("Wet/Dry Mix (%)"); pcPortNames[ITUBE_AUDIO_IN1] = strdup("Input (Left)"); pcPortNames[ITUBE_AUDIO_OUT1] = strdup("Output (Left)"); pcPortNames[ITUBE_AUDIO_IN2] = strdup("Input (Right)"); pcPortNames[ITUBE_AUDIO_OUT2] = strdup("Output (Right)"); psPortRangeHints = ((LADSPA_PortRangeHint *) calloc(8, sizeof(LADSPA_PortRangeHint))); g_psStereoTubeDescriptor->PortRangeHints = (const LADSPA_PortRangeHint *)psPortRangeHints; psPortRangeHints[ITUBE_DRIVE].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0); psPortRangeHints[ITUBE_DRIVE].LowerBound = 0; psPortRangeHints[ITUBE_DRIVE].UpperBound = 18; psPortRangeHints[ITUBE_DCOFFSET].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0 ); psPortRangeHints[ITUBE_DCOFFSET].LowerBound = -1; psPortRangeHints[ITUBE_DCOFFSET].UpperBound = 1; psPortRangeHints[ITUBE_PHASE].HintDescriptor = (LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0); psPortRangeHints[ITUBE_MIX].HintDescriptor = (LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_HIGH ); psPortRangeHints[ITUBE_MIX].LowerBound = 0; psPortRangeHints[ITUBE_MIX].UpperBound = 100; psPortRangeHints[ITUBE_AUDIO_IN1].HintDescriptor = 0; psPortRangeHints[ITUBE_AUDIO_OUT1].HintDescriptor = 0; psPortRangeHints[ITUBE_AUDIO_IN2].HintDescriptor = 0; psPortRangeHints[ITUBE_AUDIO_OUT2].HintDescriptor = 0; g_psStereoTubeDescriptor->instantiate = instantiateItube; g_psStereoTubeDescriptor->connect_port = connectPortToItube; g_psStereoTubeDescriptor->activate = activateItube; g_psStereoTubeDescriptor->run = runStereoItube; g_psStereoTubeDescriptor->run_adding = NULL; g_psStereoTubeDescriptor->set_run_adding_gain = NULL; g_psStereoTubeDescriptor->deactivate = NULL; g_psStereoTubeDescriptor->cleanup = cleanupItube; } } void deleteDescriptor(LADSPA_Descriptor * psDescriptor) { unsigned long lIndex; if (psDescriptor) { free((char *)psDescriptor->Label); free((char *)psDescriptor->Name); free((char *)psDescriptor->Maker); free((char *)psDescriptor->Copyright); free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) free((char *)(psDescriptor->PortNames[lIndex])); free((char **)psDescriptor->PortNames); free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); free(psDescriptor); } } /* _fini() is called automatically when the library is unloaded. */ void _fini() { deleteDescriptor(g_psMonoTubeDescriptor); deleteDescriptor(g_psStereoTubeDescriptor); } /* Return a descriptor of the requested plugin type. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index) { switch (Index) { case 0: return g_psMonoTubeDescriptor; case 1: return g_psStereoTubeDescriptor; default: return NULL; } } LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr) { LADSPA_Data result; switch(param) { case ITUBE_DRIVE: if(value<0) result= 1; else if (value < 18) result = pow(10,value/20.0); else result= pow(10,0.9); break; case ITUBE_DCOFFSET: if(value<-1) result= -1; else if (value < 0) result = -pow(value,2); else if (value < 1) result = pow(value,2); else result= 1; break; case ITUBE_PHASE: if(value<0.5) result= 0; else result= 1; break; case ITUBE_MIX: if(value<0) result= 0; else if (value < 100) result = value/100; else result= 1; break; default: result=0; break; } return result; } invada-studio-plugins-0.3.1/inv_tube.h000066400000000000000000000015351123632614400177330ustar00rootroot00000000000000/* (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* control conversion function */ LADSPA_Data convertParam(unsigned long param, LADSPA_Data value, unsigned long sr); invada-studio-plugins-0.3.1/libinv_common.c000066400000000000000000000036121123632614400207440ustar00rootroot00000000000000/* Common functions (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "libinv_common.h" /* a function that checks to see if a control has been changed and calls the provided conversion fuction */ void checkParamChange( unsigned long param, LADSPA_Data * control, LADSPA_Data * last, LADSPA_Data * converted, unsigned long sr, LADSPA_Data (*ConvertFunction)(unsigned long, LADSPA_Data, unsigned long) ) { if(*control != *last) { *last=*control; *converted=(*ConvertFunction)(param, *control, sr); } } /* this function is linear between -0.7 & 0.7 (approx -3db) and returns a value bewteen 0.7 and 1 for an input from 0.7 to infinity */ LADSPA_Data InoClip(LADSPA_Data in) { LADSPA_Data out; if ( fabs(in) < 0.7 ) out = in; else out = (in>0) ? ( 0.7 + 0.3 * (1-pow(2.718281828, 3.33333333*(0.7-in)))): ( -0.7 - 0.3 * (1-pow(2.718281828, 3.33333333*(0.7+in)))); return out; } /* distortion function based on sin() */ LADSPA_Data ITube(LADSPA_Data in, LADSPA_Data Drive) { LADSPA_Data out; out = (in>0) ? pow( fabs(sin(in*Drive*PI_ON_2)),ITUBE_MAGIC ) : -pow( fabs(sin(-in*Drive*PI_ON_2)),ITUBE_MAGIC ); return out; } invada-studio-plugins-0.3.1/libinv_common.h000066400000000000000000000024241123632614400207510ustar00rootroot00000000000000/* (c) Fraser Stuart 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* 2.0 * atan(1.0) */ #define PI_ON_2 1.570796327 /* -1.0 / log10(sin(0.2 * atan(1.0))) */ #define ITUBE_MAGIC 1.241206735 /*2^31-2 */ #define TWO31_MINUS2 2147483646 /* param change detect function */ void checkParamChange(unsigned long param, LADSPA_Data * control, LADSPA_Data * last, LADSPA_Data * converted, unsigned long sr, LADSPA_Data (*ConvertFunction)(unsigned long, LADSPA_Data, unsigned long)); /* soft clipping function */ LADSPA_Data InoClip(LADSPA_Data in); /* distortion function */ LADSPA_Data ITube(LADSPA_Data in, LADSPA_Data Drive);