@@ -393,7 +393,8 @@ endif | |||
endif | |||
ifeq ($(EXPERIMENTAL_PLUGINS),true) | |||
NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs freetype2 fftw3f x11) -lclthreads -lclxclient | |||
NATIVE_PLUGINS_FLAGS += $(shell pkg-config --cflags fftw3f xft) | |||
NATIVE_PLUGINS_LIBS += -lzita-convolver $(shell pkg-config --libs fftw3f xft) -lclthreads -lclxclient | |||
endif | |||
# -------------------------------------------------------------- | |||
@@ -20,6 +20,10 @@ | |||
#include "CarlaNative.h" | |||
#include <pthread.h> | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
@@ -81,11 +85,29 @@ typedef struct { | |||
} jack_client_t; | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
* Client functions, defined in the plugin code */ | |||
* Client functions */ | |||
extern jack_client_t* gLastJackClient; | |||
jack_client_t* jack_client_open(const char* clientname, jack_options_t options, jack_status_t* status, ...); | |||
static inline | |||
jack_client_t* jack_client_open(const char* clientname, jack_options_t options, jack_status_t* status, ...) | |||
{ | |||
if (status != NULL) | |||
*status = JackNoError; | |||
int jack_client_close(jack_client_t* client); | |||
return gLastJackClient; | |||
// unused | |||
(void)clientname; | |||
(void)options; | |||
} | |||
static inline | |||
int jack_client_close(jack_client_t* client) | |||
{ | |||
memset(client, 0, sizeof(jack_client_t)); | |||
return 0; | |||
} | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
* Callback functions */ | |||
@@ -151,7 +173,7 @@ int jack_port_unregister(jack_client_t* client, jack_port_t* port) | |||
{ | |||
if (ports[i] == port) | |||
{ | |||
ports[i] = nullptr; | |||
ports[i] = NULL; | |||
return 0; | |||
} | |||
} | |||
@@ -206,6 +228,18 @@ jack_nframes_t jack_get_sample_rate(const jack_client_t* client) | |||
return client->sampleRate; | |||
} | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
* Misc */ | |||
static inline | |||
pthread_t jack_client_thread_id(const jack_client_t* client) | |||
{ | |||
return pthread_self(); | |||
// unused | |||
(void)client; | |||
} | |||
/* ------------------------------------------------------------------------------------------------------------ */ | |||
#ifdef __cplusplus | |||
@@ -146,6 +146,7 @@ endif | |||
ifeq ($(EXPERIMENTAL_PLUGINS),true) | |||
OBJS += \ | |||
$(OBJDIR)/zita-bls1.cpp.o \ | |||
$(OBJDIR)/zita-jaaa.cpp.o | |||
endif | |||
@@ -249,10 +250,15 @@ $(OBJDIR)/zynaddsubfx-ui.cpp.o: zynaddsubfx-ui.cpp $(ZYN_UI_FILES_H) $(ZYN_UI_FI | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
$(OBJDIR)/zita-bls1.cpp.o: zita-bls1.cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -DSHARED=\"/usr/share/zita-bls1\" $(shell pkg-config --cflags xft) -c -o $@ | |||
$(OBJDIR)/zita-jaaa.cpp.o: zita-jaaa.cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -DVERSION=\"0.8.4\" $(shell pkg-config --cflags freetype2 fftw3f x11) -c -o $@ | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -DVERSION=\"0.8.4\" $(shell pkg-config --cflags fftw3f xft) -c -o $@ | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
@@ -15,7 +15,11 @@ | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "CarlaDefines.h" | |||
#include "CarlaNativeJack.h" | |||
// ----------------------------------------------------------------------- | |||
jack_client_t* gLastJackClient = NULL; | |||
// ----------------------------------------------------------------------- | |||
@@ -60,6 +64,7 @@ extern void carla_register_native_plugin_zynaddsubfx_synth(void); | |||
#ifdef WANT_EXPERIMENTAL_PLUGINS | |||
// Experimental plugins | |||
extern void carla_register_native_plugin_zita_bls1(void); | |||
extern void carla_register_native_plugin_zita_jaaa(void); | |||
#endif | |||
@@ -110,6 +115,7 @@ void carla_register_all_plugins(void) | |||
#ifdef WANT_EXPERIMENTAL_PLUGINS | |||
// Experimental plugins | |||
carla_register_native_plugin_zita_bls1(); | |||
carla_register_native_plugin_zita_jaaa(); | |||
#endif | |||
} | |||
@@ -0,0 +1,329 @@ | |||
/* | |||
* Carla Native Plugins | |||
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* 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 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. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "CarlaNative.hpp" | |||
#include "CarlaMutex.hpp" | |||
#include "CarlaJuceUtils.hpp" | |||
#include "juce_audio_basics.h" | |||
#include "zita-bls1/source/png2img.cc" | |||
#include "zita-bls1/source/guiclass.cc" | |||
#include "zita-bls1/source/hp3filt.cc" | |||
#include "zita-bls1/source/jclient.cc" | |||
#include "zita-bls1/source/lfshelf2.cc" | |||
#include "zita-bls1/source/mainwin.cc" | |||
#include "zita-bls1/source/rotary.cc" | |||
#include "zita-bls1/source/shuffler.cc" | |||
#include "zita-bls1/source/styles.cc" | |||
using juce::FloatVectorOperations; | |||
using juce::ScopedPointer; | |||
// ----------------------------------------------------------------------- | |||
// BLS1 Plugin | |||
class BLS1Plugin : public NativePluginClass | |||
{ | |||
public: | |||
#if 0 | |||
enum Parameters { | |||
kParameterInput = 0, | |||
kParameterCount | |||
}; | |||
#endif | |||
BLS1Plugin(const NativeHostDescriptor* const host) | |||
: NativePluginClass(host), | |||
fJackClient(), | |||
fMutex(), | |||
xresman(), | |||
jclient(nullptr), | |||
display(nullptr), | |||
rootwin(nullptr), | |||
mainwin(nullptr), | |||
handler(nullptr), | |||
leakDetector_BLS1Plugin() | |||
{ | |||
CARLA_SAFE_ASSERT(host != nullptr); | |||
carla_zeroStruct(fJackClient); | |||
gLastJackClient = &fJackClient; | |||
fJackClient.clientName = "bls1"; | |||
fJackClient.bufferSize = getBufferSize(); | |||
fJackClient.sampleRate = getSampleRate(); | |||
int argc = 1; | |||
char* argv[] = { (char*)"bls1" }; | |||
xresman.init(&argc, argv, (char*)"bls1", nullptr, 0); | |||
jclient = new Jclient(xresman.rname(), nullptr); | |||
//fParameters[kParameterInput] = 1.0f; | |||
} | |||
#if 0 | |||
// ------------------------------------------------------------------- | |||
// Plugin parameter calls | |||
uint32_t getParameterCount() const override | |||
{ | |||
return kParameterCount; | |||
} | |||
const NativeParameter* getParameterInfo(const uint32_t index) const override | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount, nullptr); | |||
static NativeParameter param; | |||
int hints = NATIVE_PARAMETER_IS_ENABLED|NATIVE_PARAMETER_IS_AUTOMABLE; | |||
// reset | |||
param.name = nullptr; | |||
param.unit = nullptr; | |||
param.ranges.def = 0.0f; | |||
param.ranges.min = 0.0f; | |||
param.ranges.max = 1.0f; | |||
param.ranges.step = 1.0f; | |||
param.ranges.stepSmall = 1.0f; | |||
param.ranges.stepLarge = 1.0f; | |||
param.scalePointCount = 0; | |||
param.scalePoints = nullptr; | |||
switch (index) | |||
{ | |||
case kParameterInput: | |||
hints |= NATIVE_PARAMETER_IS_INTEGER; | |||
param.name = "Input"; | |||
param.ranges.def = 1.0f; | |||
param.ranges.min = 1.0f; | |||
param.ranges.max = 8.0f; | |||
break; | |||
} | |||
param.hints = static_cast<NativeParameterHints>(hints); | |||
return ¶m; | |||
} | |||
float getParameterValue(const uint32_t index) const override | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount, 0.0f); | |||
return fParameters[index]; | |||
} | |||
// ------------------------------------------------------------------- | |||
// Plugin state calls | |||
void setParameterValue(const uint32_t index, const float value) override | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount,); | |||
fParameters[index] = value; | |||
} | |||
#endif | |||
// ------------------------------------------------------------------- | |||
// Plugin process calls | |||
void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) override | |||
{ | |||
if (! fJackClient.active) | |||
{ | |||
const int iframes(static_cast<int>(frames)); | |||
for (int i=0; i<2; ++i) | |||
FloatVectorOperations::clear(outBuffer[i], iframes); | |||
return; | |||
} | |||
for (int i=0; i<2; ++i) | |||
fJackClient.portsAudioIn[i]->buffer = inBuffer[i]; | |||
for (int i=0; i<2; ++i) | |||
fJackClient.portsAudioOut[i]->buffer = outBuffer[i]; | |||
fJackClient.processCallback(frames, fJackClient.processPtr); | |||
} | |||
// ------------------------------------------------------------------- | |||
// Plugin UI calls | |||
void uiShow(const bool show) override | |||
{ | |||
const CarlaMutexLocker cml(fMutex); | |||
if (show) | |||
{ | |||
if (display == nullptr) | |||
{ | |||
display = new X_display(nullptr); | |||
if (display->dpy() == nullptr) | |||
return hostUiUnavailable(); | |||
styles_init(display, &xresman); | |||
rootwin = new X_rootwin(display); | |||
mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient); | |||
rootwin->handle_event(); | |||
handler = new X_handler(display, mainwin, EV_X11); | |||
if (const uintptr_t winId = getUiParentId()) | |||
XSetTransientForHint(display->dpy(), mainwin->win(), static_cast<Window>(winId)); | |||
} | |||
handler->next_event(); | |||
XFlush(display->dpy()); | |||
} | |||
else | |||
{ | |||
handler = nullptr; | |||
mainwin = nullptr; | |||
rootwin = nullptr; | |||
display = nullptr; | |||
} | |||
} | |||
void uiIdle() override | |||
{ | |||
if (display == nullptr) | |||
return; | |||
int ev; | |||
for (; (ev = mainwin->process()) == EV_X11;) | |||
{ | |||
rootwin->handle_event(); | |||
handler->next_event(); | |||
} | |||
#if 0 | |||
// check if parameters were updated | |||
if (mainwin->_input+1 != static_cast<int>(fParameters[kParameterInput])) | |||
{ | |||
fParameters[kParameterInput] = mainwin->_input+1; | |||
uiParameterChanged(kParameterInput, fParameters[kParameterInput]); | |||
} | |||
#endif | |||
if (ev == EV_EXIT) | |||
{ | |||
handler = nullptr; | |||
mainwin = nullptr; | |||
rootwin = nullptr; | |||
display = nullptr; | |||
uiClosed(); | |||
} | |||
} | |||
#if 0 | |||
void uiSetParameterValue(const uint32_t index, const float value) override | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount,); | |||
const CarlaMutexLocker cml(fMutex); | |||
if (itcc == nullptr) | |||
return; | |||
switch (index) | |||
{ | |||
case kParameterInput: | |||
mainwin->set_input(static_cast<int>(value)-1); | |||
break; | |||
} | |||
} | |||
#endif | |||
// ------------------------------------------------------------------- | |||
// Plugin dispatcher calls | |||
void bufferSizeChanged(const uint32_t bufferSize) override | |||
{ | |||
fJackClient.bufferSize = bufferSize; | |||
} | |||
void sampleRateChanged(const double sampleRate) override | |||
{ | |||
fJackClient.sampleRate = sampleRate; | |||
} | |||
// ------------------------------------------------------------------- | |||
private: | |||
// Fake jack client | |||
jack_client_t fJackClient; | |||
// Mutex just in case | |||
CarlaMutex fMutex; | |||
// Zita stuff (core) | |||
X_resman xresman; | |||
ScopedPointer<Jclient> jclient; | |||
ScopedPointer<X_display> display; | |||
ScopedPointer<X_rootwin> rootwin; | |||
ScopedPointer<Mainwin> mainwin; | |||
ScopedPointer<X_handler> handler; | |||
//float fParameters[kParameterCount]; | |||
PluginClassEND(BLS1Plugin) | |||
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(BLS1Plugin) | |||
}; | |||
// ----------------------------------------------------------------------- | |||
static const NativePluginDescriptor bls1Desc = { | |||
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | |||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
|NATIVE_PLUGIN_HAS_UI | |||
|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS | |||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |||
|NATIVE_PLUGIN_USES_PARENT_ID), | |||
/* supports */ static_cast<NativePluginSupports>(0x0), | |||
/* audioIns */ 2, | |||
/* audioOuts */ 2, | |||
/* midiIns */ 0, | |||
/* midiOuts */ 0, | |||
/* paramIns */ 0, //JaaaPlugin::kParameterCount, | |||
/* paramOuts */ 0, | |||
/* name */ "BLS1", | |||
/* label */ "bls1", | |||
/* maker */ "Fons Adriaensen", | |||
/* copyright */ "GPL v2+", | |||
PluginDescriptorFILL(BLS1Plugin) | |||
}; | |||
// ----------------------------------------------------------------------- | |||
CARLA_EXPORT | |||
void carla_register_native_plugin_zita_bls1(); | |||
CARLA_EXPORT | |||
void carla_register_native_plugin_zita_bls1() | |||
{ | |||
carla_register_native_plugin(&bls1Desc); | |||
} | |||
// ----------------------------------------------------------------------- |
@@ -0,0 +1 @@ | |||
Fons Adriaensen <fons@linuxaudio.org> |
@@ -0,0 +1,340 @@ | |||
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. | |||
<one line to give the program's name and a brief idea of what it does.> | |||
Copyright (C) <year> <name of author> | |||
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. | |||
<signature of Ty Coon>, 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. |
@@ -0,0 +1,24 @@ | |||
To install, cd to this directory, make, sudo make install. | |||
To build this program you need the shared libraries | |||
libclthreads-2.4.0 | |||
libclxclient-3.6.1 | |||
libzita-convolver-3.0.0 | |||
and the corresponding header files. They are available at | |||
<http://www.kokkinizita.net/linuxaudio/downloads> | |||
Install clthreads first as clxclient depends on it. | |||
The other dependencies (X11, Xft, png, cairo, fftw3f, jack) | |||
should be provided by any Linux distro. | |||
To install into /usr instead of /usr/local modify the | |||
definition of 'PREFIX' in the Makefile. | |||
Note: the 'make install' step is necessary to make | |||
the application work - it expects to find some files | |||
in $PREFIX/share/zita-bls1. | |||
@@ -0,0 +1,3 @@ | |||
See doc/html/quickguide.html | |||
@@ -0,0 +1,111 @@ | |||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |||
<html><head> | |||
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8"> | |||
<meta http-equiv="Content-Language" content="en"> | |||
<link rel="stylesheet" type="text/css" href="styles.css"> | |||
<title>BLS1 - Quick guide</title> | |||
</head> | |||
<body> | |||
<table border="0" cellpadding="0" cellspacing="10" width="950"> | |||
<tbody> | |||
<tr height="50"> | |||
<td width="150"> | |||
<img src="redzita.png" border=0> | |||
</td> | |||
<td width="850" align="center"> | |||
<h2>BLS1 - Quick guide</h2> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td></td> | |||
<td class="content"> | |||
<p>BLS1 is a digital realisation of the 'Blumlein Shuffler', invented by Alan | |||
Blumlen in the early 1930s and analysed in detail by Michael Gerzon in a | |||
paper presented at the 1993 AES Convention in San Francisco.</p> | |||
<p>The Blumlein Shuffler is used to convert binaural stereo signals into a | |||
form suitable for reproduction using a convential stereo speaker pair. | |||
Binaural signals are provided by e.g. a dummy head, or a pair of closely | |||
spaced omnis with a baffle (e.g. a Jecklin disk) in between them. Such signals | |||
have no significant level differences for off-centre signals at low and low-mid | |||
frequencies, only a phase difference which depends on the frequency, the distance | |||
between the mics and the source direction. The shuffler turns these phase | |||
differences into amplitude differences by applying a specific filter to the | |||
(L-R) signal. This can be done only as long as the phase difference is not | |||
ambiguous, i.e. less than half a cycle, so the shuffler is normally set up | |||
to not affect higher frequencies. For these, sufficient channel separation must | |||
be provided by the input signals themselves, typically by using some sort of | |||
baffle between the mics.</p> | |||
<p> The ideal difference channel filter would be of the form 1 + a/s, i.e. unity | |||
plus an integrator, or the inverse of a first order highpass. But since this has | |||
unbounded gain as frequency goes down it can't be used. An analog implementation | |||
would use an LF shelf filter instead. The problem with this is that limiting the | |||
gain at LF also means that the phase response returns to zero, while it should | |||
ideally stay at 90 degrees. This could be compensated for by using all-pass filters | |||
in both the sum and difference channels, but this complicates the circuit (in | |||
particular if the shuffler parameters are variable) and of course also affects | |||
the overall phase response.</p> | |||
<p>Zita-bls1 uses a FIR filter (1024 taps at 48 kHz) that has the amplitude | |||
response of the shelf filter but the phase response of the ideal filter, and | |||
the sum channel is just a matching delay. The finite length of the FIR means | |||
there will be some roll-off at very low frequencies, in this case -3dB at 40 Hz, | |||
which is probably not a bad thing. It could be avoided by using a longer FIR.</p> | |||
<p>Apart from the basic shuffler algorithm some extras are provided: an input | |||
gain balance control, an 18 dB/oct highpass filter, and a variable frequency | |||
LF shelf filter.</p> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td></td> | |||
<td align="center"> | |||
<img src="zita-bls1.png" border=0> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td></td> | |||
<td class="content"> | |||
<p> The rotary knobs can be used in two ways:</p> | |||
<p> * Click on the knob with the <b>left</b> mouse button, keep it pressed | |||
and move either left..right or up..down.</p> | |||
<p> * Using the <b>mouse wheel</b>. This provides 'sensible' steps, e.g. | |||
1 or 1/2 dB for gains and 1/3 or 1/6 octave for frequencies. Press <b>Shift | |||
</b>for smaller steps.</p> | |||
<p>From Left to right we have: | |||
</p> | |||
<p><b>* Input balance.</b> | |||
Not all mic preamps provide perfect matching of channel gains, and the mics | |||
themselves may have slightly different sensitivities as well Since the | |||
shuffler amplifies the difference between the L and R inputs, even small | |||
gain errors could have a significant impact. This control is provided to | |||
allow exact matching of the two input signal gains.</p> | |||
<p><b>* Highpass filter.</b> | |||
As the shuffler boosts LF signals it's advisable to remove any low | |||
frequency rumble. Ideally this should be done by the mic preamps, but | |||
not all of them all provide such a filter. Filter slope is 18 dB/oct. | |||
When set to 10 Hz it has no significant effect in the audio band.</p> | |||
<p><b>* Shuffler gain.</b> | |||
This the maximum gain the difference channel filter will have as | |||
frequency goes down. Depending on the combined gain and frequency | |||
settings It may not reach this value since there is also a fixed | |||
rolloff (-3 dB at 40 Hz).</p> | |||
<p><b>* Shuffler frequency.</b> | |||
This is the frequency at which the difference channel filter will | |||
have 3dB gain.</p> | |||
<p><b>* LF shelf filter frequency and gain.</b> | |||
The LF shelf filter is provided to correct the tonal balance in | |||
the low frequency range which may be affected by the action of the | |||
shuffler. It is a second order design and has a somewhat steeper | |||
slope than most shelf filters. | |||
</p> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
</body> |
@@ -0,0 +1,24 @@ | |||
body | |||
{ | |||
font-family: sans-serif; | |||
margin: 0; | |||
color: #FFFFFF; | |||
background-color: #383838; | |||
background-image: url(emboss.png); | |||
background-repeat: repeat; | |||
background-attachment: scroll; | |||
background-position: top left; | |||
} | |||
a:link { font-size: 10pt; font-weight: bold; color: #60FF60; } | |||
a:visited { font-size: 10pt; font-weight: bold; color: #8080FF; } | |||
h1 { font-size: 18pt; font-weight:bold; background-color: #0000E0; color: #FFFFFF; padding: 8pt; } | |||
h2 { font-size: 14pt; font-weight:normal; background-color: #0000E0; color: #FFFFFF; padding-left: 8pt; } | |||
h3 { font-size: 12pt; font-weight:normal; background-color: #FF0000; color: #FFFFFF; padding-left: 8pt; } | |||
.content { font-size: 10pt; font-weight: normal; color: #FFFFFF; padding-bottom: 10pt; } | |||
.comment { font-size: 10pt; font-weight: bold; color: #FFFF00; } | |||
.lborder { font-size: 11pt; font-weight: bold; padding: 15pt; } | |||
.theader { font-size: 10pt; font-weight: bold; color: #FFFF00; } | |||
@@ -0,0 +1,64 @@ | |||
# -------------------------------------------------------------------------- | |||
# | |||
# Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
# | |||
# 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. | |||
# | |||
# -------------------------------------------------------------------------- | |||
PREFIX = /usr/local | |||
SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/') | |||
LIBDIR = lib$(SUFFIX) | |||
BINDIR = $(PREFIX)/bin | |||
SHARED = $(PREFIX)/share/zita-bls1 | |||
VERSION = 0.1.0 | |||
DISTDIR = zita-bls1-$(VERSION) | |||
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DSHARED=\"$(SHARED)\" | |||
CXXFLAGS += -O2 -ffast-math -Wall -MMD -MP | |||
CXXFLAGS += -march=native | |||
all: zita-bls1 | |||
ZITA-BLS1_O = zita-bls1.o styles.o jclient.o mainwin.o png2img.o guiclass.o rotary.o \ | |||
hp3filt.o lfshelf2.o shuffler.o | |||
zita-bls1: CPPFLAGS += -I/usr/X11R6/include `freetype-config --cflags` | |||
zita-bls1: LDLIBS += -lzita-convolver -lfftw3f -lclxclient -lclthreads -ljack -lcairo -lpthread -lpng -lXft -lX11 -lrt | |||
zita-bls1: LDFLAGS += -L/usr/X11R6/lib | |||
zita-bls1: $(ZITA-BLS1_O) | |||
g++ $(LDFLAGS) -o $@ $(ZITA-BLS1_O) $(LDLIBS) | |||
$(ZITA-BLS1_O): | |||
-include $(ZITA-BLS1_O:%.o=%.d) | |||
install: all | |||
install -d $(DESTDIR)$(BINDIR) | |||
install -d $(DESTDIR)$(SHARED) | |||
install -m 755 zita-bls1 $(DESTDIR)$(BINDIR) | |||
rm -rf $(DESTDIR)$(SHARED)/* | |||
install -m 644 ../share/* $(DESTDIR)$(SHARED) | |||
uninstall: | |||
rm -f $(DESTDIR)$(BINDIR)/zita-bls1 | |||
rm -rf $(DESTDIR)$(SHARED) | |||
clean: | |||
/bin/rm -f *~ *.o *.a *.d *.so | |||
/bin/rm -f zita-bls1 | |||
@@ -0,0 +1,32 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __GLOBAL_H | |||
#define __GLOBAL_H | |||
#define PROGNAME "zita-bls1" | |||
#define MAXCH 2 | |||
#define EV_X11 16 | |||
#define EV_EXIT 31 | |||
#endif |
@@ -0,0 +1,154 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <math.h> | |||
#include "guiclass.h" | |||
Rlinctl::Rlinctl (X_window *parent, | |||
X_callback *cbobj, | |||
RotaryImg *image, | |||
int xp, | |||
int yp, | |||
int cm, | |||
int dd, | |||
double vmin, | |||
double vmax, | |||
double vini, | |||
int cbind) : | |||
RotaryCtl (parent, cbobj, image, xp, yp, cbind), | |||
_cm (cm), | |||
_dd (dd), | |||
_vmin (vmin), | |||
_vmax (vmax), | |||
_form (0) | |||
{ | |||
_count = -1; | |||
set_value (vini); | |||
} | |||
void Rlinctl::get_string (char *p, int n) | |||
{ | |||
if (_form) snprintf (p, n, _form, _value); | |||
else *p = 0; | |||
} | |||
void Rlinctl::set_value (double v) | |||
{ | |||
set_count ((int) floor (_cm * (v - _vmin) / (_vmax - _vmin) + 0.5)); | |||
render (); | |||
} | |||
int Rlinctl::handle_button (void) | |||
{ | |||
return PRESS; | |||
} | |||
int Rlinctl::handle_motion (int dx, int dy) | |||
{ | |||
return set_count (_rcount + dx - dy); | |||
} | |||
int Rlinctl::handle_mwheel (int dw) | |||
{ | |||
if (! (_keymod & ShiftMask)) dw *= _dd; | |||
return set_count (_count + dw); | |||
} | |||
int Rlinctl::set_count (int u) | |||
{ | |||
if (u < 0) u= 0; | |||
if (u > _cm) u = _cm; | |||
if (u != _count) | |||
{ | |||
_count = u; | |||
_value = _vmin + u * (_vmax - _vmin) / _cm; | |||
_angle = 270.0 * ((double) u / _cm - 0.5); | |||
return DELTA; | |||
} | |||
return 0; | |||
} | |||
Rlogctl::Rlogctl (X_window *parent, | |||
X_callback *cbobj, | |||
RotaryImg *image, | |||
int xp, | |||
int yp, | |||
int cm, | |||
int dd, | |||
double vmin, | |||
double vmax, | |||
double vini, | |||
int cbind) : | |||
RotaryCtl (parent, cbobj, image, xp, yp, cbind), | |||
_cm (cm), | |||
_dd (dd), | |||
_form (0) | |||
{ | |||
_count = -1; | |||
_vmin = log (vmin); | |||
_vmax = log (vmax); | |||
set_value (vini); | |||
} | |||
void Rlogctl::get_string (char *p, int n) | |||
{ | |||
if (_form) snprintf (p, n, _form, _value); | |||
else *p = 0; | |||
} | |||
void Rlogctl::set_value (double v) | |||
{ | |||
set_count ((int) floor (_cm * (log (v) - _vmin) / (_vmax - _vmin) + 0.5)); | |||
render (); | |||
} | |||
int Rlogctl::handle_button (void) | |||
{ | |||
return PRESS; | |||
} | |||
int Rlogctl::handle_motion (int dx, int dy) | |||
{ | |||
return set_count (_rcount + dx - dy); | |||
} | |||
int Rlogctl::handle_mwheel (int dw) | |||
{ | |||
if (! (_keymod & ShiftMask)) dw *= _dd; | |||
return set_count (_count + dw); | |||
} | |||
int Rlogctl::set_count (int u) | |||
{ | |||
if (u < 0) u= 0; | |||
if (u > _cm) u = _cm; | |||
if (u != _count) | |||
{ | |||
_count = u; | |||
_value = exp (_vmin + u * (_vmax - _vmin) / _cm); | |||
_angle = 270.0 * ((double) u / _cm - 0.5); | |||
return DELTA; | |||
} | |||
return 0; | |||
} |
@@ -0,0 +1,97 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __GUICLASS_H | |||
#define __GUICLASS_H | |||
#include "rotary.h" | |||
class Rlinctl : public RotaryCtl | |||
{ | |||
public: | |||
Rlinctl (X_window *parent, | |||
X_callback *cbobj, | |||
RotaryImg *image, | |||
int xp, | |||
int yp, | |||
int cm, | |||
int dd, | |||
double vmin, | |||
double vmax, | |||
double vini, | |||
int cbind = 0); | |||
virtual void set_value (double v); | |||
virtual void get_string (char *p, int n); | |||
private: | |||
virtual int handle_button (void); | |||
virtual int handle_motion (int dx, int dy); | |||
virtual int handle_mwheel (int dw); | |||
int set_count (int u); | |||
int _cm; | |||
int _dd; | |||
double _vmin; | |||
double _vmax; | |||
const char *_form; | |||
}; | |||
class Rlogctl : public RotaryCtl | |||
{ | |||
public: | |||
Rlogctl (X_window *parent, | |||
X_callback *cbobj, | |||
RotaryImg *image, | |||
int xp, | |||
int yp, | |||
int cm, | |||
int dd, | |||
double vmin, | |||
double vmax, | |||
double vini, | |||
int cbind = 0); | |||
virtual void set_value (double v); | |||
virtual void get_string (char *p, int n); | |||
private: | |||
virtual int handle_button (void); | |||
virtual int handle_motion (int dx, int dy); | |||
virtual int handle_mwheel (int dw); | |||
int set_count (int u); | |||
int _cm; | |||
int _dd; | |||
double _vmin; | |||
double _vmax; | |||
const char *_form; | |||
}; | |||
#endif |
@@ -0,0 +1,178 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <string.h> | |||
#include <math.h> | |||
#include "hp3filt.h" | |||
HP3filt::HP3filt (void) : | |||
_touch0 (0), | |||
_touch1 (0), | |||
_state (BYPASS), | |||
_f0 (0), | |||
_f1 (0), | |||
_c1 (0), | |||
_c2 (0), | |||
_c3 (0), | |||
_g (0), | |||
_d (0) | |||
{ | |||
setfsamp (0.0f); | |||
} | |||
HP3filt::~HP3filt (void) | |||
{ | |||
} | |||
void HP3filt::setfsamp (float fsamp) | |||
{ | |||
_fsamp = fsamp; | |||
reset (); | |||
} | |||
void HP3filt::reset (void) | |||
{ | |||
memset (_z1, 0, sizeof (float) * MAXCH); | |||
memset (_z2, 0, sizeof (float) * MAXCH); | |||
memset (_z3, 0, sizeof (float) * MAXCH); | |||
} | |||
void HP3filt::prepare (int nsamp) | |||
{ | |||
float f; | |||
f = _f0; | |||
if (_touch1 != _touch0) | |||
{ | |||
if (_f1 == f) | |||
{ | |||
_touch1 = _touch0; | |||
if (_state == FADING) | |||
{ | |||
_state = (_d > 0) ? STATIC : BYPASS; | |||
} | |||
} | |||
else if (_f1 == 0) | |||
{ | |||
_f1 = f; | |||
_a = 0.0f; | |||
_d = 1.0f / nsamp; | |||
calcpar1 (0, _f1); | |||
reset (); | |||
_state = FADING; | |||
} | |||
else if (f == 0) | |||
{ | |||
_f1 = f; | |||
_a = 1.0f; | |||
_d = -1.0f / nsamp; | |||
_state = FADING; | |||
} | |||
else | |||
{ | |||
if (f > 1.25f * _f1) _f1 *= 1.25f; | |||
if (f < 0.80f * _f1) _f1 *= 0.80f; | |||
else _f1 = f; | |||
calcpar1 (0, _f1); | |||
} | |||
} | |||
} | |||
float HP3filt::response (float /*f*/) | |||
{ | |||
// Compute gain at frequency f from _c1 _c2, _c3, _g. | |||
// This is left as an exercise for the reader. | |||
return 0; | |||
} | |||
void HP3filt::calcpar1 (int /*nsamp*/, float f) | |||
{ | |||
float a, b, t; | |||
_g = 1; | |||
a = (float)(M_PI) * f / _fsamp; | |||
b = a * a; | |||
t = 1 + a + b; | |||
_g /= t; | |||
_c1 = 2 * a + 4 * b; | |||
_c2 = 4 * b / _c1; | |||
_c1 /= t; | |||
t = 1 + a; | |||
_g /= t; | |||
_c3 = 2 * a / t; | |||
} | |||
void HP3filt::process1 (int nsamp, int nchan, float *data[]) | |||
{ | |||
int i, j; | |||
float a, d, x, y, z1, z2, z3; | |||
float *p; | |||
a = _a; | |||
d = _d; | |||
for (i = 0; i < nchan; i++) | |||
{ | |||
p = data [i]; | |||
z1 = _z1 [i]; | |||
z2 = _z2 [i]; | |||
z3 = _z3 [i]; | |||
if (_state == FADING) | |||
{ | |||
a = _a; | |||
for (j = 0; j < nsamp; j++) | |||
{ | |||
x = *p; | |||
y = x - z1 - z2 + 1e-20f; | |||
z2 += _c2 * z1; | |||
z1 += _c1 * y; | |||
y -= z3 - 1e-20f; | |||
z3 += _c3 * y; | |||
a += d; | |||
*p++ = a * (_g * y) + (1 - a) * x; | |||
} | |||
} | |||
else | |||
{ | |||
for (j = 0; j < nsamp; j++) | |||
{ | |||
x = *p; | |||
y = x - z1 - z2 + 1e-20f; | |||
z2 += _c2 * z1; | |||
z1 += _c1 * y; | |||
y -= z3 - 1e-20f; | |||
z3 += _c3 * y; | |||
*p++ = _g * y; | |||
} | |||
} | |||
_z1 [i] = z1; | |||
_z2 [i] = z2; | |||
_z3 [i] = z3; | |||
} | |||
if (_state == FADING) _a = a; | |||
} |
@@ -0,0 +1,71 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __HP3FILT_H | |||
#define __HP3FILT_H | |||
#include <stdint.h> | |||
#include "global.h" | |||
class HP3filt | |||
{ | |||
public: | |||
HP3filt (void); | |||
~HP3filt (void); | |||
void setfsamp (float fsamp); | |||
void setparam (float f) | |||
{ | |||
_f0 = f; | |||
_touch0++; | |||
} | |||
void reset (void); | |||
void prepare (int nsamp); | |||
void process (int nsamp, int nchan, float *data[]) | |||
{ | |||
if (_state != BYPASS) process1 (nsamp, nchan, data); | |||
} | |||
float response (float f); | |||
private: | |||
enum { BYPASS, STATIC, FADING }; | |||
void calcpar1 (int nsamp, float f); | |||
void process1 (int nsamp, int nchan, float *data[]); | |||
volatile int16_t _touch0; | |||
volatile int16_t _touch1; | |||
int _state; | |||
float _fsamp; | |||
float _f0, _f1; | |||
float _c1, _c2, _c3; | |||
float _g, _a, _d; | |||
float _z1 [2]; | |||
float _z2 [2]; | |||
float _z3 [2]; | |||
}; | |||
#endif |
@@ -0,0 +1,194 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <string.h> | |||
#include "jclient.h" | |||
Jclient::Jclient (const char *jname, const char *jserv) : | |||
A_thread ("Jclient"), | |||
_jack_client (0), | |||
_active (false), | |||
_jname (0), | |||
_inpbal0 (0), | |||
_inpbal1 (0), | |||
_ga (1.0f), | |||
_gb (1.0f), | |||
_da (0.0f), | |||
_db (0.0f) | |||
{ | |||
init_jack (jname, jserv); | |||
} | |||
Jclient::~Jclient (void) | |||
{ | |||
if (_jack_client) close_jack (); | |||
} | |||
void Jclient::init_jack (const char *jname, const char *jserv) | |||
{ | |||
jack_status_t stat; | |||
struct sched_param spar; | |||
int options, abspri, policy, k; | |||
options = JackNoStartServer; | |||
if (jserv) options |= JackServerName; | |||
if ((_jack_client = jack_client_open (jname, (jack_options_t) options, &stat, jserv)) == 0) | |||
{ | |||
fprintf (stderr, "Can't connect to JACK\n"); | |||
exit (1); | |||
} | |||
jack_set_process_callback (_jack_client, jack_static_process, (void *) this); | |||
jack_on_shutdown (_jack_client, jack_static_shutdown, (void *) this); | |||
if (jack_activate (_jack_client)) | |||
{ | |||
fprintf (stderr, "Can't activate JACK.\n"); | |||
exit (1); | |||
} | |||
_jname = jack_get_client_name (_jack_client); | |||
_fsamp = jack_get_sample_rate (_jack_client); | |||
_psize = jack_get_buffer_size (_jack_client); | |||
if (_psize > 4096) | |||
{ | |||
fprintf (stderr, "Period size can't be more than 4096.\n"); | |||
exit (1); | |||
} | |||
if (_psize & (_psize - 1)) | |||
{ | |||
fprintf (stderr, "Period size must be a power of 2.\n"); | |||
exit (1); | |||
} | |||
pthread_getschedparam (jack_client_thread_id (_jack_client), &policy, &spar); | |||
abspri = spar.sched_priority; | |||
_inpports [0] = jack_port_register (_jack_client, "inp.L", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); | |||
_inpports [1] = jack_port_register (_jack_client, "inp.R", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); | |||
_outports [0] = jack_port_register (_jack_client, "out.L", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | |||
_outports [1] = jack_port_register (_jack_client, "out.R", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | |||
_hpfilt.setfsamp (_fsamp); | |||
_lshelf.setfsamp (_fsamp); | |||
_lshelf.bypass (false); | |||
_shuffl.init (_fsamp, _psize, abspri, policy); | |||
for (k = _fsamp, _fragm = 1024; k > 56000; k >>= 1, _fragm <<= 1); | |||
_nsamp = 0; | |||
_active = true; | |||
} | |||
void Jclient::close_jack () | |||
{ | |||
jack_deactivate (_jack_client); | |||
jack_client_close (_jack_client); | |||
} | |||
void Jclient::jack_static_shutdown (void *arg) | |||
{ | |||
((Jclient *) arg)->jack_shutdown (); | |||
} | |||
int Jclient::jack_static_process (jack_nframes_t nframes, void *arg) | |||
{ | |||
return ((Jclient *) arg)->jack_process (nframes); | |||
} | |||
void Jclient::jack_shutdown (void) | |||
{ | |||
send_event (EV_EXIT, 1); | |||
} | |||
int Jclient::jack_process (int frames) | |||
{ | |||
int i, k, n; | |||
float a, b, t; | |||
float *inp [2]; | |||
float *tmp [2]; | |||
float *out [2]; | |||
if (!_active) return 0; | |||
inp [0] = (float *) jack_port_get_buffer (_inpports [0], frames); | |||
inp [1] = (float *) jack_port_get_buffer (_inpports [1], frames); | |||
out [0] = tmp [0] = (float *) jack_port_get_buffer (_outports [0], frames); | |||
out [1] = tmp [1] = (float *) jack_port_get_buffer (_outports [1], frames); | |||
a = _ga; | |||
b = _gb; | |||
n = frames; | |||
while (n) | |||
{ | |||
if (!_nsamp) | |||
{ | |||
if (fabsf (_inpbal0 -_inpbal1) > 0.01f) | |||
{ | |||
_inpbal1 = _inpbal0; | |||
t = powf (10.0f, 0.05f * _inpbal0); | |||
_db = (t - b) / _fragm; | |||
t = 1.0f / t; | |||
_da = (t - a) / _fragm; | |||
} | |||
else | |||
{ | |||
_da = 0.0f; | |||
_db = 0.0f; | |||
} | |||
_hpfilt.prepare (_fragm); | |||
_lshelf.prepare (_fragm); | |||
_nsamp = _fragm; | |||
} | |||
k = (n < _nsamp) ? n: _nsamp; | |||
for (i = 0; i < k; i++) | |||
{ | |||
a += _da; | |||
b += _db; | |||
tmp [0][i] = a * inp [0][i]; | |||
tmp [1][i] = b * inp [1][i]; | |||
} | |||
_hpfilt.process (k, 2, tmp); | |||
_lshelf.process (k, 2, tmp); | |||
inp [0] += k; | |||
inp [1] += k; | |||
tmp [0] += k; | |||
tmp [1] += k; | |||
_nsamp -= k; | |||
n -= k; | |||
} | |||
_ga = a; | |||
_gb = b; | |||
_shuffl.process (frames, out, out); | |||
return 0; | |||
} | |||
@@ -0,0 +1,97 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __JCLIENT_H | |||
#define __JCLIENT_H | |||
#include <inttypes.h> | |||
#include <stdlib.h> | |||
#include <math.h> | |||
#include <clthreads.h> | |||
#include "CarlaNativeJack.h" | |||
#include "hp3filt.h" | |||
#include "shuffler.h" | |||
#include "lfshelf2.h" | |||
#include "global.h" | |||
class Jclient : public A_thread | |||
{ | |||
public: | |||
Jclient (const char *jname, const char *jserv); | |||
~Jclient (void); | |||
const char *jname (void) const { return _jname; } | |||
void set_inpbal (float diff) | |||
{ | |||
_inpbal0 = diff; | |||
} | |||
void set_hpfilt (float freq) | |||
{ | |||
_hpfilt.setparam (freq); | |||
} | |||
void set_loshelf (float gain, float freq) | |||
{ | |||
_lshelf.setparam (powf (10.0f, 0.05f * gain), freq, 0.4f); | |||
} | |||
Shuffler *shuffler (void) | |||
{ | |||
return (Shuffler *) &_shuffl; | |||
} | |||
private: | |||
void init_jack (const char *jname, const char *jserv); | |||
void close_jack (void); | |||
void jack_shutdown (void); | |||
int jack_process (int nframes); | |||
virtual void thr_main (void) {} | |||
jack_client_t *_jack_client; | |||
jack_port_t *_inpports [2]; | |||
jack_port_t *_outports [2]; | |||
bool _active; | |||
const char *_jname; | |||
unsigned int _fsamp; | |||
int _psize; | |||
int _fragm; | |||
int _nsamp; | |||
float _inpbal0; | |||
float _inpbal1; | |||
float _ga, _gb; | |||
float _da, _db; | |||
HP3filt _hpfilt; | |||
LFshelf2 _lshelf; | |||
Shuffler _shuffl; | |||
static void jack_static_shutdown (void *arg); | |||
static int jack_static_process (jack_nframes_t nframes, void *arg); | |||
}; | |||
#endif |
@@ -0,0 +1,248 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <math.h> | |||
#include <string.h> | |||
#include "lfshelf2.h" | |||
LFshelf2::LFshelf2 (void) : | |||
_touch0 (0), | |||
_touch1 (0), | |||
_bypass (true), | |||
_state (BYPASS), | |||
_g0 (1), | |||
_g1 (1), | |||
_f0 (1e2f), | |||
_f1 (1e2f), | |||
_s0 (0), | |||
_s1 (0) | |||
{ | |||
setfsamp (0.0f); | |||
} | |||
LFshelf2::~LFshelf2 (void) | |||
{ | |||
} | |||
void LFshelf2::setfsamp (float fsamp) | |||
{ | |||
_fsamp = fsamp; | |||
reset (); | |||
} | |||
void LFshelf2::reset (void) | |||
{ | |||
memset (_z1, 0, sizeof (float) * MAXCH); | |||
memset (_z2, 0, sizeof (float) * MAXCH); | |||
} | |||
void LFshelf2::prepare (int nsamp) | |||
{ | |||
bool upd = false; | |||
float g, f, s; | |||
if (_touch1 != _touch0) | |||
{ | |||
g = _bypass ? 1 : _g0; | |||
f = _f0; | |||
s = _s0; | |||
if (g != _g1) | |||
{ | |||
upd = true; | |||
if (g > 2 * _g1) _g1 *= 2; | |||
else if (_g1 > 2 * g) _g1 /= 2; | |||
else _g1 = g; | |||
} | |||
if (f != _f1) | |||
{ | |||
upd = true; | |||
if (f > 2 * _f1) _f1 *= 2; | |||
else if (_f1 > 2 * f) _f1 /= 2; | |||
else _f1 = f; | |||
} | |||
if (s != _s1) | |||
{ | |||
upd = true; | |||
if (s > _s1 + 0.3f) _s1 += 0.3f; | |||
else if (s < _s1 - 0.3f) _s1 -= 0.3f; | |||
else _s1 = s; | |||
} | |||
if (upd) | |||
{ | |||
if ((_state == BYPASS) && (_g1 == 1)) | |||
{ | |||
calcpar1 (0, _g1, _f1, _s1); | |||
} | |||
else | |||
{ | |||
_state = SMOOTH; | |||
calcpar1 (nsamp, _g1, _f1, _s1); | |||
} | |||
} | |||
else | |||
{ | |||
_touch1 = _touch0; | |||
if (fabs (_g1 - 1) < 0.001f) | |||
{ | |||
_state = BYPASS; | |||
reset (); | |||
} | |||
else | |||
{ | |||
_state = STATIC; | |||
} | |||
} | |||
} | |||
} | |||
float LFshelf2::response (float /*f*/) | |||
{ | |||
// Compute gain at frequency f from _a0, _a1, _a2, _b1, _b2. | |||
// This is left as an exercise for the reader. | |||
return 0; | |||
} | |||
void LFshelf2::calcpar1 (int nsamp, float g, float f, float s) | |||
{ | |||
bool inv; | |||
float a0, a1, a2, b1, b2; | |||
float r, w1, w2, c1, c2, c3, c4, d1, d2; | |||
inv = (g < 1.0f); | |||
if (inv) g = 1.0f / g; | |||
w1 = 2 * M_PI * f / _fsamp; | |||
w2 = w1 * sqrtf (g); | |||
s *= (g - 1) / g; | |||
d1 = 1.8f - 0.55f * s / (1 + 2 * w1); | |||
d2 = 1.8f - 1.50f * s / (1 + 2 * w2); | |||
if (inv) | |||
{ | |||
c1 = w1 * w1; | |||
c2 = d1 * w1; | |||
c3 = w2 * w2; | |||
c4 = d2 * w2; | |||
} | |||
else | |||
{ | |||
c1 = w2 * w2; | |||
c2 = d2 * w2; | |||
c3 = w1 * w1; | |||
c4 = d1 * w1; | |||
} | |||
r = c3 + 2 * c4 + 4; | |||
b1 = 4 * (c4 - c3) / r; | |||
b2 = 4 * c3 / r; | |||
a0 = (c1 + 2 * c2 + 4) / r - 1; | |||
a1 = 4 * (c2 - c1) / r - b1; | |||
a2 = 4 * c1 / r - b2; | |||
if (nsamp) | |||
{ | |||
_da0 = (a0 - _a0) / nsamp + 1e-30f; | |||
_da1 = (a1 - _a1) / nsamp + 1e-30f; | |||
_da2 = (a2 - _a2) / nsamp + 1e-30f; | |||
_db1 = (b1 - _b1) / nsamp + 1e-30f; | |||
_db2 = (b2 - _b2) / nsamp + 1e-30f; | |||
} | |||
else | |||
{ | |||
_a0 = a0; | |||
_a1 = a1; | |||
_a2 = a2; | |||
_b1 = b1; | |||
_b2 = b2; | |||
} | |||
} | |||
void LFshelf2::process1 (int nsamp, int nchan, float *data[]) | |||
{ | |||
int i, j; | |||
float a0, a1, a2, b1, b2; | |||
float x, y, z1, z2; | |||
float *p; | |||
a0 = _a0; | |||
a1 = _a1; | |||
a2 = _a2; | |||
b1 = _b1; | |||
b2 = _b2; | |||
if (_state == SMOOTH) | |||
{ | |||
for (i = 0; i < nchan; i++) | |||
{ | |||
p = data [i]; | |||
z1 = _z1 [i]; | |||
z2 = _z2 [i]; | |||
a0 = _a0; | |||
a1 = _a1; | |||
a2 = _a2; | |||
b1 = _b1; | |||
b2 = _b2; | |||
for (j = 0; j < nsamp; j++) | |||
{ | |||
a0 += _da0; | |||
a1 += _da1; | |||
a2 += _da2; | |||
b1 += _db1; | |||
b2 += _db2; | |||
x = *p; | |||
y = x - b1 * z1 - b2 * z2 + 1e-10f; | |||
*p++ = x + a0 * y + a1 * z1 + a2 * z2; | |||
z2 += z1; | |||
z1 += y; | |||
} | |||
_z1 [i] = z1; | |||
_z2 [i] = z2; | |||
} | |||
_a0 = a0; | |||
_a1 = a1; | |||
_a2 = a2; | |||
_b1 = b1; | |||
_b2 = b2; | |||
} | |||
else | |||
{ | |||
for (i = 0; i < nchan; i++) | |||
{ | |||
p = data [i]; | |||
z1 = _z1 [i]; | |||
z2 = _z2 [i]; | |||
for (j = 0; j < nsamp; j++) | |||
{ | |||
x = *p; | |||
y = x - b1 * z1 - b2 * z2 + 1e-10f; | |||
*p++ = x + a0 * y + a1 * z1 + a2 * z2; | |||
z2 += z1; | |||
z1 += y; | |||
} | |||
_z1 [i] = z1; | |||
_z2 [i] = z2; | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,88 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __LFSHELF2_H | |||
#define __LFSHELF2_H | |||
#include <stdint.h> | |||
#include "global.h" | |||
class LFshelf2 | |||
{ | |||
public: | |||
LFshelf2 (void); | |||
~LFshelf2 (void); | |||
void setfsamp (float fsamp); | |||
void setparam (float g, float f, float s) | |||
{ | |||
_f0 = f; | |||
_g0 = g; | |||
_s0 = s; | |||
_touch0++; | |||
} | |||
void reset (void); | |||
void bypass (bool s) | |||
{ | |||
if (s != _bypass) | |||
{ | |||
_bypass = s; | |||
_touch0++; | |||
} | |||
} | |||
void prepare (int nsamp); | |||
void process (int nsamp, int nchan, float *data[]) | |||
{ | |||
if (_state != BYPASS) process1 (nsamp, nchan, data); | |||
} | |||
float response (float f); | |||
private: | |||
enum { BYPASS, STATIC, SMOOTH }; | |||
void calcpar1 (int nsamp, float g, float f, float s); | |||
void process1 (int nsamp, int nchan, float *data[]); | |||
volatile int16_t _touch0; | |||
volatile int16_t _touch1; | |||
bool _bypass; | |||
int _state; | |||
float _fsamp; | |||
float _g0, _g1; | |||
float _f0, _f1; | |||
float _s0, _s1; | |||
float _a0, _a1, _a2; | |||
float _b1, _b2; | |||
float _da0, _da1, _da2; | |||
float _db1, _db2; | |||
float _z1 [2]; | |||
float _z2 [2]; | |||
}; | |||
#endif |
@@ -0,0 +1,254 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <stdlib.h> | |||
#include <stdio.h> | |||
#include <math.h> | |||
#include "styles.h" | |||
#include "global.h" | |||
#include "mainwin.h" | |||
Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient) : | |||
A_thread ("Main"), | |||
X_window (parent, xp, yp, XSIZE, YSIZE, XftColors_bls1 [C_MAIN_BG]->pixel), | |||
_stop (false), | |||
_xres (xres), | |||
_jclient (jclient), | |||
_touch (false) | |||
{ | |||
X_hints H; | |||
char s [1024]; | |||
int i; | |||
_atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True); | |||
XSetWMProtocols (dpy (), win (), &_atom, 1); | |||
_atom = XInternAtom (dpy (), "WM_PROTOCOLS", True); | |||
sprintf (s, "%s", jclient->jname ()); | |||
x_set_title (s); | |||
H.position (xp, yp); | |||
H.minsize (XSIZE, YSIZE); | |||
H.maxsize (XSIZE, YSIZE); | |||
H.rname (xres->rname ()); | |||
H.rclas (xres->rclas ()); | |||
x_apply (&H); | |||
RotaryCtl::init (disp ()); | |||
_rotary [INPBAL] = new Rlinctl (this, this, &inpbal_img, 20, 0, 120, 4, -3.0f, 3.0f, 0.0f, INPBAL); | |||
_rotary [HPFILT] = new Rlogctl (this, this, &hpfilt_img, 20, 0, 120, 4, 10.0f, 320.0f, 40.0f, HPFILT); | |||
_rotary [SHGAIN] = new Rlinctl (this, this, &shgain_img, 190, 0, 120, 5, 0.0f, 24.0f, 15.0f, SHGAIN); | |||
_rotary [SHFREQ] = new Rlogctl (this, this, &shfreq_img, 190, 0, 192, 8, 125.0f, 2e3f, 5e2f, SHFREQ); | |||
_rotary [LFFREQ] = new Rlogctl (this, this, &lffreq_img, 410, 0, 192, 8, 20.0f, 320.0f, 80.0f, LFFREQ); | |||
_rotary [LFGAIN] = new Rlinctl (this, this, &lfgain_img, 410, 0, 180, 5, -9.0f, 9.0f, 0.0f, LFGAIN); | |||
for (i = 0; i < NROTARY; i++) _rotary [i]->x_map (); | |||
_jclient->set_inpbal (_rotary [INPBAL]->value ()); | |||
_jclient->set_hpfilt (_rotary [HPFILT]->value ()); | |||
_jclient->set_loshelf (_rotary [LFGAIN]->value (),_rotary [LFFREQ]->value ()); | |||
_jclient->shuffler ()->prepare (_rotary [SHGAIN]->value (), _rotary [SHFREQ]->value ()); | |||
_numtext = new X_textip (this, 0, &tstyle1, 0, 0, 45, 15, 15); | |||
_numtext->set_align (0); | |||
_parmind = -1; | |||
_timeout = 0; | |||
x_add_events (ExposureMask); | |||
x_map (); | |||
set_time (0); | |||
inc_time (250000); | |||
} | |||
Mainwin::~Mainwin (void) | |||
{ | |||
RotaryCtl::fini (); | |||
} | |||
int Mainwin::process (void) | |||
{ | |||
int e; | |||
if (_stop) handle_stop (); | |||
e = get_event_timed (); | |||
switch (e) | |||
{ | |||
case EV_TIME: | |||
handle_time (); | |||
break; | |||
} | |||
return e; | |||
} | |||
void Mainwin::handle_event (XEvent *E) | |||
{ | |||
switch (E->type) | |||
{ | |||
case Expose: | |||
expose ((XExposeEvent *) E); | |||
break; | |||
case ClientMessage: | |||
clmesg ((XClientMessageEvent *) E); | |||
break; | |||
} | |||
} | |||
void Mainwin::expose (XExposeEvent *E) | |||
{ | |||
if (E->count) return; | |||
redraw (); | |||
} | |||
void Mainwin::clmesg (XClientMessageEvent *E) | |||
{ | |||
if (E->message_type == _atom) _stop = true; | |||
} | |||
void Mainwin::handle_time (void) | |||
{ | |||
if (_timeout) | |||
{ | |||
if (--_timeout == 0) numdisp (-1); | |||
} | |||
inc_time (100000); | |||
XFlush (dpy ()); | |||
if (_touch && _jclient->shuffler ()->ready ()) | |||
{ | |||
_jclient->shuffler ()->prepare (_rotary [SHGAIN]->value (), _rotary [SHFREQ]->value ()); | |||
_touch = 0; | |||
} | |||
} | |||
void Mainwin::handle_stop (void) | |||
{ | |||
put_event (EV_EXIT, 1); | |||
} | |||
void Mainwin::handle_callb (int type, X_window *W, XEvent * /*E*/) | |||
{ | |||
RotaryCtl *R; | |||
int k; | |||
switch (type) | |||
{ | |||
case RotaryCtl::PRESS: | |||
R = (RotaryCtl *) W; | |||
k = R->cbind (); | |||
switch (k) | |||
{ | |||
default: | |||
numdisp (-1); | |||
} | |||
break; | |||
case RotaryCtl::DELTA: | |||
R = (RotaryCtl *) W; | |||
k = R->cbind (); | |||
switch (k) | |||
{ | |||
case INPBAL: | |||
_jclient->set_inpbal (_rotary [INPBAL]->value ()); | |||
break; | |||
case HPFILT: | |||
_jclient->set_hpfilt (_rotary [HPFILT]->value ()); | |||
break; | |||
case SHGAIN: | |||
case SHFREQ: | |||
_touch++; | |||
break; | |||
case LFFREQ: | |||
case LFGAIN: | |||
_jclient->set_loshelf (_rotary [LFGAIN]->value (), _rotary [LFFREQ]->value ()); | |||
break; | |||
} | |||
break; | |||
} | |||
} | |||
void Mainwin::redraw (void) | |||
{ | |||
XPutImage (dpy (), win (), dgc (), inputsect, 0, 0, 20, 0, 130, 75); | |||
XPutImage (dpy (), win (), dgc (), shuffsect, 0, 0, 190, 0, 170, 75); | |||
XPutImage (dpy (), win (), dgc (), lfshfsect, 0, 0, 410, 0, 105, 75); | |||
XPutImage (dpy (), win (), dgc (), redzita_img, 0, 0, XSIZE - 35, 0, 35, 75); | |||
} | |||
void Mainwin::numdisp (int k) | |||
{ | |||
int y = 0; | |||
_timeout = 10; | |||
if (k >= 0) fmtfreq (k); | |||
if (k == _parmind) return; | |||
if (k < 0) | |||
{ | |||
_numtext->x_unmap (); | |||
_parmind = -1; | |||
} | |||
else | |||
{ | |||
switch (k) | |||
{ | |||
default: | |||
; | |||
} | |||
_numtext->x_move (1, y + 3); | |||
_numtext->x_map (); | |||
_parmind = k; | |||
} | |||
} | |||
void Mainwin::fmtfreq (int k) | |||
{ | |||
double v; | |||
char t [16]; | |||
const char *f; | |||
v = _rotary [k]->value (); | |||
if (v <= 3e1) f = "%1.1lf"; | |||
else if (v <= 1e3) f = "%1.0lf"; | |||
else if (v <= 3e3) | |||
{ | |||
f = "%1.2lfk"; | |||
v *= 1e-3; | |||
} | |||
else | |||
{ | |||
f = "%1.1lfk"; | |||
v *= 1e-3; | |||
} | |||
sprintf (t, f, v); | |||
_numtext->set_text (t); | |||
} | |||
@@ -0,0 +1,74 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __MAINWIN_H | |||
#define __MAINWIN_H | |||
#include <clxclient.h> | |||
#include "guiclass.h" | |||
#include "jclient.h" | |||
#include "global.h" | |||
class Mainwin : public A_thread, public X_window, public X_callback | |||
{ | |||
public: | |||
enum { XSIZE = 640, YSIZE = 75 }; | |||
Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient); | |||
~Mainwin (void); | |||
Mainwin (const Mainwin&); | |||
Mainwin& operator=(const Mainwin&); | |||
void stop (void) { _stop = true; } | |||
int process (void); | |||
private: | |||
enum { INPBAL, HPFILT, SHGAIN, SHFREQ, LFFREQ, LFGAIN, NROTARY }; | |||
virtual void thr_main (void) {} | |||
void handle_time (void); | |||
void handle_stop (void); | |||
void handle_event (XEvent *); | |||
void handle_callb (int type, X_window *W, XEvent *E); | |||
void expose (XExposeEvent *E); | |||
void clmesg (XClientMessageEvent *E); | |||
void redraw (void); | |||
void numdisp (int ind); | |||
void fmtfreq (int ind); | |||
Atom _atom; | |||
bool _stop; | |||
X_resman *_xres; | |||
Jclient *_jclient; | |||
RotaryCtl *_rotary [NROTARY]; | |||
X_textip *_numtext; | |||
int _parmind; | |||
int _timeout; | |||
int _touch; | |||
}; | |||
#endif |
@@ -0,0 +1,131 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2007-2010 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <png.h> | |||
#include <clxclient.h> | |||
XImage *png2img (const char *file, X_display *disp, XftColor *bgnd) | |||
{ | |||
FILE *F; | |||
png_byte hdr [8]; | |||
png_structp png_ptr; | |||
png_infop png_info; | |||
const unsigned char **data, *p; | |||
int dx, dy, x, y, dp; | |||
float vr, vg, vb, va, br, bg, bb; | |||
unsigned long mr, mg, mb, pix; | |||
XImage *image; | |||
F = fopen (file, "r"); | |||
if (!F) | |||
{ | |||
fprintf (stderr, "Can't open '%s'\n", file); | |||
return 0; | |||
} | |||
fread (hdr, 1, 8, F); | |||
if (png_sig_cmp (hdr, 0, 8)) | |||
{ | |||
fprintf (stderr, "'%s' is not a PNG file\n", file); | |||
return 0; | |||
} | |||
fseek (F, 0, SEEK_SET); | |||
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); | |||
if (! png_ptr) | |||
{ | |||
fclose (F); | |||
return 0; | |||
} | |||
png_info = png_create_info_struct (png_ptr); | |||
if (! png_info) | |||
{ | |||
png_destroy_read_struct (&png_ptr, 0, 0); | |||
fclose (F); | |||
return 0; | |||
} | |||
if (setjmp (png_jmpbuf (png_ptr))) | |||
{ | |||
png_destroy_read_struct (&png_ptr, &png_info, 0); | |||
fclose (F); | |||
fprintf (stderr, "png:longjmp()\n"); | |||
return 0; | |||
} | |||
png_init_io (png_ptr, F); | |||
png_read_png (png_ptr, png_info, | |||
PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, | |||
0); | |||
// This requires libpng14 or later. If you still have an | |||
// older version, use the three commented lines instead. | |||
dx = png_get_image_width (png_ptr, png_info); | |||
dy = png_get_image_height (png_ptr, png_info); | |||
dp = (png_get_color_type (png_ptr, png_info) & PNG_COLOR_MASK_ALPHA) ? 4 : 3; | |||
// dx = png_info->width; | |||
// dy = png_info->height; | |||
// dp = (png_info->color_type & PNG_COLOR_MASK_ALPHA) ? 4 : 3; | |||
data = (const unsigned char **)(png_get_rows (png_ptr, png_info)); | |||
image = XCreateImage (disp->dpy (), | |||
disp->dvi (), | |||
DefaultDepth (disp->dpy (), disp->dsn ()), | |||
ZPixmap, 0, 0, dx, dy, 32, 0); | |||
image->data = new char [image->height * image->bytes_per_line]; | |||
mr = image->red_mask; | |||
mg = image->green_mask; | |||
mb = image->blue_mask; | |||
vr = mr / 255.0f; | |||
vg = mg / 255.0f; | |||
vb = mb / 255.0f; | |||
if (bgnd) | |||
{ | |||
br = bgnd->color.red >> 8; | |||
bg = bgnd->color.green >> 8; | |||
bb = bgnd->color.blue >> 8; | |||
} | |||
else br = bg = bb = 0; | |||
for (y = 0; y < dy; y++) | |||
{ | |||
p = data [y]; | |||
for (x = 0; x < dx; x++) | |||
{ | |||
va = (dp == 4) ? (p [3] / 255.0f) : 1; | |||
pix = ((unsigned long)((p [0] * va + (1 - va) * br) * vr) & mr) | |||
| ((unsigned long)((p [1] * va + (1 - va) * bg) * vg) & mg) | |||
| ((unsigned long)((p [2] * va + (1 - va) * bb) * vb) & mb); | |||
XPutPixel (image, x, y, pix); | |||
p += dp; | |||
} | |||
} | |||
png_destroy_read_struct (&png_ptr, &png_info, 0); | |||
fclose (F); | |||
return image; | |||
} |
@@ -0,0 +1,32 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2007-2010 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __PNG2IMG_H | |||
#define __PNG2IMG_H | |||
#include <clxclient.h> | |||
extern XImage *png2img (const char *file, X_display *disp, XftColor *bgnd); | |||
#endif |
@@ -0,0 +1,203 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <cairo/cairo.h> | |||
#include <cairo/cairo-xlib.h> | |||
#include <math.h> | |||
#include "rotary.h" | |||
cairo_t *RotaryCtl::_cairotype = 0; | |||
cairo_surface_t *RotaryCtl::_cairosurf = 0; | |||
int RotaryCtl::_wb_up = 4; | |||
int RotaryCtl::_wb_dn = 5; | |||
int RotaryCtl::_keymod = 0; | |||
int RotaryCtl::_button = 0; | |||
int RotaryCtl::_rcount = 0; | |||
int RotaryCtl::_rx = 0; | |||
int RotaryCtl::_ry = 0; | |||
RotaryCtl::RotaryCtl (X_window *parent, | |||
X_callback *cbobj, | |||
RotaryImg *image, | |||
int xp, | |||
int yp, | |||
int cbind) : | |||
X_window (parent, | |||
image->_x0 + xp, image->_y0 + yp, | |||
image->_dx, image->_dy, | |||
image->_backg->pixel), | |||
_cbobj (cbobj), | |||
_cbind (cbind), | |||
_image (image), | |||
_state (0), | |||
_count (0), | |||
_value (0), | |||
_angle (0) | |||
{ | |||
x_add_events ( ExposureMask | |||
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | |||
} | |||
RotaryCtl::~RotaryCtl (void) | |||
{ | |||
} | |||
void RotaryCtl::init (X_display *disp) | |||
{ | |||
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50); | |||
_cairotype = cairo_create (_cairosurf); | |||
} | |||
void RotaryCtl::fini (void) | |||
{ | |||
cairo_destroy (_cairotype); | |||
cairo_surface_destroy (_cairosurf); | |||
} | |||
void RotaryCtl::handle_event (XEvent *E) | |||
{ | |||
switch (E->type) | |||
{ | |||
case Expose: | |||
render (); | |||
break; | |||
case ButtonPress: | |||
bpress ((XButtonEvent *) E); | |||
break; | |||
case ButtonRelease: | |||
brelse ((XButtonEvent *) E); | |||
break; | |||
case MotionNotify: | |||
motion ((XMotionEvent *) E); | |||
break; | |||
default: | |||
fprintf (stderr, "RotaryCtl: event %d\n", E->type ); | |||
} | |||
} | |||
void RotaryCtl::bpress (XButtonEvent *E) | |||
{ | |||
int r = 0; | |||
double d; | |||
d = hypot (E->x - _image->_xref, E->y - _image->_yref); | |||
if (d > _image->_rad + 3) return; | |||
_keymod = E->state; | |||
if (E->button < 4) | |||
{ | |||
_rx = E->x; | |||
_ry = E->y; | |||
_button = E->button; | |||
r = handle_button (); | |||
_rcount = _count; | |||
} | |||
else if (_button) return; | |||
else if ((int)E->button == _wb_up) | |||
{ | |||
r = handle_mwheel (1); | |||
} | |||
else if ((int)E->button == _wb_dn) | |||
{ | |||
r = handle_mwheel (-1); | |||
} | |||
if (r) | |||
{ | |||
callback (r); | |||
render (); | |||
} | |||
} | |||
void RotaryCtl::brelse (XButtonEvent *E) | |||
{ | |||
if (_button == (int)E->button) | |||
{ | |||
_button = 0; | |||
callback (RELSE); | |||
} | |||
} | |||
void RotaryCtl::motion (XMotionEvent *E) | |||
{ | |||
int dx, dy, r; | |||
if (_button) | |||
{ | |||
_keymod = E->state; | |||
dx = E->x - _rx; | |||
dy = E->y - _ry; | |||
r = handle_motion (dx, dy); | |||
if (r) | |||
{ | |||
callback (r); | |||
render (); | |||
} | |||
} | |||
} | |||
void RotaryCtl::set_state (int s) | |||
{ | |||
_state = s; | |||
render (); | |||
} | |||
void RotaryCtl::render (void) | |||
{ | |||
XImage *I; | |||
double a, c, r, x, y; | |||
I = _image->_image [_state]; | |||
XPutImage (dpy (), win (), dgc (), I, | |||
_image->_x0, _image->_y0, 0, 0, _image->_dx, _image->_dy); | |||
cairo_xlib_surface_set_drawable (_cairosurf, win(), | |||
_image->_dx, _image->_dy); | |||
c = _image->_lncol [_state] ? 1.0 : 0.0; | |||
a = _angle * M_PI / 180; | |||
r = _image->_rad; | |||
x = _image->_xref; | |||
y = _image->_yref; | |||
cairo_new_path (_cairotype); | |||
cairo_move_to (_cairotype, x, y); | |||
x += r * sin (a); | |||
y -= r * cos (a); | |||
cairo_line_to (_cairotype, x, y); | |||
cairo_set_source_rgb (_cairotype, c, c, c); | |||
cairo_set_line_width (_cairotype, 1.8); | |||
cairo_stroke (_cairotype); | |||
} | |||
@@ -0,0 +1,115 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __ROTARY_H | |||
#define __ROTARY_H | |||
#include <cairo/cairo.h> | |||
#include <cairo/cairo-xlib.h> | |||
#include <clxclient.h> | |||
class RotaryImg | |||
{ | |||
public: | |||
XftColor *_backg; | |||
XImage *_image [4]; | |||
char _lncol [4]; | |||
int _x0; | |||
int _y0; | |||
int _dx; | |||
int _dy; | |||
double _xref; | |||
double _yref; | |||
double _rad; | |||
}; | |||
class RotaryCtl : public X_window | |||
{ | |||
public: | |||
RotaryCtl (X_window *parent, | |||
X_callback *cbobj, | |||
RotaryImg *image, | |||
int xp, int yp, | |||
int cbind = 0); | |||
virtual ~RotaryCtl (void); | |||
enum { NOP = 200, PRESS, RELSE, DELTA }; | |||
int cbind (void) { return _cbind; } | |||
int state (void) { return _state; } | |||
double value (void) { return _value; } | |||
int keymod (void) { return _keymod; } | |||
int button (void) { return _button; } | |||
virtual void set_state (int s); | |||
virtual void set_value (double v) = 0; | |||
virtual void get_string (char * /*p*/, int /*n*/) {} | |||
static void init (X_display *disp); | |||
static void fini (void); | |||
static int _wb_up; | |||
static int _wb_dn; | |||
protected: | |||
X_callback *_cbobj; | |||
int _cbind; | |||
RotaryImg *_image; | |||
int _state; | |||
int _count; | |||
int _range; | |||
double _value; | |||
double _angle; | |||
void render (void); | |||
void callback (int k) { _cbobj->handle_callb (k, this, 0); } | |||
static int _keymod; | |||
static int _button; | |||
static int _rcount; | |||
static int _rx; | |||
static int _ry; | |||
private: | |||
void handle_event (XEvent *E); | |||
void bpress (XButtonEvent *E); | |||
void brelse (XButtonEvent *E); | |||
void motion (XMotionEvent *E); | |||
virtual int handle_button (void) = 0; | |||
virtual int handle_motion (int dx, int dy) = 0; | |||
virtual int handle_mwheel (int dw) = 0; | |||
static cairo_t *_cairotype; | |||
static cairo_surface_t *_cairosurf; | |||
}; | |||
#endif |
@@ -0,0 +1,182 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <stdio.h> | |||
#include <unistd.h> | |||
#include <string.h> | |||
#include <math.h> | |||
#include "shuffler.h" | |||
Shuffler::Shuffler (void) : | |||
_fsamp (0), | |||
_quant (0), | |||
_minpt (0), | |||
_iplen (0), | |||
_delay (0), | |||
_fft_time (0), | |||
_fft_freq (0), | |||
_fft_plan (0), | |||
_del_size (0), | |||
_del_wind (0), | |||
_del_data (0), | |||
_count (0), | |||
_touch0 (0), | |||
_touch1 (0) | |||
{ | |||
} | |||
Shuffler::~Shuffler (void) | |||
{ | |||
fini (); | |||
} | |||
void Shuffler::init (int fsamp, int quant, int abspri, int policy) | |||
{ | |||
int k; | |||
_fsamp = fsamp; | |||
_quant = quant; | |||
_minpt = 256; | |||
for (k = _fsamp, _iplen = 1024; k > 56000; k >>= 1, _iplen <<= 1); | |||
if (_quant > _iplen) _quant = _iplen; | |||
_delay = _iplen / 2; | |||
if (_quant < _minpt) _delay += 2 * _minpt - _quant; | |||
else _minpt = _quant; | |||
_del_size = 3 * _iplen; | |||
_del_wind = 0; | |||
_del_data = new float [3 * _iplen]; | |||
memset (_del_data, 0, 3 * _iplen * sizeof (float)); | |||
_fft_time = (float *) fftwf_malloc (_iplen * sizeof (float)); | |||
_fft_freq = (fftwf_complex *) fftwf_malloc ((_iplen / 2 + 1) * sizeof (fftwf_complex)); | |||
_fft_plan = fftwf_plan_dft_c2r_1d (_iplen, _fft_freq, _fft_time, FFTW_ESTIMATE); | |||
memset (_fft_time, 0, _iplen * sizeof (float)); | |||
_fft_time [_iplen / 2] = 1.0f; | |||
_convproc.configure (1, 1, _iplen, _quant, _minpt, _minpt); | |||
_convproc.impdata_create (0, 0, 1, _fft_time, 0, _iplen); | |||
_convproc.start_process (abspri, policy); | |||
} | |||
void Shuffler::fini (void) | |||
{ | |||
fftwf_free (_fft_time); | |||
fftwf_free (_fft_freq); | |||
fftwf_destroy_plan (_fft_plan); | |||
delete[] _del_data; | |||
_convproc.stop_process (); | |||
_convproc.cleanup (); | |||
} | |||
void Shuffler::reset (void) | |||
{ | |||
} | |||
void Shuffler::prepare (float gain, float freq) | |||
{ | |||
int i, h; | |||
float f, g, t; | |||
g = powf (10.0f, 0.05f * gain); | |||
g = sqrtf (g * g - 1.0f); | |||
freq /= g; | |||
h = _iplen / 2; | |||
for (i = 0; i < h; i++) | |||
{ | |||
f = i * _fsamp / _iplen; | |||
t = 1.0f / hypotf (1.0f, f / freq); | |||
_fft_freq [i][0] = 0; | |||
_fft_freq [i][1] = (i & 1) ? t : -t; | |||
} | |||
_fft_freq [h][0] = 0; | |||
_fft_freq [h][1] = 0; | |||
fftwf_execute(_fft_plan); | |||
g /= _iplen; | |||
for (i = 1; i < h; i++) | |||
{ | |||
t = g * (0.6f + 0.4f * cosf (i * M_PI / h)); | |||
_fft_time [h + i] *= t; | |||
_fft_time [h - i] *= t; | |||
} | |||
_fft_time [0] = 0; | |||
_fft_time [h] = 1; | |||
_convproc.impdata_update (0, 0, 1, _fft_time, 0, _iplen); | |||
_touch0++; | |||
} | |||
void Shuffler::process (int nsamp, float *inp [], float *out []) | |||
{ | |||
int i, k, im, ri, wi; | |||
float a, b, *p0, *p1, *q; | |||
im = _del_size; | |||
wi = _del_wind; | |||
ri = _del_wind - _delay; | |||
if (ri < 0) ri += im; | |||
for (k = 0; k < nsamp; k += _quant) | |||
{ | |||
if ((_count == 0) && (_touch0 != _touch1)) _count = 2 * _iplen; | |||
p0 = inp [0] + k; | |||
p1 = inp [1] + k; | |||
q = _convproc.inpdata (0); | |||
for (i = 0; i < _quant; i++) | |||
{ | |||
a = p0 [i] / 2; | |||
b = p1 [i] / 2; | |||
_del_data [wi++] = a + b; | |||
if (wi == im) wi = 0; | |||
*q++ = a - b; | |||
} | |||
_convproc.process (); | |||
p0 = out [0] + k; | |||
p1 = out [1] + k; | |||
q = _convproc.outdata (0); | |||
for (i = 0; i < _quant; i++) | |||
{ | |||
a = _del_data [ri++]; | |||
if (ri == im) ri = 0; | |||
b = *q++; | |||
p0 [i] = a + b; | |||
p1 [i] = a - b; | |||
} | |||
if (_count) | |||
{ | |||
_count -= _quant; | |||
if (_count == 0) _touch1 = _touch0; | |||
} | |||
} | |||
_del_wind = wi; | |||
} |
@@ -0,0 +1,67 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __SHUFFLER_H | |||
#define __SHUFFLER_H | |||
#include <zita-convolver.h> | |||
#include "global.h" | |||
class Shuffler | |||
{ | |||
public: | |||
Shuffler (void); | |||
~Shuffler (void); | |||
void init (int fsamp, int quant, int abspri, int policy); | |||
void reset (void); | |||
void prepare (float gain, float freq); | |||
void process (int nsamp, float *inp [], float *out []); | |||
bool ready (void) { return _touch0 == _touch1; } | |||
private: | |||
void fini (void); | |||
float _fsamp; | |||
int _quant; | |||
int _minpt; | |||
int _iplen; | |||
int _delay; | |||
float *_fft_time; | |||
fftwf_complex *_fft_freq; | |||
fftwf_plan _fft_plan; | |||
int _del_size; | |||
int _del_wind; | |||
float *_del_data; | |||
int _state; | |||
int _count; | |||
volatile int16_t _touch0; | |||
volatile int16_t _touch1; | |||
Convproc _convproc; | |||
}; | |||
#endif |
@@ -0,0 +1,135 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 "styles.h" | |||
#include "png2img.h" | |||
XftColor *XftColors_bls1 [NXFTCOLORS]; | |||
XftFont *XftFonts_bls1 [NXFTFONTS]; | |||
X_textln_style tstyle1; | |||
XImage *inputsect; | |||
XImage *shuffsect; | |||
XImage *lfshfsect; | |||
XImage *redzita_img; | |||
RotaryImg inpbal_img; | |||
RotaryImg hpfilt_img; | |||
RotaryImg shfreq_img; | |||
RotaryImg shgain_img; | |||
RotaryImg lffreq_img; | |||
RotaryImg lfgain_img; | |||
int styles_init (X_display *disp, X_resman *xrm) | |||
{ | |||
XftColors_bls1 [C_MAIN_BG] = disp->alloc_xftcolor (0.25f, 0.25f, 0.25f, 1.0f); | |||
XftColors_bls1 [C_MAIN_FG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f); | |||
XftColors_bls1 [C_TEXT_BG] = disp->alloc_xftcolor (1.0f, 1.0f, 0.0f, 1.0f); | |||
XftColors_bls1 [C_TEXT_FG] = disp->alloc_xftcolor (0.0f, 0.0f, 0.0f, 1.0f); | |||
XftFonts_bls1 [F_TEXT] = disp->alloc_xftfont (xrm->get (".font.text", "luxi:bold::pixelsize=11")); | |||
tstyle1.font = XftFonts_bls1 [F_TEXT]; | |||
tstyle1.color.normal.bgnd = XftColors_bls1 [C_TEXT_BG]->pixel; | |||
tstyle1.color.normal.text = XftColors_bls1 [C_TEXT_FG]; | |||
inputsect = png2img (SHARED"/inputsect.png", disp, XftColors_bls1 [C_MAIN_BG]); | |||
shuffsect = png2img (SHARED"/shuffsect.png", disp, XftColors_bls1 [C_MAIN_BG]); | |||
lfshfsect = png2img (SHARED"/lfshfsect.png", disp, XftColors_bls1 [C_MAIN_BG]); | |||
redzita_img = png2img (SHARED"/redzita.png", disp, XftColors_bls1 [C_MAIN_BG]); | |||
if (!inputsect || !shuffsect || !lfshfsect || !redzita_img) return 1; | |||
inpbal_img._backg = XftColors_bls1 [C_MAIN_BG]; | |||
inpbal_img._image [0] = inputsect; | |||
inpbal_img._lncol [0] = 1; | |||
inpbal_img._x0 = 28; | |||
inpbal_img._y0 = 17; | |||
inpbal_img._dx = 25; | |||
inpbal_img._dy = 25; | |||
inpbal_img._xref = 12.5; | |||
inpbal_img._yref = 12.5; | |||
inpbal_img._rad = 12; | |||
hpfilt_img._backg = XftColors_bls1 [C_MAIN_BG]; | |||
hpfilt_img._image [0] = inputsect; | |||
hpfilt_img._lncol [0] = 0; | |||
hpfilt_img._x0 = 87; | |||
hpfilt_img._y0 = 17; | |||
hpfilt_img._dx = 25; | |||
hpfilt_img._dy = 25; | |||
hpfilt_img._xref = 12.5; | |||
hpfilt_img._yref = 12.5; | |||
hpfilt_img._rad = 12; | |||
shgain_img._backg = XftColors_bls1 [C_MAIN_BG]; | |||
shgain_img._image [0] = shuffsect; | |||
shgain_img._lncol [0] = 0; | |||
shgain_img._x0 = 68; | |||
shgain_img._y0 = 17; | |||
shgain_img._dx = 25; | |||
shgain_img._dy = 25; | |||
shgain_img._xref = 12.5; | |||
shgain_img._yref = 12.5; | |||
shgain_img._rad = 12; | |||
shfreq_img._backg = XftColors_bls1 [C_MAIN_BG]; | |||
shfreq_img._image [0] = shuffsect; | |||
shfreq_img._lncol [0] = 0; | |||
shfreq_img._x0 = 127; | |||
shfreq_img._y0 = 17; | |||
shfreq_img._dx = 25; | |||
shfreq_img._dy = 25; | |||
shfreq_img._xref = 12.5; | |||
shfreq_img._yref = 12.5; | |||
shfreq_img._rad = 12; | |||
lffreq_img._backg = XftColors_bls1 [C_MAIN_BG]; | |||
lffreq_img._image [0] = lfshfsect; | |||
lffreq_img._lncol [0] = 0; | |||
lffreq_img._x0 = 14; | |||
lffreq_img._y0 = 31; | |||
lffreq_img._dx = 25; | |||
lffreq_img._dy = 25; | |||
lffreq_img._xref = 12.5; | |||
lffreq_img._yref = 12.5; | |||
lffreq_img._rad = 12; | |||
lfgain_img._backg = XftColors_bls1 [C_MAIN_BG]; | |||
lfgain_img._image [0] = lfshfsect; | |||
lfgain_img._lncol [0] = 1; | |||
lfgain_img._x0 = 63; | |||
lfgain_img._y0 = 17; | |||
lfgain_img._dx = 25; | |||
lfgain_img._dy = 25; | |||
lfgain_img._xref = 12.5; | |||
lfgain_img._yref = 12.5; | |||
lfgain_img._rad = 12; | |||
return 0; | |||
} | |||
void styles_fini (X_display * /*disp*/) | |||
{ | |||
} |
@@ -0,0 +1,63 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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. | |||
// | |||
// ---------------------------------------------------------------------- | |||
#ifndef __STYLES_H | |||
#define __STYLES_H | |||
#include <clxclient.h> | |||
#include "rotary.h" | |||
enum | |||
{ | |||
C_MAIN_BG, C_MAIN_FG, | |||
C_TEXT_BG, C_TEXT_FG, | |||
NXFTCOLORS | |||
}; | |||
enum | |||
{ | |||
F_TEXT, | |||
NXFTFONTS | |||
}; | |||
extern int styles_init (X_display *disp, X_resman *xrm); | |||
extern void styles_fini (X_display *disp); | |||
extern XftColor *XftColors_bls1 [NXFTCOLORS]; | |||
extern XftFont *XftFonts_bls1 [NXFTFONTS]; | |||
extern X_textln_style tstyle1; | |||
extern XImage *inputsect; | |||
extern XImage *shuffsect; | |||
extern XImage *lfshfsect; | |||
extern XImage *redzita_img; | |||
extern RotaryImg inpbal_img; | |||
extern RotaryImg hpfilt_img; | |||
extern RotaryImg shfreq_img; | |||
extern RotaryImg shgain_img; | |||
extern RotaryImg lffreq_img; | |||
extern RotaryImg lfgain_img; | |||
#endif |
@@ -0,0 +1,129 @@ | |||
// ---------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// 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 <stdlib.h> | |||
#include <stdio.h> | |||
#include <clthreads.h> | |||
#include <sys/mman.h> | |||
#include <signal.h> | |||
#include "global.h" | |||
#include "styles.h" | |||
#include "jclient.h" | |||
#include "mainwin.h" | |||
#define NOPTS 4 | |||
#define CP (char *) | |||
XrmOptionDescRec options [NOPTS] = | |||
{ | |||
{ CP"-h", CP".help", XrmoptionNoArg, CP"true" }, | |||
{ CP"-g", CP".geometry", XrmoptionSepArg, 0 }, | |||
{ CP"-s", CP".server", XrmoptionSepArg, 0 } | |||
}; | |||
static Jclient *jclient = 0; | |||
static Mainwin *mainwin = 0; | |||
static void help (void) | |||
{ | |||
fprintf (stderr, "\n%s-%s\n\n", PROGNAME, VERSION); | |||
fprintf (stderr, " (C) 2011 Fons Adriaensen <fons@linuxaudio.org>\n\n"); | |||
fprintf (stderr, "Options:\n"); | |||
fprintf (stderr, " -h Display this text\n"); | |||
fprintf (stderr, " -g <geometry> Window position\n"); | |||
fprintf (stderr, " -s <server> Jack server name\n"); | |||
exit (1); | |||
} | |||
static void sigint_handler (int) | |||
{ | |||
signal (SIGINT, SIG_IGN); | |||
mainwin->stop (); | |||
} | |||
int main (int ac, char *av []) | |||
{ | |||
X_resman xresman; | |||
X_display *display; | |||
X_handler *handler; | |||
X_rootwin *rootwin; | |||
int ev, xp, yp, xs, ys; | |||
xresman.init (&ac, av, CP PROGNAME, options, NOPTS); | |||
if (xresman.getb (".help", 0)) help (); | |||
display = new X_display (xresman.get (".display", 0)); | |||
if (display->dpy () == 0) | |||
{ | |||
fprintf (stderr, "Can't open display.\n"); | |||
delete display; | |||
return 1; | |||
} | |||
xp = yp = 100; | |||
xs = Mainwin::XSIZE + 4; | |||
ys = Mainwin::YSIZE + 30; | |||
xresman.geometry (".geometry", display->xsize (), display->ysize (), 1, xp, yp, xs, ys); | |||
if (styles_init (display, &xresman)) | |||
{ | |||
delete display; | |||
return 1; | |||
} | |||
jclient = new Jclient (xresman.rname (), xresman.get (".server", 0)); | |||
rootwin = new X_rootwin (display); | |||
mainwin = new Mainwin (rootwin, &xresman, xp, yp, jclient); | |||
rootwin->handle_event (); | |||
handler = new X_handler (display, mainwin, EV_X11); | |||
handler->next_event (); | |||
XFlush (display->dpy ()); | |||
ITC_ctrl::connect (jclient, EV_EXIT, mainwin, EV_EXIT); | |||
if (mlockall (MCL_CURRENT | MCL_FUTURE)) fprintf (stderr, "Warning: memory lock failed.\n"); | |||
signal (SIGINT, sigint_handler); | |||
do | |||
{ | |||
ev = mainwin->process (); | |||
if (ev == EV_X11) | |||
{ | |||
rootwin->handle_event (); | |||
handler->next_event (); | |||
} | |||
} | |||
while (ev != EV_EXIT); | |||
delete jclient; | |||
delete handler; | |||
delete rootwin; | |||
delete display; | |||
return 0; | |||
} | |||
@@ -30,25 +30,6 @@ | |||
using juce::FloatVectorOperations; | |||
using juce::ScopedPointer; | |||
// ----------------------------------------------------------------------- | |||
// fake jack_client_open/close per plugin | |||
static jack_client_t* gLastJackClient = nullptr; | |||
jack_client_t* jack_client_open(const char*, jack_options_t, jack_status_t* status, ...) | |||
{ | |||
if (status != NULL) | |||
*status = JackNoError; | |||
return gLastJackClient; | |||
} | |||
int jack_client_close(jack_client_t* client) | |||
{ | |||
carla_zeroStruct(client, 1); | |||
return 0; | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Jaaa Plugin | |||
@@ -1,7 +1,7 @@ | |||
// ------------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2004-2013 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// | |||
// 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 | |||
@@ -57,7 +57,7 @@ Spectwin::Spectwin (X_window *parent, X_resman *xres, ITC_ctrl *audio) : | |||
H.rname (xres->rname ()); | |||
H.rclas (xres->rclas ()); | |||
H.input (True); | |||
x_apply (&H); | |||
x_apply (&H); | |||
x_add_events (ExposureMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask); | |||
@@ -65,7 +65,7 @@ Spectwin::Spectwin (X_window *parent, X_resman *xres, ITC_ctrl *audio) : | |||
_plotmap = XCreatePixmap (dpy (), _plotwin->win (), XDEF - LMAR - RMAR, YDEF - TMAR - BMAR, disp ()->depth ()); | |||
_plotgct = XCreateGC (dpy (), _plotmap, 0, NULL); | |||
XSetWindowBackgroundPixmap (dpy (), _plotwin->win (), _plotmap); | |||
_plotwin->x_map (); | |||
_plotwin->x_map (); | |||
x = XDEF - RMAR + 3; | |||
y = 20; | |||
@@ -82,7 +82,7 @@ Spectwin::Spectwin (X_window *parent, X_resman *xres, ITC_ctrl *audio) : | |||
Bst1.size.x = RMAR - 6; | |||
_butt [BANDW] = new X_tbutton (this, this, &Bst1, x, y, "Bandw", 0, BANDW); | |||
y += Bst1.size.y; | |||
y += Bst1.size.y; | |||
_butt [VIDAV] = new X_tbutton (this, this, &Bst1, x, y, "Vid.Av", 0, VIDAV); | |||
y += Bst1.size.y; | |||
_butt [PEAKH] = new X_tbutton (this, this, &Bst1, x, y, "Pk Hold", 0, PEAKH); | |||
@@ -159,7 +159,7 @@ Spectwin::Spectwin (X_window *parent, X_resman *xres, ITC_ctrl *audio) : | |||
_trbuf = (fftwf_complex *) fftwf_malloc ((FFT_MAX / 2 + 9) * sizeof (fftwf_complex)); | |||
_power = new float [FFT_MAX + 1]; //!!! | |||
_spect = new Spectdata (disp()->xsize() - LMAR - RMAR); | |||
_spect = new Spectdata (disp()->xsize() - LMAR - RMAR); | |||
_spect->_npix = XDEF - LMAR - RMAR; | |||
_spect->_bits = 0; | |||
_spect->_avcnt = 0; | |||
@@ -193,19 +193,19 @@ void Spectwin::handle_event (XEvent *E) | |||
{ | |||
case Expose: | |||
expose ((XExposeEvent *) E); | |||
break; | |||
break; | |||
case ButtonPress: | |||
bpress ((XButtonEvent *) E); | |||
break; | |||
break; | |||
case MotionNotify: | |||
motion ((XPointerMovedEvent *) E); | |||
break; | |||
break; | |||
case ButtonRelease: | |||
brelse ((XButtonEvent *) E); | |||
break; | |||
break; | |||
case ConfigureNotify: | |||
resize ((XConfigureEvent *) E); | |||
@@ -292,9 +292,9 @@ void Spectwin::handle_callb (int k, X_window *W, _XEvent * /*E*/ ) | |||
B->set_stat (0); | |||
_spect->_avcnt = 0; | |||
} | |||
else | |||
else | |||
{ | |||
B->set_stat (2); | |||
B->set_stat (2); | |||
_butt [PEAKH]->set_stat (0); | |||
_spect->_avcnt = 1; | |||
_spect->_bits &= ~Spectdata::PEAKH; | |||
@@ -307,11 +307,11 @@ void Spectwin::handle_callb (int k, X_window *W, _XEvent * /*E*/ ) | |||
B->set_stat (0); | |||
_spect->_bits &= ~Spectdata::PEAKH; | |||
} | |||
else | |||
else | |||
{ | |||
B->set_stat (2); | |||
_butt [VIDAV]->set_stat (0); | |||
_spect->_bits |= Spectdata::PEAKH; | |||
_spect->_bits |= Spectdata::PEAKH; | |||
_spect->_avcnt = 0; | |||
} | |||
break; | |||
@@ -322,7 +322,7 @@ void Spectwin::handle_callb (int k, X_window *W, _XEvent * /*E*/ ) | |||
B->set_stat (0); | |||
_spect->_bits &= ~Spectdata::FREEZE; | |||
} | |||
else | |||
else | |||
{ | |||
B->set_stat (2); | |||
_spect->_bits |= Spectdata::FREEZE; | |||
@@ -386,7 +386,7 @@ void Spectwin::resize (XConfigureEvent *E) | |||
_ys = E->height; | |||
if (_xs > XMAX) _xs = XMAX; | |||
if (_ys > YMAX) _ys = YMAX; | |||
_plotwin->x_resize (_xs - LMAR - RMAR, _ys - TMAR - BMAR); | |||
_plotwin->x_resize (_xs - LMAR - RMAR, _ys - TMAR - BMAR); | |||
XFreePixmap (dpy (), _plotmap); | |||
XFreeGC (dpy (), _plotgct); | |||
_plotmap = XCreatePixmap (dpy (), _plotwin->win (), _xs - LMAR - RMAR, _ys - TMAR - BMAR, disp ()->depth ()); | |||
@@ -403,9 +403,9 @@ void Spectwin::redraw (void) | |||
{ | |||
X_draw D (dpy (), win (), dgc (), xft ()); | |||
D.setcolor (XftColors.main_fg); | |||
D.setfont (XftFonts.button); | |||
D.clearwin (); | |||
D.setcolor (XftColors_jaaa.main_fg); | |||
D.setfont (XftFonts_jaaa.button); | |||
D.clearwin (); | |||
D.move (_xs - RMAR + 2, 15); | |||
D.drawstring ("Input", -1); | |||
@@ -432,7 +432,7 @@ void Spectwin::redraw (void) | |||
void Spectwin::update (void) | |||
{ | |||
calc_spect (_spect); | |||
calc_spect (_spect); | |||
plot_clear (); | |||
if (_spect->_bits & (Spectdata::YP_VAL | Spectdata::YM_VAL)) | |||
{ | |||
@@ -589,11 +589,11 @@ void Spectwin::set_param (int i) | |||
case FMAX: _p_val = _f1; break; | |||
case FCENT: _p_val = _fc; break; | |||
case FSPAN: _p_val = _f1 - _f0; break; | |||
case AMAX: _p_val = _a1; break; | |||
case ASPAN: _p_val = _a1 - _a0; break; | |||
case AMAX: _p_val = _a1; break; | |||
case ASPAN: _p_val = _a1 - _a0; break; | |||
case NSLEV: _p_val = _a_ns; break; | |||
case SILEV: _p_val = _a_si; break; | |||
case SFREQ: _p_val = _f_si; break; | |||
case SILEV: _p_val = _a_si; break; | |||
case SFREQ: _p_val = _f_si; break; | |||
default: _p_val = 0; | |||
} | |||
show_param (); | |||
@@ -679,8 +679,8 @@ void Spectwin::set_fc (float f) | |||
void Spectwin::set_fs (float f) | |||
{ | |||
if (f < 0.001 * (_fmax - _fmin)) f = 0.001 * (_fmax - _fmin); | |||
_f0 = _fc - 0.5 * f; | |||
_f1 = _fc + 0.5 * f; | |||
_f0 = _fc - 0.5 * f; | |||
_f1 = _fc + 0.5 * f; | |||
if (_f0 < _fmin) { _f0 = _fmin; _f1 = 2 * _fc - _f0; } | |||
if (_f1 > _fmax) { _f1 = _fmax; _f0 = 2 * _fc - _f1; } | |||
_p_val = _f1 - _f0; | |||
@@ -782,7 +782,7 @@ float Spectwin::calcfreq (int x) | |||
void Spectwin::show_param (void) | |||
{ | |||
char s [16]; | |||
*s = 0; | |||
switch (_p_ind) | |||
{ | |||
@@ -805,7 +805,7 @@ void Spectwin::show_param (void) | |||
case NSLEV: | |||
case SILEV: | |||
sprintf (s, "%2.1f dB", _p_val); | |||
break; | |||
break; | |||
} | |||
_txt1->set_text (s); | |||
_txt1->clear_modified (); | |||
@@ -816,13 +816,13 @@ void Spectwin::plot_fscale (void) | |||
{ | |||
int i, j, k0, k1, x; | |||
float f, g, xr; | |||
char s [16]; | |||
char s [16]; | |||
X_draw D (dpy (), win (), dgc (), xft ()); | |||
D.setcolor (XftColors.spect_sc); | |||
D.setfont (XftFonts.scales); | |||
D.setcolor (XftColors_jaaa.spect_sc); | |||
D.setfont (XftFonts_jaaa.scales); | |||
D.setfunc (GXcopy); | |||
xr = _xs - LMAR - RMAR - 1; | |||
if (! _ngx) | |||
{ | |||
@@ -849,7 +849,7 @@ void Spectwin::plot_fscale (void) | |||
else if (f < 50) _df = 50; | |||
else if (f < 100) _df = 100; | |||
else if (f < 200) _df = 200; | |||
else _df = 500; | |||
else _df = 500; | |||
if (_df < 1.0f) i++; | |||
if (_df < 0.1f) i++; | |||
@@ -864,14 +864,14 @@ void Spectwin::plot_fscale (void) | |||
for (i = k0; i <= k1; i++) | |||
{ | |||
f = i * _df; | |||
x = (int)((f - _f0) / (_f1 - _f0) * xr + 0.5f); | |||
x = (int)((f - _f0) / (_f1 - _f0) * xr + 0.5f); | |||
sprintf (s, _fform, f / _funit); | |||
D.move (x + LMAR, _ys - BMAR); | |||
D.rdraw (0, 5); | |||
if (! (i & 1)) | |||
{ | |||
if (! _ngx) _grx [j++] = x; | |||
D.rmove (0, 10); | |||
D.rmove (0, 10); | |||
D.drawstring (s, 0); | |||
} | |||
} | |||
@@ -883,13 +883,13 @@ void Spectwin::plot_ascale (void) | |||
{ | |||
int i, j, k0, k1, y; | |||
float a, yr; | |||
char s [16]; | |||
char s [16]; | |||
X_draw D (dpy (), win (), dgc (), xft ()); | |||
D.setfont (XftFonts.scales); | |||
D.setcolor (XftColors.spect_sc); | |||
D.setfont (XftFonts_jaaa.scales); | |||
D.setcolor (XftColors_jaaa.spect_sc); | |||
D.setfunc (GXcopy); | |||
yr = _ys - TMAR - BMAR - 1; | |||
if (! _ngy) | |||
{ | |||
@@ -907,12 +907,12 @@ void Spectwin::plot_ascale (void) | |||
for (i = k0; i <= k1; i++) | |||
{ | |||
a = i * _da; | |||
y = (int)(yr - (a - _a0) / (_a1 - _a0) * yr + 0.5); | |||
y = (int)(yr - (a - _a0) / (_a1 - _a0) * yr + 0.5); | |||
sprintf (s, "%1.0f", a); | |||
D.move (LMAR, y + TMAR); | |||
D.rdraw (-5, 0); | |||
if (! _ngy) _gry [j++] = y; | |||
D.rmove (-3, 4); | |||
D.rmove (-3, 4); | |||
D.drawstring (s, 1); | |||
} | |||
if (! _ngy) _ngy = j; | |||
@@ -935,7 +935,7 @@ void Spectwin::plot_grid (void) | |||
X_draw D (dpy (), _plotmap, _plotgct, 0); | |||
D.setcolor (Colors.spect_gr ^ Colors.spect_bg); | |||
D.setfunc (GXxor); | |||
D.setfunc (GXxor); | |||
for (i = 0; i < _ngx; i++) | |||
{ | |||
D.move (_grx [i], 0); | |||
@@ -953,7 +953,7 @@ void Spectwin::plot_spect (Spectdata *Z) | |||
{ | |||
int i, n, x, y; | |||
XPoint P [XMAX - LMAR - RMAR]; | |||
float sx, ry, sy, v; | |||
float sx, ry, sy, v; | |||
X_draw D (dpy (), _plotmap, _plotgct, 0); | |||
D.setline (0); | |||
@@ -970,7 +970,7 @@ void Spectwin::plot_spect (Spectdata *Z) | |||
{ | |||
v = 10 * log10f (Z->_ym [i] + 1e-30f); | |||
P [n].x = i; | |||
P [n++].y = (int)(ry - (v - _a0) * sy + 0.5f); | |||
P [n++].y = (int)(ry - (v - _a0) * sy + 0.5f); | |||
} | |||
} | |||
D.drawlines (n, P); | |||
@@ -985,7 +985,7 @@ void Spectwin::plot_spect (Spectdata *Z) | |||
{ | |||
v = 10 * log10f (Z->_yp [i] + 1e-30f); | |||
P [n].x = i; | |||
P [n++].y = (int)(ry - (v - _a0) * sy + 0.5f); | |||
P [n++].y = (int)(ry - (v - _a0) * sy + 0.5f); | |||
} | |||
} | |||
D.drawlines (n, P); | |||
@@ -1016,12 +1016,12 @@ void Spectwin::plot_spect (Spectdata *Z) | |||
void Spectwin::print_note (char *s, float f) | |||
{ | |||
int n; | |||
f = fmodf (12 * log2 (f / 440.0f) + 129, 12.0f); | |||
n = (int)(floorf (f + 0.5f)); | |||
n = (int)(floorf (f + 0.5f)); | |||
f -= n; | |||
if (n == 12) n = 0; | |||
sprintf (s, " %5s (%+2.0lf)", _notes [n], 100.0f * f); | |||
sprintf (s, " %5s (%+2.0lf)", _notes [n], 100.0f * f); | |||
} | |||
@@ -1033,17 +1033,17 @@ void Spectwin::plot_annot (Spectdata *Z) | |||
X_draw D (dpy (), _plotmap, _plotgct, xft ()); | |||
D.setcolor (XftColors.spect_an); | |||
D.setfont (XftFonts.labels); | |||
D.setcolor (XftColors_jaaa.spect_an); | |||
D.setfont (XftFonts_jaaa.labels); | |||
D.setfunc (GXcopy); | |||
sprintf (s, "BW = %4.2lf Hz = %5.2lf dBHz, VA = %d, Ptot = %5.2lf", | |||
Z->_bw, | |||
sprintf (s, "BW = %4.2lf Hz = %5.2lf dBHz, VA = %d, Ptot = %5.2lf", | |||
Z->_bw, | |||
10 * log10 (Z->_bw), | |||
Z->_avcnt, | |||
10 * log10 (_ptot)); | |||
D.move (10, 15); | |||
D.drawstring (s, -1); | |||
D.drawstring (s, -1); | |||
if (Z->_bits & Spectdata::MK1_SET) | |||
{ | |||
@@ -1052,7 +1052,7 @@ void Spectwin::plot_annot (Spectdata *Z) | |||
v1 = 10 * log10 (Z->_mk1p * _fftlen / (2.02 * _fsamp)); | |||
sprintf (s, "Mk1 = %8.1lf Hz, %7.2lf dB/Hz", Z->_mk1f, v1); | |||
} | |||
else | |||
else | |||
{ | |||
v1 = 10 * log10 (Z->_mk1p); | |||
k = sprintf (s, "Mk1 = %8.1lf Hz, %7.2lf dB", Z->_mk1f, v1); | |||
@@ -1073,14 +1073,14 @@ void Spectwin::plot_annot (Spectdata *Z) | |||
{ | |||
sprintf (s, "Del = %8.1lf Hz, %7.2lf dB", Z->_mk2f - Z->_mk1f, v2 - v1); | |||
} | |||
else | |||
else | |||
{ | |||
sprintf (s, "Del = %8.1lf Hz, %7.2lf dB/Hz", Z->_mk2f - Z->_mk1f, v2 - v1); | |||
} | |||
D.move (10, 69); | |||
D.drawstring (s, -1); | |||
} | |||
else | |||
else | |||
{ | |||
v2 = 10 * log10 (Z->_mk2p); | |||
k = sprintf (s, "Mk2 = %8.1lf Hz, %7.2lf dB", Z->_mk2f, v2); | |||
@@ -1091,7 +1091,7 @@ void Spectwin::plot_annot (Spectdata *Z) | |||
{ | |||
sprintf (s, "Del = %8.1lf Hz, %7.2lf dBHz", Z->_mk2f - Z->_mk1f, v2 - v1); | |||
} | |||
else | |||
else | |||
{ | |||
sprintf (s, "Del = %8.1lf Hz, %7.2lf dB, (%5.3lf)", Z->_mk2f - Z->_mk1f, v2 - v1, Z->_mk2f / Z->_mk1f); | |||
} | |||
@@ -1110,7 +1110,7 @@ void Spectwin::alloc_fft (Spectdata *S) | |||
b = 1.41f * _fsamp / S->_bw;; | |||
k = FFT_MIN; | |||
while ((k < FFT_MAX) && (k < b)) k *= 2; | |||
while ((k < FFT_MAX) && (k < b)) k *= 2; | |||
S->_bw = 2.00 * _fsamp / k; | |||
if (_fftlen != k) | |||
{ | |||
@@ -1134,7 +1134,7 @@ void Spectwin::handle_mesg (ITC_mesg *M) | |||
sprintf (s, "%s-%s [%s]", PROGNAME, VERSION, Z->_jname); | |||
x_set_title (s); | |||
_ipcnt = 0; | |||
_audio->put_event (EV_MESG, new M_buffp (_ipbuf, INP_MAX, INP_LEN)); | |||
_audio->put_event (EV_MESG, new M_buffp (_ipbuf, INP_MAX, INP_LEN)); | |||
} | |||
M->recover (); | |||
} | |||
@@ -1150,7 +1150,7 @@ void Spectwin::handle_trig () | |||
if (_ipcnt % _ipmod == 0) | |||
{ | |||
if (_spect->_bits & Spectdata::FREEZE) return; | |||
if (k < _fftlen) | |||
if (k < _fftlen) | |||
{ | |||
memcpy (_ipbuf + INP_MAX, _ipbuf, k * sizeof (float)); | |||
k += INP_MAX; | |||
@@ -1173,14 +1173,14 @@ void Spectwin::handle_trig () | |||
memset (_power, 0, (FFT_MAX + 1) * sizeof (float)); | |||
if (_spect->_avcnt) _spect->_avcnt = 1; | |||
} | |||
k = _spect->_avcnt; | |||
k = _spect->_avcnt; | |||
h = _spect->_bits & Spectdata::PEAKH; | |||
a = 1.0f; | |||
if (k) | |||
{ | |||
a = 1.0f / k; | |||
if (k < _spect->_avmax) _spect->_avcnt = k + 1; | |||
} | |||
} | |||
b = 4.0f / ((float)_fftlen * (float)_fftlen); | |||
s = 0; | |||
pow = _power; | |||
@@ -1254,19 +1254,19 @@ void Spectwin::calc_spect (Spectdata *S) | |||
if (dd > dc) S->_bits |= Spectdata::YM_VAL; | |||
else S->_bits &= ~Spectdata::YM_VAL; | |||
f0 = S->_f0 - 0.5 * dd; | |||
j = (int)(ceil (f0 / dc)); | |||
j = (int)(ceil (f0 / dc)); | |||
if (j < 0) j = 0; | |||
for (i = 0; i < S->_npix; i++) | |||
{ | |||
fd = f0 + (i + 1) * dd; | |||
fc = j * dc; | |||
fc = j * dc; | |||
pp = pm = 0; | |||
for (k = 0; fc < fd; j++, fc += dc) | |||
{ | |||
if (j > _fftlen) break; | |||
p = _power [j]; | |||
if (p > pp) pp = p; | |||
if (p > pp) pp = p; | |||
pm += p; | |||
k++; | |||
} | |||
@@ -1287,12 +1287,12 @@ void Spectwin::calc_spect (Spectdata *S) | |||
if (S->_bits & Spectdata::MK1_NSE) calc_noise (&(S->_mk1f), &(S->_mk1p)); | |||
else calc_peak (&(S->_mk1f), &(S->_mk1p), dd / dc); | |||
} | |||
} | |||
if (S->_bits & Spectdata::MK2_SET) | |||
{ | |||
if (S->_bits & Spectdata::MK2_NSE) calc_noise (&(S->_mk2f), &(S->_mk2p)); | |||
else calc_peak (&(S->_mk2f), &(S->_mk2p), dd / dc); | |||
} | |||
} | |||
} | |||
@@ -1300,7 +1300,7 @@ void Spectwin::calc_noise (float *f, float *p) | |||
{ | |||
int i, j; | |||
float z; | |||
j = (int)(floor ((*f) * 2 * _fftlen / _fsamp + 0.5)); | |||
if (j < 10) j = 10; | |||
if (j > _fftlen - 10) j = _fftlen - 10; | |||
@@ -1314,7 +1314,7 @@ void Spectwin::calc_peak (float *f, float *p, float r) | |||
{ | |||
int i, j, k, n; | |||
float a, b, c, yl, yr, z; | |||
j = (int)(floor ((*f) * 2 * _fftlen / _fsamp + 0.5)); | |||
n = (int)(10 * r); | |||
if (n < 2) n = 2; | |||
@@ -1338,8 +1338,8 @@ void Spectwin::calc_peak (float *f, float *p, float r) | |||
k += j; | |||
a = sqrt (_power [k]); | |||
yl = sqrt (_power [k - 1]); | |||
yr = sqrt (_power [k + 1]); | |||
yl = sqrt (_power [k - 1]); | |||
yr = sqrt (_power [k + 1]); | |||
b = 0.5 * (yr - yl); | |||
c = 0.5 * (yr + yl) - a; | |||
@@ -1,7 +1,7 @@ | |||
// ------------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2004-2013 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// | |||
// 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 | |||
@@ -24,8 +24,8 @@ | |||
struct colors Colors; | |||
struct fonts Fonts; | |||
struct xft_colors XftColors; | |||
struct xft_fonts XftFonts; | |||
struct xft_colors XftColors_jaaa; | |||
struct xft_fonts XftFonts_jaaa; | |||
X_button_style Bst0, Bst1, BstA, BstB, BstM; | |||
X_textln_style Tst0, Tst1; | |||
@@ -55,33 +55,33 @@ void init_styles (X_display *disp, X_resman *xrm) | |||
Colors.butt_bgB = disp->alloc_color (xrm->get (".color.butt.bgB", "blue"), Colors.black); | |||
Colors.butt_bgM = disp->alloc_color (xrm->get (".color.butt.bgM", "green"), Colors.white); | |||
XftColors.white = disp->alloc_xftcolor ("white", 0); | |||
XftColors.black = disp->alloc_xftcolor ("black", 0); | |||
XftColors.main_fg = disp->alloc_xftcolor (xrm->get (".color.main.fg", "black"), XftColors.black); | |||
XftColors.text_fg = disp->alloc_xftcolor (xrm->get (".color.text.fg", "black"), XftColors.black); | |||
XftColors.spect_fg = disp->alloc_xftcolor (xrm->get (".color.spect.fg", "blue"), XftColors.black); | |||
XftColors.spect_sc = disp->alloc_xftcolor (xrm->get (".color.spect.sc", "black"), XftColors.black); | |||
XftColors.spect_an = disp->alloc_xftcolor (xrm->get (".color.spect.an", "red"), XftColors.black); | |||
XftColors.butt_fg0 = disp->alloc_xftcolor (xrm->get (".color.butt.fg0", "black"), XftColors.black); | |||
XftColors.butt_fg1 = disp->alloc_xftcolor (xrm->get (".color.butt.fg1", "black"), XftColors.black); | |||
XftColors.butt_fg2 = disp->alloc_xftcolor (xrm->get (".color.butt.fg2", "black"), XftColors.black); | |||
XftColors.butt_fgA = disp->alloc_xftcolor (xrm->get (".color.butt.fgA", "white"), XftColors.white); | |||
XftColors.butt_fgB = disp->alloc_xftcolor (xrm->get (".color.butt.fgB", "white"), XftColors.white); | |||
XftColors.butt_fgM = disp->alloc_xftcolor (xrm->get (".color.butt.fgM", "black"), XftColors.black); | |||
XftFonts.about1 = disp->alloc_xftfont (xrm->get (".font.about1", "times:pixelsize=24")); | |||
XftFonts.about2 = disp->alloc_xftfont (xrm->get (".font.about2", "times:pixelsize=14")); | |||
XftFonts.button = disp->alloc_xftfont (xrm->get (".font.button", "luxi:pixelsize=11")); | |||
XftFonts.labels = disp->alloc_xftfont (xrm->get (".font.labels", "luxi:pixelsize=11")); | |||
XftFonts.scales = disp->alloc_xftfont (xrm->get (".font.scales", "luxi:pixelsize=10")); | |||
Bst0.font = XftFonts.button; | |||
XftColors_jaaa.white = disp->alloc_xftcolor ("white", 0); | |||
XftColors_jaaa.black = disp->alloc_xftcolor ("black", 0); | |||
XftColors_jaaa.main_fg = disp->alloc_xftcolor (xrm->get (".color.main.fg", "black"), XftColors_jaaa.black); | |||
XftColors_jaaa.text_fg = disp->alloc_xftcolor (xrm->get (".color.text.fg", "black"), XftColors_jaaa.black); | |||
XftColors_jaaa.spect_fg = disp->alloc_xftcolor (xrm->get (".color.spect.fg", "blue"), XftColors_jaaa.black); | |||
XftColors_jaaa.spect_sc = disp->alloc_xftcolor (xrm->get (".color.spect.sc", "black"), XftColors_jaaa.black); | |||
XftColors_jaaa.spect_an = disp->alloc_xftcolor (xrm->get (".color.spect.an", "red"), XftColors_jaaa.black); | |||
XftColors_jaaa.butt_fg0 = disp->alloc_xftcolor (xrm->get (".color.butt.fg0", "black"), XftColors_jaaa.black); | |||
XftColors_jaaa.butt_fg1 = disp->alloc_xftcolor (xrm->get (".color.butt.fg1", "black"), XftColors_jaaa.black); | |||
XftColors_jaaa.butt_fg2 = disp->alloc_xftcolor (xrm->get (".color.butt.fg2", "black"), XftColors_jaaa.black); | |||
XftColors_jaaa.butt_fgA = disp->alloc_xftcolor (xrm->get (".color.butt.fgA", "white"), XftColors_jaaa.white); | |||
XftColors_jaaa.butt_fgB = disp->alloc_xftcolor (xrm->get (".color.butt.fgB", "white"), XftColors_jaaa.white); | |||
XftColors_jaaa.butt_fgM = disp->alloc_xftcolor (xrm->get (".color.butt.fgM", "black"), XftColors_jaaa.black); | |||
XftFonts_jaaa.about1 = disp->alloc_xftfont (xrm->get (".font.about1", "times:pixelsize=24")); | |||
XftFonts_jaaa.about2 = disp->alloc_xftfont (xrm->get (".font.about2", "times:pixelsize=14")); | |||
XftFonts_jaaa.button = disp->alloc_xftfont (xrm->get (".font.button", "luxi:pixelsize=11")); | |||
XftFonts_jaaa.labels = disp->alloc_xftfont (xrm->get (".font.labels", "luxi:pixelsize=11")); | |||
XftFonts_jaaa.scales = disp->alloc_xftfont (xrm->get (".font.scales", "luxi:pixelsize=10")); | |||
Bst0.font = XftFonts_jaaa.button; | |||
Bst0.color.bg [0] = Colors.butt_bg0; | |||
Bst0.color.fg [0] = XftColors.butt_fg0; | |||
Bst0.color.fg [0] = XftColors_jaaa.butt_fg0; | |||
Bst0.color.bg [1] = Colors.butt_bg1; | |||
Bst0.color.fg [1] = XftColors.butt_fg1; | |||
Bst0.color.fg [1] = XftColors_jaaa.butt_fg1; | |||
Bst0.color.bg [2] = Colors.butt_bg2; | |||
Bst0.color.fg [2] = XftColors.butt_fg2; | |||
Bst0.color.fg [2] = XftColors_jaaa.butt_fg2; | |||
Bst0.color.shadow.bgnd = Colors.main_bg; | |||
Bst0.color.shadow.lite = Colors.main_ls; | |||
Bst0.color.shadow.dark = Colors.main_ds; | |||
@@ -89,13 +89,13 @@ void init_styles (X_display *disp, X_resman *xrm) | |||
Bst0.size.y = 17; | |||
Bst0.type = X_button_style::RAISED; | |||
Bst1.font = XftFonts.button; | |||
Bst1.font = XftFonts_jaaa.button; | |||
Bst1.color.bg [0] = Colors.butt_bg0; | |||
Bst1.color.fg [0] = XftColors.butt_fg0; | |||
Bst1.color.fg [0] = XftColors_jaaa.butt_fg0; | |||
Bst1.color.bg [1] = Colors.butt_bg1; | |||
Bst1.color.fg [1] = XftColors.butt_fg1; | |||
Bst1.color.fg [1] = XftColors_jaaa.butt_fg1; | |||
Bst1.color.bg [2] = Colors.butt_bg2; | |||
Bst1.color.fg [2] = XftColors.butt_fg2; | |||
Bst1.color.fg [2] = XftColors_jaaa.butt_fg2; | |||
Bst1.color.shadow.bgnd = Colors.main_bg; | |||
Bst1.color.shadow.lite = Colors.main_ls; | |||
Bst1.color.shadow.dark = Colors.main_ds; | |||
@@ -105,28 +105,28 @@ void init_styles (X_display *disp, X_resman *xrm) | |||
BstA = Bst0; | |||
BstA.color.bg [1] = Colors.butt_bgA; | |||
BstA.color.fg [1] = XftColors.butt_fgA; | |||
BstA.color.fg [1] = XftColors_jaaa.butt_fgA; | |||
BstB = Bst0; | |||
BstB.color.bg [1] = Colors.butt_bgB; | |||
BstB.color.fg [1] = XftColors.butt_fgB; | |||
BstB.color.fg [1] = XftColors_jaaa.butt_fgB; | |||
BstM = Bst0; | |||
BstM.color.bg [1] = Colors.butt_bgM; | |||
BstM.color.fg [1] = XftColors.butt_fgM; | |||
BstM.color.fg [1] = XftColors_jaaa.butt_fgM; | |||
Tst0.font = XftFonts.labels; | |||
Tst0.font = XftFonts_jaaa.labels; | |||
Tst0.color.normal.bgnd = Colors.white; | |||
Tst0.color.normal.text = XftColors.text_fg; | |||
Tst0.color.normal.text = XftColors_jaaa.text_fg; | |||
Tst0.color.shadow.lite = Colors.main_ls; | |||
Tst0.color.shadow.dark = Colors.main_ds; | |||
Tst0.color.shadow.bgnd = Colors.main_bg; | |||
Tst1.font = XftFonts.labels; | |||
Tst1.font = XftFonts_jaaa.labels; | |||
Tst1.color.normal.bgnd = Colors.main_bg; | |||
Tst1.color.normal.text = XftColors.main_fg; | |||
Tst1.color.normal.text = XftColors_jaaa.main_fg; | |||
Tst1.color.focus.bgnd = Colors.text_ed; | |||
Tst1.color.focus.text = XftColors.main_fg; | |||
Tst1.color.focus.text = XftColors_jaaa.main_fg; | |||
Tst1.color.focus.line = Colors.text_ca; | |||
Tst1.color.shadow.lite = Colors.main_ls; | |||
Tst1.color.shadow.dark = Colors.main_ds; | |||
@@ -1,7 +1,7 @@ | |||
// ------------------------------------------------------------------------- | |||
// | |||
// Copyright (C) 2004-2013 Fons Adriaensen <fons@linuxaudio.org> | |||
// | |||
// | |||
// 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 | |||
@@ -52,7 +52,7 @@ struct colors | |||
}; | |||
struct fonts | |||
struct fonts | |||
{ | |||
}; | |||
@@ -75,7 +75,7 @@ struct xft_colors | |||
}; | |||
struct xft_fonts | |||
struct xft_fonts | |||
{ | |||
XftFont *about1; | |||
XftFont *about2; | |||
@@ -88,8 +88,8 @@ struct xft_fonts | |||
extern struct colors Colors; | |||
extern struct fonts Fonts; | |||
extern struct xft_colors XftColors; | |||
extern struct xft_fonts XftFonts; | |||
extern struct xft_colors XftColors_jaaa; | |||
extern struct xft_fonts XftFonts_jaaa; | |||
extern X_button_style Bst0, Bst1, BstA, BstB, BstM; | |||
extern X_textln_style Tst0, Tst1; | |||