id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,534,532
|
ivwcsdockwidget.h
|
schirmermischa_THELI/src/iview/dockwidgets/ivwcsdockwidget.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IVWCSDOCKWIDGET_H
#define IVWCSDOCKWIDGET_H
#include <QDockWidget>
namespace Ui {
class IvWCSDockWidget;
}
class IvWCSDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit IvWCSDockWidget(QWidget *parent = 0);
~IvWCSDockWidget();
double cd11_orig = 0.;
double cd12_orig = 0.;
double cd21_orig = 0.;
double cd22_orig = 0.;
double crpix1_orig = 0.;
double crpix2_orig = 0.;
double crval1_orig = 0.;
double crval2_orig = 0.;
void init();
private slots:
void on_cd11Slider_sliderMoved(int position);
void on_cd12Slider_sliderMoved(int position);
void on_cd21Slider_sliderMoved(int position);
void on_cd22Slider_sliderMoved(int position);
void on_plateScaleSlider_sliderMoved(int position);
void on_posAngleSlider_sliderMoved(int position);
void on_resetPushButton_clicked();
void on_cd11Slider_sliderReleased();
void on_cd12Slider_sliderReleased();
void on_cd21Slider_sliderReleased();
void on_cd22Slider_sliderReleased();
private:
Ui::IvWCSDockWidget *ui;
double cd11 = 0.;
double cd12 = 0.;
double cd21 = 0.;
double cd22 = 0.;
double crpix1 = 0.;
double crpix2 = 0.;
double crval1 = 0.;
double crval2 = 0.;
double translateCDmatrixSlider(int position, int maxRange);
double translatePlateScaleSlider(int position, int maxRange);
double translatePosAngleSlider(int position, int maxRange);
void updateLineEdits();
void restoreSliders();
float calcCDweight();
signals:
void CDmatrixChanged(double cd11, double cd12, double cd21, double cd22);
void CDmatrixChangedFITS(double cd11, double cd12, double cd21, double cd22);
void CRPIXchanged(double crpix);
};
#endif // IVWCSDOCKWIDGET_H
| 2,449
|
C++
|
.h
| 69
| 31.869565
| 81
| 0.749471
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,533
|
ivconfdockwidget.h
|
schirmermischa_THELI/src/iview/dockwidgets/ivconfdockwidget.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IVCONFDOCKWIDGET_H
#define IVCONFDOCKWIDGET_H
#include "../mybinnedgraphicsview.h"
#include "../mymagnifiedgraphicsview.h"
#include "../mygraphicsscene.h"
#include <QDockWidget>
#include "wcs.h"
#include "wcshdr.h"
namespace Ui {
class IvConfDockWidget;
}
class IView; // Forward declaration to access members
class IvConfDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit IvConfDockWidget(IView *parent = 0);
~IvConfDockWidget();
Ui::IvConfDockWidget *ui;
IView *iview;
MyMagnifiedGraphicsView *magnifiedGraphicsView;
MyBinnedGraphicsView *binnedGraphicsView;
MyGraphicsScene *magnifiedScene = new MyGraphicsScene();
MyGraphicsScene *binnedScene = new MyGraphicsScene();
int navigator_binned_nx = 0; // the width and height of the binned window;
int navigator_binned_ny = 0;
int navigator_magnified_nx = 0; // the width and height of the magnifyer window;
int navigator_magnified_ny = 0;
double cd11 = 0.;
double cd12 = 0.;
double cd21 = 0.;
double cd22 = 0.;
wcsprm *wcs = nullptr;
QRect currentFov; // the currently displayed field of view
QList<QGraphicsRectItem*> currentFovList;
void switchMode(QString mode);
double zoom2scale(int zoomlevel);
void drawCompass();
private slots:
void on_zoomOutPushButton_clicked();
void on_zoomInPushButton_clicked();
void on_minLineEdit_returnPressed();
void on_maxLineEdit_returnPressed();
void on_autocontrastPushButton_toggled(bool checked);
void on_quitPushButton_clicked();
void showCurrentMousePosBinned(QPointF currentMousePos);
public slots:
void on_zoomFitPushButton_clicked();
void on_zoomZeroPushButton_clicked();
void updateNavigatorMagnifiedReceived(QGraphicsPixmapItem *magnifiedPixmapItem, qreal magnification, float dx, float dy);
void updateNavigatorBinnedReceived(QGraphicsPixmapItem *binnedPixmapItem);
void mouseEnteredViewReceived();
void mouseLeftViewReceived();
void updateNavigatorBinnedViewportReceived(QRect rect);
void updateNavigatorMagnifiedViewportReceived();
void receiveWCS(wcsprm *WCS, bool wcsinit);
void clearMagnifiedSceneReceiver();
void clearBinnedSceneReceiver();
signals:
void autoContrastPushButton_toggled(bool checked);
void minmaxLineEdit_returnPressed(QString rangeMin, QString rangeMax);
void zoomFitPushButton_clicked(bool checked);
void zoomInPushButton_clicked();
void zoomOutPushButton_clicked();
void zoomZeroPushButton_clicked();
void closeIview();
};
#endif // IVCONFDOCKWIDGET_H
| 3,290
|
C++
|
.h
| 82
| 36.512195
| 125
| 0.775267
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,534
|
ivscampdockwidget.h
|
schirmermischa_THELI/src/iview/dockwidgets/ivscampdockwidget.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IVSCAMPDOCKWIDGET_H
#define IVSCAMPDOCKWIDGET_H
#include <QDockWidget>
namespace Ui {
class IvScampDockWidget;
}
class IView; // Forward declaration to access members
class IvScampDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit IvScampDockWidget(IView *parent = 0);
~IvScampDockWidget();
IView *iview;
private:
Ui::IvScampDockWidget *ui;
private slots:
void on_acceptSolution_clicked();
void on_rejectSolution_clicked();
signals:
void solutionAcceptanceState(bool state);
};
#endif // IVSCAMPDOCKWIDGET_H
| 1,247
|
C++
|
.h
| 37
| 31.405405
| 75
| 0.79732
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,535
|
ivredshiftdockwidget.h
|
schirmermischa_THELI/src/iview/dockwidgets/ivredshiftdockwidget.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IVREDSHIFTDOCKWIDGET_H
#define IVREDSHIFTDOCKWIDGET_H
#include <QDockWidget>
#include <QCheckBox>
#include <QList>
#include "../myaxis.h"
namespace Ui {
class IvRedshiftDockWidget;
}
class IView; // Forward declaration to access members
class IvRedshiftDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit IvRedshiftDockWidget(IView *parent = 0);
~IvRedshiftDockWidget();
Ui::IvRedshiftDockWidget *ui;
IView *iview;
QList<QPair<QString,float>> HList;
QList<QPair<QString,float>> HeList;
QList<QPair<QString,float>> NeList;
QList<QPair<QString,float>> NList;
QList<QPair<QString,float>> CList;
QList<QPair<QString,float>> OList;
QList<QPair<QString,float>> ArList;
QList<QPair<QString,float>> FeList;
QList<QPair<QString,float>> MgList;
QList<QPair<QString,float>> NaList;
QList<QPair<QString,float>> CaList;
QList<QPair<QString,float>> SList;
void init();
public slots:
void showWavelength(QString lobs, QString lrest);
void redshiftUpdatedReceiver(float z_0);
private slots:
void on_zLineEdit_textChanged(const QString &arg1);
void validate();
private:
void populateWavelengthMaps();
void showAxes();
signals:
void redshiftEdited(QString text);
};
#endif // IVREDSHIFTDOCKWIDGET_H
| 1,991
|
C++
|
.h
| 58
| 31.258621
| 75
| 0.770518
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,536
|
processingStatus.h
|
schirmermischa_THELI/src/processingStatus/processingStatus.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef PROCESSINGSTATUS_H
#define PROCESSINGSTATUS_H
#include <QObject>
#include <QDir>
#include <QString>
class ProcessingStatus : public QObject
{
Q_OBJECT
public:
explicit ProcessingStatus(QString dirName, QObject *parent = nullptr);
bool HDUreformat = false;
bool Processscience = false;
bool Chopnod = false;
bool Background = false;
bool Collapse = false;
bool Starflat = false;
bool Skysub = false;
QString statusString = "";
void writeToDrive(); // Used by Data class only
void readFromDrive(); // Used by Data class only
void reset();
void statusToBoolean(QString status);
QString getStatusString();
void inferStatusFromFilenames();
bool doesStatusFileExist();
void deleteFromDrive();
QString whatIsStatusOnDrive();
QString extractStatusFromFilename(QString &filename);
private:
QDir dir;
QString dirName = "";
signals:
void processingStatusChanged();
void messageAvailable(QString messageString, QString code);
void critical();
public slots:
};
#endif // PROCESSINGSTATUS_H
| 1,783
|
C++
|
.h
| 52
| 31.096154
| 75
| 0.760047
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,537
|
query.h
|
schirmermischa_THELI/src/query/query.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef QUERY_H
#define QUERY_H
#include "../processingInternal/data.h"
#include "../myimage/myimage.h"
#include "fitsio2.h"
#include <omp.h>
#include <QString>
#include <QTextStream>
#include <QByteArray>
#include <QObject>
#include <QMap>
class Data; // circular include directives triggered by myworker
class Query : public QObject
{
Q_OBJECT
public:
explicit Query(int *verbose);
~Query();
Data *scienceData = nullptr;
MyImage *photomImage = nullptr;
QString photomDir = "";
QString photomImageName = "";
bool suppressCatalogWarning = false;
int numChips = 1;
QString mainDirName;
QString refcatName = "";
QString alpha_manual = "";
QString delta_manual = "";
QString radius_manual = "";
QString magLimit_string = "";
QString maxProperMotion_string = "";
QString targetAlpha = "";
QString targetDelta = "";
QString refcatFilter1 = "";
QString refcatFilter2 = "";
QString refcatFilter3 = "";
QString refcatFilter4 = "";
QString refcatFilter5 = "";
long numSources = 0;
int numG2sources = 0;
float naxis1 = 0.; // needed for building the anet index
float naxis2 = 0.; // needed for building the anet index
float pixscale = 0.; // needed for building the anet index
float radius = 0.;
QString radius_string = "";
bool fromImage = false;
QVector<double> ra_out;
QVector<double> de_out;
QVector<float> mag1_out;
QVector<float> mag2_out;
QVector<float> mag3_out;
QVector<float> mag4_out;
QVector<float> mag5_out;
QVector<bool> G2type;
QVector<float> mag1err_out;
QVector<float> mag2err_out;
QVector<float> mag3err_out;
void initAstromQuery();
void doBrightStarQueryFromWeb();
void doAstromQueryFromWeb();
void doPhotomQueryFromWeb();
void doColorCalibQueryFromWeb();
void doGaiaQuery();
QString resolveTargetSidereal(QString target);
QString resolveTargetNonsidereal(QString target, QString dateobs, float geoLon, float geoLat);
void writeAstromScamp();
void writeAstromANET();
void writeAstromIview();
void pushNumberOfSources();
void identifySolarTypeStars();
signals:
void bulkMotionObtained(QString pmRA_GUI, QString pmDE_GUI);
void messageAvailable(QString messageString, QString code);
void critical();
private:
QString path;
QString thelidir;
QString userdir;
QString instrument_dir;
QString pythonExecutable = "";
QString curlExecutable = "";
// The location and radius for the search, and their string representations
double alpha = 0.;
double delta = 0.;
float magLimit = 25.;
float maxProperMotion = 1.e9;
QString alpha_string = "";
QString delta_string = "";
double rad = 3.1415926535 / 180.;
int *verbosity;
bool successProcessing = true;
QVector<double> raMotions; // Contains the proper motions in RA
QVector<double> deMotions; // Contains the proper motions in DEC
QVector<double> raMotions_err; // Contains the proper motion errors in RA
QVector<double> deMotions_err; // Contains the proper motion errors in DEC
double raBulkMotion = 0.;
double deBulkMotion = 0.;
double raErrBulkMotion = 0.;
double deErrBulkMotion = 0.;
double epoch = 0;
double epochReference = 2016.0; // Reference epoch for GAIA-DR3. WARNING: might change with newer GAIA releases!
// QString downloadServer = "";
QString queryCommand = "";
QByteArray byteArray;
bool successfulDataBaseAccess = true;
int firstUsableRow = 0; // The first line in the downloaded catalog that contains usable data (not counting #-ed lines)
// G2 references. These ranges roughly span G0V - G5V
const float sunUG = 1.43; // u-g
const float sunGR = 0.44; // g-r
const float sunRI = 0.11; // r-i
const float sunIZ = 0.03; // i-z
const float sunBV = 0.65; // B-V
const float sunVR = 0.36; // V-R
const float sunUGtol = 0.08; // tolerance
const float sunGRtol = 0.05; // tolerance
const float sunRItol = 0.05; // tolerance
const float sunIZtol = 0.05; // tolerance
const float sunBVtol = 0.05; // tolerance
float c1min = 0.;
float c1max = 0.;
float c2min = 0.;
float c2max = 0.;
float c3min = 0.;
float c3max = 0.;
float c1tol = 0.;
float c2tol = 0.;
float c3tol = 0.;
void getCatalogSearchLocationAstrom();
void getCatalogSearchLocationPhotom();
void getCatalogSearchRadiusAstrom();
void getCatalogSearchLocationColorCalib();
void buildQuerySyntaxAstrom();
void buildQuerySyntaxGaia();
void buildQuerySyntaxPhotom();
void buildQuerySyntaxColorCalib();
QString extractRaDecMagAstrom(QString &line);
void processAstromCatalog();
void processGaiaCatalog();
void processPhotomCatalog();
void processColorCalibCatalog();
void processBrightStarCatalog();
void getMedianEpoch();
// void provideHeaderInfo();
void measureBulkMotion();
void clearAstrom();
void clearPhotom();
void clearColorCalib();
void clearGaia();
void runCommand(QString command);
void dumpRefcatID();
void initPhotomQuery();
void initGaiaQuery();
void initColorCalibQuery();
QString filterStringToVizierName(QString filter);
QString extractRaDecMagPhotom(QString &line);
QString extractRaDecGaia(QString &line);
// QString parseXML(QString &line, const QString &tag);
// void parseXML2(QString &line, const QString &tag, QString &val1, QString &val2);
QString extractRaDecMagColorCalib(QString &line);
void printCfitsioError(QString funcName, int status);
};
#endif // QUERY_H
| 6,438
|
C++
|
.h
| 176
| 32.232955
| 125
| 0.707979
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,538
|
absphot.h
|
schirmermischa_THELI/src/abszp/absphot.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef ABSPHOT_H
#define ABSPHOT_H
#include <QVector>
class AbsPhot
{
public:
AbsPhot();
QVector<double> qv_RA = QVector<double>();
QVector<double> qv_DEC = QVector<double>();
QVector<double> qv_ZP = QVector<double>(); // the median ZP per aperture
QVector<double> qv_ZPerr = QVector<double>(); // the median ZP err per aperture
QVector<double> qv_mag1ref = QVector<double>(); // the reference magnitude per object
QVector<double> qv_mag2ref = QVector<double>(); // the reference magnitude to construct the color term per object
QVector<double> qv_mag1errref = QVector<double>(); // the reference magnitude error per object
QVector<double> qv_mag2errref = QVector<double>(); // the reference magnitude error to construct the color term per object
QVector<double> qv_colorIndividual = QVector<double>(); // individual color index per object
QVector<double> qv_colorErrIndividual = QVector<double>(); // individual color index error per object
QVector<double> qv_ZPIndividual = QVector<double>(); // individual ZP per object (magref - magobj)
QVector<double> qv_ZPerrIndividual = QVector<double>(); // individual ZP error per object (magref - magobj)
QVector<double> qv_colorIndividualOutlier = QVector<double>(); // individual color term per object that did not survive the fit
QVector<double> qv_ZPIndividualOutlier = QVector<double>(); // individual ZP per object (magref - magobj) that did not survive the fit
QVector<double> qv_colorManualOutlier = QVector<double>(); // individual color term per object that was manually rejected
QVector<double> qv_ZPManualOutlier = QVector<double>(); // individual ZP per object (magref - magobj) that was manually rejected
QVector<double> qv_magauto = QVector<double>(); // MAG_AUTO per object
QVector<double> qv_magerrauto = QVector<double>(); // MAGERR_AUTO per object
QVector<double> qv_apertures = QVector<double>(); // aperture sizes
QVector<bool> qv_fitMask = QVector<bool>(); // whether an individual object is masked for a fit iteration
QVector<bool> qv_fitMask_old = QVector<bool>(); // whether an individual object is masked for a fit iteration previously
QVector<bool> qv_ManualMask = QVector<bool>(); // whether an individual object was manually selected for exclusion
QVector<bool> qv_ManualMask_old = QVector<bool>(); // whether an individual object was previously manually selected for exclusion
// dims of magaper: numObj vectors, each vector conaining numAper apertures
QVector< QVector<double> > qv_magaper = QVector< QVector<double> >(); // contains all individual apertures per object, per aperture
QVector< QVector<double> > qv_magerraper = QVector< QVector<double> >(); // contains all individual apertures per object, per aperture
QString filter = "";
QString colorfilter = "";
QString color = "";
double slope = 0.;
double cutoff = 0.;
int numAper = 0;
int numObj = 0;
int num_outliers = 0;
int num_ManualOutliers = 0;
QVector<float> fitParams = QVector<float>(4,0.);
QVector<float> fitParamsErr = QVector<float>(4,0.);
bool initialized = false;
double ZPauto = 0.;
double ZPautoerr = 0.;
QString ZPSelected;
QString ZPerrSelected;
QString Aperture;
QString Color1Selected;
QString Color2Selected;
QString Color3Selected;
QString ColorErr1Selected;
QString ColorErr2Selected;
QString ColorErr3Selected;
void regressionLinfit(); // using an iterative linear fit
bool regression(int fitOrder); // Using a GSL polynomial fit
void clear();
void getColor();
void getZP();
private:
long setupFitMask();
};
#endif // ABSPHOT_H
| 4,576
|
C++
|
.h
| 79
| 53.911392
| 143
| 0.7089
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,539
|
abszeropoint.h
|
schirmermischa_THELI/src/abszp/abszeropoint.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef ABSZEROPOINT_H
#define ABSZEROPOINT_H
#include "../threading/abszpworker.h"
#include "../qcustomplot.h"
#include "../myimage/myimage.h"
#include "../iview/iview.h"
#include <QMainWindow>
#include <QThread>
#include <QVector>
#include <QFileInfo>
#include "absphot.h"
class AbszpWorker;
namespace Ui {
class AbsZeroPoint;
}
class AbsZeroPoint : public QMainWindow
{
Q_OBJECT
public:
explicit AbsZeroPoint(QString image, QWidget *parent = nullptr);
~AbsZeroPoint();
void plot();
QString startImage = "";
AbsPhot *absPhot = new AbsPhot();
QThread *workerThread;
AbszpWorker *abszpWorker;
float autoMaxVal = 100.; // determined by the coadd task on the coadded image
int verbosity = 0;
int maxCPU = 1;
void taskInternalAbszeropoint();
void updateSaturationValue(float value);
signals:
void messageAvailable(QString message, QString type);
void progressUpdate(float progress);
void resetProgressBar();
void finished();
void readyForPlotting();
void abszpClosed();
void updateAbsPhotPlot(bool checked);
public slots:
void updateVerbosity(int verbosityLevel);
void iViewClosed();
private slots:
void on_actionClose_triggered();
void on_closePushButton_clicked();
void on_showAbsphotPushButton_clicked();
void on_zpImageLineEdit_textChanged(const QString &arg1);
void on_zpRefcatComboBox_currentTextChanged(const QString &arg1);
void on_zpLoadPushButton_clicked();
void on_abortPushButton_clicked();
void on_startPushButton_clicked();
void on_zpClearPushButton_clicked();
void on_zpExportPushButton_clicked();
void on_zpFilterComboBox_currentTextChanged(const QString &arg1);
void showData(QCPAbstractPlottable *plottable, int dataIndex);
void on_zpFitOrderSpinBox_valueChanged(int arg1);
void displayMessage(QString message, QString type);
void finishedCalculations();
void buildAbsPhot();
void criticalReceived();
private:
void defaults_if_empty();
void initGUI();
void updateHeader();
void validate();
bool doColortermFit();
void updateCoaddHeader();
void pushBeginMessage();
void pushEndMessage();
void queryRefCat();
void loadPreferences();
void closeEvent(QCloseEvent *event);
void writeAbsPhotRefcat();
void clearText();
double getFirstZPestimate();
Ui::AbsZeroPoint *ui;
QString taskBasename = "AbsZeropoint";
QString thelidir;
QString userdir;
QFileInfo fileInfo;
QStringList totalCommandList;
bool performingStartup = true;
QVector<double> raRefCat;
QVector<double> deRefCat;
QVector<float> mag1RefCat;
QVector<float> mag2RefCat;
QVector<float> mag3RefCat;
QVector<float> mag1errRefCat;
QVector<float> mag2errRefCat;
QVector<float> mag3errRefCat;
long numRefSources = 0;
double refCatUpperMagLimit = 40.;
QVector<QVector<double>> refDat;
QVector<QVector<double>> objDat;
QVector<QVector<double>> matched;
MyImage *myImage;
bool workerInit = false;
bool workerThreadInit = false;
IView *iView;
bool iViewOpen = false;
};
#endif // ABSZEROPOINT_H
| 3,877
|
C++
|
.h
| 116
| 29.465517
| 87
| 0.74933
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,540
|
errordialog.h
|
schirmermischa_THELI/src/processingExternal/errordialog.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef ERRORDIALOG_H
#define ERRORDIALOG_H
#include <QDialog>
namespace Ui {
class ErrorDialog;
}
class ErrorDialog : public QDialog
{
Q_OBJECT
public:
explicit ErrorDialog(QWidget *parent = nullptr);
~ErrorDialog();
QString code;
QString title;
QString explanation;
QString suggestion;
QString logname;
QString line;
void translate();
void getErrorLine(QString code);
void update();
private slots:
void on_errorShowPushButton_clicked();
void on_errorLogfileLineEdit_textChanged(const QString &arg1);
private:
Ui::ErrorDialog *ui;
QString editorPreference;
int readSettings();
};
#endif // ERRORDIALOG_H
| 1,359
|
C++
|
.h
| 44
| 28.045455
| 75
| 0.77573
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,541
|
memoryviewer.h
|
schirmermischa_THELI/src/dockwidgets/memoryviewer.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MEMORYVIEWER_H
#define MEMORYVIEWER_H
#include "../processingInternal/controller.h"
#include "../processingInternal/data.h"
#include "../datamodel/datamodel.h"
#include "../threading/memoryworker.h"
#include "../iview/iview.h"
#include <QDockWidget>
#include <QMainWindow>
#include <QList>
#include <QThread>
#include <QComboBox>
class MainWindow; // forward declaration to access GUI members
class MemoryWorker; // Not sure why I need this forward declaration (otherwise compiler error; the controller doesn't require it, otoh)
class Controller; // only because of including memoryworker
class DataModel; // only because of including memoryworker
namespace Ui {
class MemoryViewer;
}
class MemoryViewer : public QDockWidget
{
Q_OBJECT
public:
explicit MemoryViewer(Controller *ctrl, MainWindow *parent = 0);
~MemoryViewer();
MainWindow *mainGUI;
Controller *controller;
Ui::MemoryViewer *ui; // public, so that we can access its members from outside
QList<DataModel*> dataModelList;
QThread *workerThread;
MemoryWorker *worker;
bool iViewOpen = false;
private:
void addData(const QList<Data *> &DT_x, const QString &type);
bool workerInit = false;
bool workerThreadInit = false;
IView *iView;
DataModel *emptyModel = new DataModel(this);
void addGlobalWeights();
void addDataWeights(const QList<Data *> &DT_x);
void addBackupDirs(const QString &dirName);
void showhideStatusCheckBoxes(QString type);
void updateStatusCheckBoxes(Data *data);
void repopulateRestoreComboBox();
void statusDataToCheckBox(Data *data);
void statusCheckBoxToData();
Data *getDataClassThisModel();
void hideStatusCheckBoxes();
public slots:
void populate();
void clearMemoryViewReceived();
void populateMemoryViewReceived();
void addBackupDirReceived(QString scienceDir);
void updateStatusCheckBoxesReceived(QString statusString);
void projectResetReceived();
private slots:
void on_datadirComboBox_currentIndexChanged(int index);
void on_downloadToolButton_clicked();
// void activeStateCheckBoxClicked(QModelIndex index);
void writeCheckBoxClicked(const QModelIndex &index);
void on_memoryTableView_clicked(const QModelIndex &index);
void currentlyDisplayedIndex_received(int currentId);
void on_restorePushButton_clicked();
void updateProcessingStatusOnDriveAndInData();
void updateStatusTipRestoreButton();
void on_restoreComboBox_currentTextChanged(const QString &arg1);
void iViewClosed_received();
void activationChangedReceiver();
signals:
void beginResetModel();
void endResetModel();
void refreshMemoryViewer();
void activationChanged();
};
#endif // MEMORYVIEWER_H
| 3,452
|
C++
|
.h
| 89
| 35.460674
| 135
| 0.77512
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,542
|
confdockwidget.h
|
schirmermischa_THELI/src/dockwidgets/confdockwidget.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef CONFDOCKWIDGET_H
#define CONFDOCKWIDGET_H
#include "readmes/scampreadme.h"
#include <QDockWidget>
#include <QMap>
#include <QMainWindow>
#include <QPushButton>
#include <QComboBox>
#include <QFile>
#include <QDebug>
#include <QString>
#include <QButtonGroup>
class MainWindow; // forward declaration to access GUI members
namespace Ui {
class ConfDockWidget;
}
class ConfDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit ConfDockWidget(MainWindow *parent = 0);
~ConfDockWidget();
Ui::ConfDockWidget *ui;
QMap<QString,QString> defaultMap;
MainWindow *mainGUI;
// The following are set externally by MainWindow::on_setupInstrumentComboBox_clicked()
QFile instrument_file;
QString instrument_dir;
QString instrument_name;
QString instrument_type;
QString instrument_bayer;
int instrument_nchips = 1;
QButtonGroup *norxtalkButtonGroup = new QButtonGroup(this);
QButtonGroup *rowxtalkButtonGroup = new QButtonGroup(this);
void load_default_stdcat();
bool checkRightScampMode(const QString &coordsMode);
private:
QList<QPushButton*> APIstdPushButtonList;
QList<QComboBox*> APIstdComboBoxList;
ScampReadme *scampreadme;
bool doingInitialLaunch = false;
void populateDefaultMap();
void populateAPIlists();
void establish_connections();
void launchViewer(const QString &mode);
void initConfDockWidget();
void applyStyleSheets();
void setupXtalkButtonGroups();
void validate();
void connect_validators();
void setupAstrometry();
private slots:
void on_APDrefcatComboBox_currentTextChanged(const QString &arg1);
void on_APIrefcatComboBox_currentTextChanged(const QString &arg1);
void on_ARCcatalogComboBox_currentTextChanged(const QString &arg1);
void on_ARCselectimagePushButton_clicked();
void on_ASTmethodComboBox_currentIndexChanged(int index);
void on_ASTmatchMethodComboBox_currentIndexChanged(int index);
void on_ASTreadmepushButton_clicked();
void on_COAcelestialtypeComboBox_activated(const QString &arg1);
void on_COAskypaPushButton_clicked();
void on_COCdirectionComboBox_currentTextChanged(const QString &arg1);
void on_confStackedWidget_currentChanged(int arg1);
void on_confForwardPushButton_clicked();
void on_confBackwardPushButton_clicked();
void on_skyAreaComboBox_currentTextChanged(const QString &arg1);
void on_skyAreaPushButton_clicked();
void showAPIsolution();
void switch_static_dynamic();
void toggle_icons_xtalkToolButtons();
void updateConfPageLabel();
void on_nonlinearityCheckBox_clicked();
void on_ASTviewCheckPlotsPushButton_clicked();
void update_COA_uniqueID();
public slots:
void loadDefaults();
void updateGaiaBulkMotion(const QString &pmRA, const QString &pmDE);
void updateAPIsolutions();
void updateARCdisplay();
void setupInstrumentComboBox_clicked();
void toggle_skyparams();
void toggle_skyparamThresholds(QString text);
void targetResolvedReceived(const QString &alpha, const QString &delta);
};
#endif // CONFDOCKWIDGET_H
| 3,814
|
C++
|
.h
| 99
| 34.838384
| 91
| 0.779583
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,543
|
monitor.h
|
schirmermischa_THELI/src/dockwidgets/monitor.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MONITOR_H
#define MONITOR_H
#include <QDockWidget>
#include <QMutex>
namespace Ui {
class Monitor;
}
class Monitor : public QDockWidget
{
Q_OBJECT
public:
explicit Monitor(QWidget *parent = 0);
~Monitor();
Ui::Monitor *ui;
QMutex mutex;
public slots:
void displayMessage(QString message, QString type);
void appendOK();
private:
};
#endif // MONITOR_H
| 1,075
|
C++
|
.h
| 35
| 28.514286
| 75
| 0.781676
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,544
|
imagestatistics.h
|
schirmermischa_THELI/src/imagestatistics/imagestatistics.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IMAGESTATISTICS_H
#define IMAGESTATISTICS_H
#include "../readmes/imstatsreadme.h"
#include "../iview/iview.h"
#include "../qcustomplot.h"
#include "../instrumentdata.h"
#include "../processingStatus/processingStatus.h"
#include <QMainWindow>
#include <myimage/myimage.h>
#include "../processingInternal/data.h"
#include <QVector>
namespace Ui {
class ImageStatistics;
}
class ImageStatistics : public QMainWindow
{
Q_OBJECT
public:
// Constructor passing a list of MyImages
// explicit ImageStatistics(QVector<QList<MyImage *> > &imlist, const QString main, const QString sciencedir,
// const instrumentDataType *instrumentData, QWidget *parent);
explicit ImageStatistics(QList<Data *> &datalist, const QString main, const QString sciencedir,
const instrumentDataType *instrumentData, QWidget *parent);
~ImageStatistics();
void keyReleaseEvent(QKeyEvent *event);
bool iViewOpen = false;
signals:
void imageSelected(int index);
public slots:
void currentlyDisplayedIndexReceived(int currentId);
void activationChangedReceiver();
void iviewNewImageShownReceiver(int newDataPoint);
private slots:
void dataPointClicked(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
void numericSelection();
void on_statisticsPushButton_clicked();
void on_exportPushButton_clicked();
void on_showPushButton_clicked();
void on_ClearPlotPushButton_clicked();
void on_restoreDataPushButton_clicked();
void on_clearSelectionPushButton_clicked();
void on_invertSelectionPushButton_clicked();
void on_readmePushButton_clicked();
void on_connectDataPointsCheckBox_clicked();
void uncheckIviewPushButton();
void validate();
// void currentlyDisplayedIndexReceived(int currentId);
void on_fwhmunitsComboBox_currentIndexChanged(const QString &arg1);
void on_actionClose_triggered();
void on_scienceComboBox_activated(const QString &arg1);
void on_chipsLineEdit_editingFinished();
void on_raLineEdit_editingFinished();
void on_decLineEdit_editingFinished();
private:
QString mainDir;
QString statusString;
ProcessingStatus *processingStatus;
const instrumentDataType *instData;
QList<Data*> dataList;
Data *scienceData;
Ui::ImageStatistics *ui;
QString thelidir;
QString userdir;
QVector<QList<MyImage*>> myExposureList;
QList<MyImage*> allMyImages;
QList<MyImage*> filteredMyImages;
QStringList dataName;
QStringList badStatsList;
QString scienceDirName;
QDir scienceDir;
QVector<double> dataImageNr = QVector<double>();
QVector<double> dataSky = QVector<double>();
QVector<double> dataAirmass = QVector<double>();
QVector<double> dataFWHM = QVector<double>();
QVector<double> dataRZP = QVector<double>();
QVector<double> dataEllipticity = QVector<double>();
bool skyData = true;
bool seeingData = true;
bool seeingFromGaia = false; // A flag whether the seeing was estimated from medians of all sources, or from a match with GAIA point sources
bool airmassData = true;
bool rzpData = true;
bool ellipticityData = true;
bool imgSelected = false;
bool statisticsDataDisplayed = false;
QString imgSelectedName = "";
int numObj = 0;
int lastDataPointClicked = -1;
enum Qt::MouseButton lastButtonClicked = Qt::LeftButton;
enum Qt::Key lastKeyPressed = Qt::Key_Left;
bool initKeySelection = false;
QString directionSwitched = "noSwitch";
IView *iView;
QCPGraph *skyGraph;
QCPGraph *seeingGraph;
QCPGraph *airmassGraph;
QCPGraph *rzpGraph;
QCPGraph *ellipticityGraph;
QCPGraph *skyGraphIview;
QCPGraph *seeingGraphIview;
QCPGraph *airmassGraphIview;
QCPGraph *rzpGraphIview;
QCPGraph *ellipticityGraphIview;
QCPDataSelection selection; // data points selected by mouse clicks or key presses
QCPDataSelection numSelection; // data points selected by manually entered numeric thresholds
QList<QCPGraph*> graphList;
QList<QCPGraph*> graphListIview;
QStringList filteredImageList;
QList<QLineEdit*> numericThresholdList;
ImstatsReadme *imstatsReadme;
QCPGraph::LineStyle myLineStyle;
void clearAll();
void clearData();
void clearSelection();
void makeConnections();
void plot();
void plotSelection(int index);
void readStatisticsData();
// void showNoData(QCPGraph *graph, float xpos, float ypos);
void makeListOfBadImages();
Data *getData(QList<Data *> DT_x, QString dirName);
void init();
bool isImageSelected(MyImage *myImage, const QString &ra, const QString &dec, const QVector<int> &chipID);
void activateImages();
void highlightClickedDataPoint();
};
#endif // IMAGESTATISTICS_H
| 5,543
|
C++
|
.h
| 140
| 35.5
| 155
| 0.749954
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,545
|
fitting.h
|
schirmermischa_THELI/src/tools/fitting.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef FITTING_H
#define FITTING_H
#include "../functions.h"
#include <gsl/gsl_math.h>
#include <gsl/gsl_interp2d.h>
#include <gsl/gsl_spline2d.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_multifit.h>
#include <gsl/gsl_vector.h>
#include <QVector>
#include <QObject>
class Fitting : public QObject
{
Q_OBJECT
public:
Fitting();
~Fitting();
bool FITSUCCESS = true;
void makePolynomialFit2D(const int order, QList<QVector<double>> nodes);
void makePolynomialFit2D(const int order, const QVector<double> x_in, const QVector<double> y_in,
const QVector<double> z_in, QVector<double> w_in = QVector<double>());
gsl_vector *c = nullptr; // e.g. for polynomial coefficients (fit result)
gsl_matrix *cov = nullptr;
signals:
void messageAvailable(QString message, QString type);
void critical();
void warning();
};
#endif // FITTING_H
| 1,595
|
C++
|
.h
| 43
| 34.093023
| 101
| 0.745939
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,546
|
imagequality.h
|
schirmermischa_THELI/src/tools/imagequality.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IMAGEQUALITY_H
#define IMAGEQUALITY_H
#include "../query/query.h"
#include "../processingInternal/data.h"
#include "../instrumentdata.h"
#include <QObject>
class ImageQuality : public QObject
{
Q_OBJECT
public:
explicit ImageQuality(const instrumentDataType *instrumentData, QString maindirname, QObject *parent = nullptr);
bool getSeeingFromGaia();
bool getSeeingFromRhMag();
double matchingTolerance = 1./3600; // 1.0 arcsec starting value
QString baseName;
double fwhm = -1.0; // in pixel
double ellipticity = -1.0;
long numSources = 0;
QVector<double> source;
QVector<QVector<double>> sourceCat;
QVector<QVector<double>> refCat;
QVector<double> sourceMag;
QVector<double> refRA;
QVector<double> refDEC;
private:
const instrumentDataType *instData;
QString mainDirName;
signals:
void messageAvailable(QString message, QString type);
void critical();
public slots:
private slots:
void displayMessageReceived(QString message, QString type);
void criticalReceived();
};
#endif // IMAGEQUALITY_H
| 1,790
|
C++
|
.h
| 50
| 32.8
| 116
| 0.765081
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,547
|
ram.h
|
schirmermischa_THELI/src/tools/ram.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef RAM_H
#define RAM_H
#include <QObject>
#include <QFile>
#include <QVector>
#include <QTextStream>
class RAM : public QObject
{
Q_OBJECT
public:
explicit RAM(QObject *parent = nullptr);
~RAM();
long getRAMload();
void getRAMInfo_MAC(unsigned long *pulSystem, unsigned long *pulUser, unsigned long *pulNice, unsigned long *pulIdle);
float getCurrentValue();
long totalRAM = 0;
signals:
private:
bool RAMbarDeactivated = false;
long availableRAM = 0;
void readStatsRAM_Linux();
void readStatsRAM_MAC();
QFile file;
QTextStream instream;
QString kernelType;
// void init();
public slots:
};
#endif // RAM_H
| 1,361
|
C++
|
.h
| 43
| 28.930233
| 122
| 0.763077
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,548
|
correlator.h
|
schirmermischa_THELI/src/tools/correlator.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef CORRELATOR_H
#define CORRELATOR_H
#include "../myimage/myimage.h"
#include <fftw3.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <QObject>
class Correlator : public QObject
{
Q_OBJECT
public:
explicit Correlator(const MyImage *refimg, const MyImage *comimg, QObject *parent = nullptr);
int numThreads = 1;
void xcorrelate();
QVector<float> find_peak();
private:
int naxis1;
int naxis2;
int n_pad;
int m_pad;
QVector<float> dataRef;
QVector<float> dataCom;
QVector<float> dataCorrelated;
bool successProcessing = true;
void padImages(const QVector<float> &dataref, const QVector<float> &datacom);
signals:
public slots:
};
#endif // CORRELATOR_H
| 1,420
|
C++
|
.h
| 43
| 30.325581
| 97
| 0.766912
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,549
|
detectedobject.h
|
schirmermischa_THELI/src/tools/detectedobject.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef DETECTEDOBJECT_H
#define DETECTEDOBJECT_H
#include <QObject>
#include <QVector>
#include<QBitArray>
#include "wcs.h"
class DetectedObject : public QObject
{
Q_OBJECT
void calcFlux();
void calcMoments();
void calcMomentsErrors();
void calcVariance();
void calcEllipticity();
void calcFluxRadius();
void calcWindowedMoments();
void calcWindowedMomentsErrors();
void calcMagAuto();
void getWindowedPixels();
void calcSkyCoords();
void calcWindowedEllipticity();
void filterSpuriousDetections();
QVector<double> calcFluxAper(float aperture);
void calcApertureMagnitudes();
void correctOriginOffset();
void calcFWHM();
bool isTruncated(const long xmin, const long xmax, const long ymin, const long ymax);
public:
explicit DetectedObject(const QList<long> &objectIndices, const QVector<float> &data, const QVector<float> &background,
const QVector<float> &weight, const QVector<bool> &mask, bool weightinmemory,
const long naxis1, const long naxis2, const long objid, const float satVal, const float gainval,
wcsprm &wcsImage, QObject *parent = nullptr);
~DetectedObject();
const QVector<float> &dataMeasure;
const QVector<float> &dataBackground;
const QVector<float> &dataWeight;
const QVector<bool> &mask;
bool badDetection = false; // set if anything goes wrong with an object parameter's calculation
bool globalMaskAvailable = true; // the default for internal processing (but not for external images, e.g. abs zeropoint)
bool weightInMemory = true;
wcsprm &wcs;
// Moments and shapes
// Using Source Extractor naming style for easier recognition
// ISOPHOTAL
long XMIN = 0; // min and max positions (used in calculations)
long XMAX = 0;
long YMIN = 0;
long YMAX = 0;
double X = 0.; // 1st moment // WARNING: zero-indexing, must add +1 if used externally
double Y = 0.; // 1st moment // WARNING: zero-indexing, must add +1 if used externally
double X2 = 0.; // 2nd moment
double Y2 = 0.; // 2nd moment
double XY = 0.; // 2nd moment
double X2Y2 = 0.; // helper variable
double A = 0; // major axis
double B = 0; // minor axis
double THETA = 0.; // position angle
double CXX = 0; // cartesian ellipticity parameterization
double CYY = 0.; // cartesian ellipticity parameterization
double CXY = 0.; // cartesian ellipticity parameterization
double XERR = 0.;
double YERR = 0.;
double ERRX2 = 0.;
double ERRY2 = 0;
double ERRXY = 0.;
double ERRA = 0.;
double ERRB = 0.;
double ERRTHETA = 0.;
double MAG_ISO = 0.;
double FLUX_ISO = 0.;
double XVAR = 0.;
double YVAR = 0.;
// WINDOWED
double XWIN = 0.; // windowed 1st moment // WARNING: zero-indexing, must add +1 if used externally
double YWIN = 0.; // windowed 1st moment // WARNING: zero-indexing, must add +1 if used externally
double X2WIN = 0.;
double Y2WIN = 0.;
double XYWIN = 0.;
double AWIN = 0.;
double BWIN = 0.;
double THETAWIN = 0.;
double CXXWIN = 0;
double CYYWIN = 0.;
double CXYWIN = 0.;
double ERRX2WIN = 0.;
double ERRY2WIN = 0.;
double ERRXYWIN = 0.;
double ERRAWIN = 0.;
double ERRBWIN = 0.;
double ERRTHETAWIN = 0.;
double XWINERR = 0.;
double YWINERR = 0.;
double MAG_AUTO = 0.;
double MAGERR_AUTO = 0.;
double FLUX_AUTO = 0.;
double FLUXERR_AUTO = 0.;
double FLUX_RADIUS = 0.;
double FWHM = 0.;
double ELLIPTICITY = 0.;
// APERTURE
QVector<double> FLUX_APER;
QVector<double> MAG_APER;
QVector<double> FLUXERR_APER;
QVector<double> MAGERR_APER;
float saturationValue = 1.e9;
double sigmai = 0.;
double sigmab = 0.;
double ZP = 0;
double ALPHA_J2000 = 0.;
double DELTA_J2000 = 0.;
double gain = 1.0;
double sigma_back = 0.;
double crval1 = 0.;
double crval2 = 0.;
long objID = 0;
long area = 0;
int FLAGS = 0;
bool aperFlagSetAlready = false;
QBitArray bitflags;
QVector<long> pixels_x;
QVector<long> pixels_y;
QVector<float> pixels_flux;
QVector<float> pixels_back;
QVector<float> pixels_weight;
QVector<long> pixelsWin_x;
QVector<long> pixelsWin_y;
QVector<float> pixelsWin_flux;
QVector<float> pixelsWin_back;
QVector<float> pixelsWin_weight;
QVector<float> apertures;
QVector<long> pixelsAper_x;
QVector<long> pixelsAper_y;
QVector<float> pixelsAper_flux;
QVector<float> pixelsAper_back;
QVector<float> pixelsAper_weight;
long naxis1 = 0; // image geometry, needed to respect boundaries
long naxis2 = 0;
double rad = 3.14159265/180.;
void computeObjectParams();
void remove();
signals:
public slots:
};
#endif // DETECTEDOBJECT_H
| 5,700
|
C++
|
.h
| 158
| 31.139241
| 127
| 0.672045
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,550
|
cfitsioerrorcodes.h
|
schirmermischa_THELI/src/tools/cfitsioerrorcodes.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef CFITSIOERRORCODES_H
#define CFITSIOERRORCODES_H
#include <QObject>
#include <QMap>
class CfitsioErrorCodes : public QObject
{
Q_OBJECT
void populateErrorKeyMap();
public:
explicit CfitsioErrorCodes(QObject *parent = nullptr);
QMap<int, QString> errorKeyMap;
signals:
public slots:
};
#endif // CFITSIOERRORCODES_H
| 1,023
|
C++
|
.h
| 29
| 33.310345
| 75
| 0.803462
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,551
|
cpu.h
|
schirmermischa_THELI/src/tools/cpu.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef CPU_H
#define CPU_H
#include <QObject>
#include <QFile>
#include <QVector>
#include <QTextStream>
class CPU : public QObject
{
Q_OBJECT
public:
explicit CPU(QObject *parent = nullptr);
~CPU();
int getCPUload();
void getCPUInfo_MAC(unsigned long *pulSystem, unsigned long *pulUser, unsigned long *pulNice, unsigned long *pulIdle);
float getCurrentValue();
signals:
private:
bool CPUbarDeactivated = false;
double tot1 = 0.;
double tot2 = 0.;
double idle1 = 0.;
double idle2 = 0.;
void readStatsCPU_Linux(double &totval, double &idleval);
void readStatsCPU_MAC(double &totval, double &idleval);
QFile file;
QTextStream instream;
int maxCPU = 1;
QString kernelType;
long long lastTotal = 0;
long long lastTotalActive = 0;
long long lastTotalIdle = 0;
void init();
public slots:
};
#endif // CPU_H
| 1,578
|
C++
|
.h
| 49
| 29.102041
| 122
| 0.749007
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,552
|
fitgauss1d.h
|
schirmermischa_THELI/src/tools/fitgauss1d.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef FITGAUSS1D_H
#define FITGAUSS1D_H
#include <QVector>
#include <QDebug>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_multifit_nlinear.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
struct fitData
{
double *t;
double *y;
long n;
};
double gaussian(const double a, const double b, const double c, const double t);
int func_f(const gsl_vector *x, void *params, gsl_vector *f);
int func_df(const gsl_vector *x, void *params, gsl_matrix *J);
int func_fvv(const gsl_vector *x, const gsl_vector *v, void *params, gsl_vector *fvv);
void solve_system(gsl_vector *x, gsl_multifit_nlinear_fdf *fdf, gsl_multifit_nlinear_parameters *params);
template<class T1>
QVector<float> fitGauss1D(const QVector<T1> dataY, double amp0, double mean0, double sigma0, const QVector<T1> dataX = QVector<T1>())
{
long n = dataY.length();
int p = 3; // number of parameters for the 1D Gaussian
// The arrays holding the data (GSL doesn't know anything about vectors)
double *xarr = new double[n];
double *yarr = new double[n];
// Copy the data
for (long i=0; i<n; ++i) {
if (dataX.isEmpty()) xarr[i] = double(i);
else xarr[i] = double(dataX[i]);
yarr[i] = double(dataY[i]);
}
struct fitData fit_data;
fit_data.n = n;
fit_data.t = xarr;
fit_data.y = yarr;
delete [] xarr;
delete [] yarr;
const gsl_rng_type * T = gsl_rng_default;
gsl_vector *f = gsl_vector_alloc(n);
gsl_vector *x = gsl_vector_alloc(p);
gsl_multifit_nlinear_fdf fdf;
gsl_multifit_nlinear_parameters fdf_params = gsl_multifit_nlinear_default_parameters();
gsl_rng *r;
gsl_rng_env_setup();
r = gsl_rng_alloc(T);
// define function to be minimized
fdf.f = func_f;
fdf.df = func_df;
fdf.fvv = func_fvv;
fdf.n = n;
fdf.p = p;
fdf.params = &fit_data;
// starting point
gsl_vector_set(x, 0, amp0);
gsl_vector_set(x, 1, mean0);
gsl_vector_set(x, 2, sigma0);
fdf_params.trs = gsl_multifit_nlinear_trs_lmaccel;
QVector<float> result; // contains amplitude, mean, sigma
solve_system(x, &fdf, &fdf_params);
result << gsl_vector_get(x, 0) << gsl_vector_get(x, 1) << gsl_vector_get(x, 2);
// debug: print data and model
/*
double A = gsl_vector_get(x, 0);
double B = gsl_vector_get(x, 1);
double C = gsl_vector_get(x, 2);
for (size_t i=0; i<n; ++i) {
double ti = fit_data.t[i];
double yi = fit_data.y[i];
double fi = gaussian(A, B, C, ti);
qDebug() << ti << yi << fi;
}
*/
gsl_vector_free(f);
gsl_vector_free(x);
gsl_rng_free(r);
return result;
}
#endif // FITGAUSS1D_H
| 3,462
|
C++
|
.h
| 96
| 31.75
| 133
| 0.666367
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,553
|
tools.h
|
schirmermischa_THELI/src/tools/tools.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef TOOLS_H
#define TOOLS_H
#include <QObject>
#include <QVector>
#include <QList>
#include "instrumentdata.h"
#include "../myimage/myimage.h"
void binData(const QVector<float> &data, QVector<float> &dataBinned, const int n,
const int nb, const int mb, const int binX, const int binY);
void binDataMean(const QVector<float> &data, QVector<float> &dataBinned, const int n,
const int nb, const int mb, const int binX, const int binY);
QVector<int> CDmatrixToTransformationMatrix(QVector<double> CD, QString instName);
void debayer(int chip, MyImage *image, MyImage *imageB, MyImage *imageG, MyImage *imageR);
int direction(float N, float E, float W, float S);
void equalizeBayerFlat(MyImage *image);
void getBinnedSize(const instrumentDataType *instData, const QVector<QVector<int> > Tmatrices,
int &n_bin, int &m_bin, int binFactor, int &xminOffset, int &yminOffset);
float hue_transit(float l1, float l2, float l3, float v1, float v3);
void mapBinnedData(QVector<float> &dataBinnedGlobal, const QVector<float> &dataBinnedIndividual, QVector<int> T,
const int nGlobal, const int mGlobal, const int nInd, const int mInd, const long crpix1,
const long crpix2, const int xminOffset, const int yminOffset, const QString instName);
float posangle(const QVector<double> CDmatrix);
void rotateCDmatrix(QVector<double> &CDin, float pa_new);
void updateDebayerMemoryStatus(MyImage *image);
QVector<float> collapse_x(QVector<float> &data, const QVector<bool> &globalMask, QVector<bool> &objectMask,
const float kappa, const long n, const long m, const QString returnMode);
QVector<float> collapse_y(QVector<float> &data, const QVector<bool> &globalMask, QVector<bool> &objectMask,
const float kappa, const long n, const long m, const QString returnMode);
QVector<float> collapse_quad(QVector<float> &data, const QVector<bool> &globalMask, QVector<bool> &objectMask,
const float kappa, const long n, const long m, const QString direction, const QString returnMode);
void match2D(const QVector<QVector<double> > vec1, QVector<QVector<double> > vec2, QVector<QVector<double>> &matched,
double tolerance, int &multiple1, int &multiple2, int nthreads);
void match2D_refcoords(const QVector<QVector<double> > vec1, QVector<QVector<double> > vec2, QVector<QVector<double>> &matched,
double tolerance, int &multiple1, int &multiple2, int nthreads);
double haversine(double ra1, double ra2, double dec1, double dec2);
#endif // TOOLS_H
| 3,292
|
C++
|
.h
| 50
| 60.86
| 127
| 0.745128
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,554
|
splitter.h
|
schirmermischa_THELI/src/tools/splitter.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SPLITTER_H
#define SPLITTER_H
#include "fitsio.h"
#include "libraw/libraw.h"
#include "../instrumentdata.h"
#include "../processingInternal/mask.h"
#include "../processingInternal/data.h"
#include "../dockwidgets/confdockwidget.h"
#include <QObject>
#include <QMap>
class Splitter : public QObject
{
Q_OBJECT
public:
explicit Splitter(const instrumentDataType &instrumentData, const Mask *detectorMask, const Mask *altDetectorMask,
Data *someData, QString datatype, const ConfDockWidget *confDockWidget, QString maindirname,
QString subdirname, QString filename, int *verbose, QObject *parent = nullptr);
void extractImages();
void determineFileFormat();
// Pixel processing
// x-talk
float xtalkNorAmp = 0.; // normal xtalk amplitude
float xtalkRowAmp = 0.; // row xtalk amplitude
float xtalkKappa = 3.; // outlier rejection
QString xtalkDirection = "x";
int xtalkNsection = 32;
QString xtalkNorAmpString = "";
QString xtalkRowAmpString = "";
QString dataType = "";
QString splitFileName = "";
bool doXtalkNor = false;
bool doXtalkRow = false;
int xtalkNorMethod = -1;
int xtalkRowMethod = -1;
bool alreadyProcessed = false;
bool MEFpastingFinished = true;
bool maskSizeWarningShown = false;
float *dateObsIncrementor = nullptr; // External variable, initialized before constructing the first Splitter object
float gainForSaturation = 1.0;
float minGainValue = 0.0; // unused
long memoryUsed = 0;
// Nonlinearity
QList<QVector<float>> nonlinearityCoefficients;
// Overscan
// Function pointer (updated externally by the controller)
float (*combineOverscan_ptr) (const QVector<float> &, const QVector<bool> &, long) = nullptr;
const Mask *mask;
const Mask *altMask; // alternative mask, in case of e.g. GROND where we have two very different detector types
Data *data;
QMap<QString, QStringList> headerDictionary; // Defined once in the controller, we just link to it; NOPE! Local copy, thread safety!
QMap<QString, QString> filterDictionary; // Defined once in the controller, we just link to it
QMap<QString, QString> instrumentDictionary; // Defined once in the controller, we just link to it
QStringList dummyKeys; // Defined once in the controller, we just link to it
QStringList headerTHELI;
float saturationValue = (float)USHRT_MAX;
float userSaturationValue = 0.;
QStringList multiChannelMultiExt; // Contains all instruments having multiple readout channels, stored in separate FITS extensions
bool successProcessing = true;
float progressStepSize = 0.;
float *progress = nullptr;
omp_lock_t *progressLock = nullptr;
omp_lock_t *genericLock = nullptr;
bool commaDetected = false;
void compileNumericKeys();
private:
fitsfile *rawFptr = nullptr;
LibRaw rawProcessor;
int rawStatus = 0;
int numExt = 1; // Number of FITS extensions in a 2D MEF
int numSlice = 1; // Number of slices in a 3D cube
int numHDU = 1; // Number of HDUs in a FITS file
int *verbosity;
long naxis1Raw = 0; // Before trimming overscan regions
long naxis2Raw = 0; // Before trimming overscan regions
long naxis3Raw = 0; // Before trimming overscan regions
long naxis1 = 0;
long naxis2 = 0;
long naxis3 = 0;
double rad = 3.1415926535 / 180.;
long numAmpPerChip = 1; // The number of amplifiers per detector
bool ampInSeparateExt = false; // Whether the data from an amplifier is in a separate FITS extension (e.g., GMOS Hamamatsu, but not for SuprimeCam-2008)
QVector<QVector<long>> overscanX;
QVector<QVector<long>> overscanY;
QVector<QVector<long>> dataSection;
QVector<float> gain; // gain values per chip in a multichip camera
QVector<float> channelGains; // gain values per readout channel in a detector; e.g. 4-port readout mode with FORS2 not requiring pasting
int numReadoutChannels = 1; // number of readout channels per detector
// The following must have the same first dimension
QVector<QVector<long>> multiportOverscanSections; // The sections containing the overscan pixels. Coord system: entire FITS extension
QVector<QVector<long>> multiportIlluminatedSections; // The sections containing the illuminated pixels. Coord system: entire FITS channel
QVector<QVector<long>> multiportChannelSections; // The sections containing the entire readout channel (including overscan). Coord system: entire FITS channel
QVector<float> multiportGains; // The gain factors for each readout channel; e.g. if amplifiers stored in different FITS extensions
QVector<long> multiportOffsetX; // The x-offset of that port's data section from the lower left pixel of the pasted image
QVector<long> multiportOffsetY; // The y-offset of that port's data section from the lower left pixel of the pasted image
QStringList multiportOverscanDirections; // Whether the overscan strips are vertical or horizontal
instrumentDataType instData; // No pointer, because it is accessed from multiple threads and is not thread safe (QVectors, QStrings)
// instrumentDataType altInstData; // For GROND, where we have two very different detector types
const ConfDockWidget *cdw;
QString name;
QString fileName;
QString path;
QString mainDirName;
QString subDirName;
QString baseName;
QString fitsType; // SINGLE, MEF or CUBE
QString dataFormat; // FITS or RAW, or UnknownFormat
QString bayerPattern = "";
QString filter = "Unknown";
QString instNameFromData = ""; // needed only for a very small number of cameras, where the instrument must be deduced from the headers (GROND)
QStringList numericKeyNames;
QString dateObsValue = "";
double crval1 = 0.0;
double crval2 = 0.0;
float chipGain = 1.0; // effective gain for this detector (could be computed for multi-amp detectors)
double positionAngle = 0.0; // in [deg]
float exptimeValue = 0.0; // header keyword value to calculate other keywords
float lstValue = 0.0; // header keyword value to calculate other keywords
double mjdobsValue = 0.0; // header keyword value to calculate other keywords
float sensorTemp = -1000.;
float cameraTemp = -1000.;
QString isoSpeed = "";
bool dateObsValid = true; // Used to see if we can safely and unambiguously rename files
QVector<float> dataRaw;
QVector<float> dataCubeRaw;
QVector<float> dataCurrent;
QVector<float> dataXcorr;
QVector<float> dataPasted; // Accumulates the data from readout channels in separate FITS extensions, until complete; Then transferred to dataCurrent;
QString fullExtHeaderString;
QString fullPrimaryHeaderString;
QStringList extHeader; // The header of the currently read extension
QStringList primaryHeader;
QString uniqueID = ""; // If dateobs cannot be determined unambiguously
// Processing parameters
void consistencyChecks();
void descrambleLiris();
void getCurrentExtensionData();
void getDetectorSections();
float polynomialSum(float x, QVector<float> coefficients);
void printCfitsioError(QString funcName, int status);
void readPrimaryHeader();
void readExtHeader();
void xtalk_method1();
void xtalk_method2();
void xtalk_method3();
void xtalk_method4();
void xtalk_method5();
void xtalk_method6();
void xtalk_method7();
void xtalk_method8();
void xtalk_method9();
void xtalk_method10();
void writeImage(int chipMapped);
void retainMandatoryKeywords();
void buildTheliHeader();
void buildTheliHeaderWCS(int chip);
void buildTheliHeaderFILTER(int chip);
void buildTheliHeaderEXPTIME();
void buildTheliHeaderMJDOBS();
void buildTheliHeaderAIRMASS();
void buildTheliHeaderDATEOBS();
void buildTheliHeaderGAIN(int chip);
void buildTheliHeaderSATURATION();
bool searchKey(const QString &searchKeyName, const QStringList &possibleKeyNames, QStringList &outputHeader);
bool searchKeyInHeader(const QString &searchKey, const QStringList &possibleKeyNames, const QStringList &inputHeader, QStringList &outputHeader);
bool searchKeyInHeaderValue(const QStringList &possibleKeyNames, const QStringList &inputHeader, int &value);
bool searchKeyInHeaderValue(const QStringList &possibleKeyNames, const QStringList &inputHeader, float &value);
bool searchKeyInHeaderValue(const QStringList &possibleKeyNames, const QStringList &inputHeader, double &value);
bool searchKeyInHeaderValue(const QStringList &possibleKeyNames, const QStringList &inputHeader, QString &keyValue);
bool searchKeyValue(const QStringList &possibleKeyNames, int &value);
bool searchKeyValue(const QStringList &possibleKeyNames, float &value);
bool searchKeyValue(const QStringList &possibleKeyNames, double &value);
bool searchKeyValue(const QStringList &possibleKeyNames, QString &value);
double dateobsToMJD();
double dateobsToLST();
double calcAirmass(double ahourangle);
double localSiderealTimeToAirmass();
bool checkFormatDATEOBS();
bool searchKeyInHeaderCRVAL(const QString searchKey, const QStringList &possibleKeyNames, const QStringList &inputHeader, QStringList &outputHeader);
void searchKeyCRVAL(const QString searchKey, const QStringList &possibleKeyNames, QStringList &outputHeader);
bool searchKeyLST(const QStringList &possibleKeyNames);
bool searchKeyInHeaderLST(const QStringList &possibleKeyNames, const QStringList &inputHeader);
void importRAW();
void buildHeaderRAW();
void extractImagesFITS();
void extractImagesRAW();
void overwriteCameraIniRAW();
void backupRawFile();
bool checkChipGeometry();
int getNorXtalkMethod();
int getRowXtalkMethod();
void correctXtalk();
void correctNonlinearity(int chip);
void correctOverscan();
// void doOverscan(float (*combineFunction_ptr)(const QVector<float> &, const QVector<bool> &, long),
// const QVector<long> &overscanXArea, const QVector<long> &overscanYArea, const QVector<long> vertices);
void cropDataSection(QVector<long> dataSection);
void initMyImage(int chip);
void getDataInFirstCubeSlice();
void getDataInCube();
void sliceCube(long slice);
void writeImageSlice(int chip, long slice);
void stackCube();
void manualWCSfix(int chip);
void WCSbuildCRVAL();
void WCSbuildCDmatrix(int chip);
void WCSbuildRADESYS();
void WCSbuildEQUINOX();
void WCSbuildCRPIX(int chip);
void WCSbuildCTYPE();
bool individualFixCDmatrix(int chip);
bool individualFixCRVAL();
void uncompress();
int inferChipID(int chip);
void convertToElectrons(int chip);
float harmonicGain(QVector<float> detectorGains);
bool individualFixGAIN(int chip);
bool isDetectorAlive(int &chipMapped);
void individualFixOutName(const int chipID);
void applyMask(int chip);
bool individualFixWriteImage(int chipMapped);
bool isImageUsable(int &chipMapped);
QVector<long> extractVertices(QString vertexString);
QVector<long> extractVerticesFromKeyword(QString keyword);
// void pasteMultiPortDataSections(QVector<long> dataSection);
void getMultiportInformation(int chip);
void doOverscanVertical(float (*combineFunction_ptr)(const QVector<float> &, const QVector<bool> &, long),
const QVector<long> &overscanArea, const QVector<long> dataVertices, float &overscanEstimate);
void doOverscanHorizontal(float (*combineFunction_ptr)(const QVector<float> &, const QVector<bool> &, long),
const QVector<long> &overscanArea, const QVector<long> dataVertices, float &overscanEstimate);
void pasteMultiportIlluminatedSections(int chip);
void pasteSubArea(QVector<float> &dataT, const QVector<float> &dataS, const QVector<long> §on,
const float corrFactor, const long nT, const long mT, const long nS);
void pasteSubArea(QVector<float> &dataT, const QVector<float> &dataS, const QVector<long> §ion,
const float corrFactor, const long offx, const long offy, const long nT, const long mT,
const long nS);
void testGROND();
QVector<long> extractVerticesFromKeyword(QString keyword1, QString keyword2, QString keyword3, QString keyword4);
QVector<long> extractReducedOverscanFromKeyword(QString keyword1, QString keyword2, int value3, int value4);
QVector<long> extractReducedIlluminationFromKeyword(QString keyword1, QString keyword2, int value3, int value4);
void updateMEFpastingStatus(int chip);
bool individualFixCRPIX(int chip);
void getNumberOfAmplifiers();
void resetInstrumentData();
void initAltInstrumentData(QString instrumentNameFullPath);
void testOverscan(QVector<int> &overscan);
void to_EN_US(QString &keyName, QString &keyValue);
bool checkCorrectMaskSize(const int chip);
QString mjdobsToDATEOBS(double mjd);
bool individualFixDATEOBS();
bool checkInstrumentConsistency(QString foundInstrumentName);
void updateMinGainValue(float gainValue);
void overrideDetectorSections(int chip);
bool individualFixFILTER(int chip);
bool individualFixEQUINOX();
// bool CDfromCDELTandPC(const QString cdeltstr, const QString pcstr, double &cd);
QVector<double> CDfromCDELT();
signals:
void messageAvailable(QString message, QString type);
void warning();
void critical();
void showMessageBox(QString trigger, QString part1, QString part2);
public slots:
};
#endif // SPLITTER_H
| 14,702
|
C++
|
.h
| 278
| 47.726619
| 166
| 0.734205
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,555
|
swarpfilter.h
|
schirmermischa_THELI/src/tools/swarpfilter.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SWARPFILTER_H
#define SWARPFILTER_H
#include "../instrumentdata.h"
#include "../myimage/myimage.h"
#include <omp.h>
#include <QVector>
#include <QObject>
#include <QDir>
class SwarpFilter : public QObject
{
Q_OBJECT
public:
SwarpFilter(QString coadddirname, QString kappaString, QString clustersizeString,
QString borderwidthString, bool checkflux, int maxCPU, int *verbose);
~SwarpFilter();
float *progress = nullptr;
void runCosmicFilter();
void init();
signals:
void messageAvailable(QString message, QString type);
void progressUpdate(float progress);
void critical();
private:
omp_lock_t lock;
float progressStepSize = 0;
int nthreads = 1;
bool successProcessing = true;
QVector<MyImage*> images;
QVector<MyImage*> weights;
long coadd_naxis1 = 0;
long coadd_naxis2 = 0;
float coadd_crpix1 = 0;
float coadd_crpix2 = 0;
long num_images = 0; // Number of resampled images
float kappa = 4.0; // Detection threshold (outliers in units of sigma)
int clusterSize = 1; // Minimum size of a cluster of bad pixels to trigger masking
bool checkFluxScale = true; // if RZP is used
int maskWidth = 0; // Width of an extra border around a detected bad pixel cluster
long blocksize = 0; // Number of lines read at a time
long chunksize = 0; // Number of pixels analysed in one step
long nblocks = 0; // The total number of blocks to process
QVector<long> naxis1;
QVector<long> naxis2;
QVector<float> crpix1; // CRPIX is integer if stacked with swarp
QVector<float> crpix2; // CRPIX is integer if stacked with swarp
QVector<float> fluxscale;
QVector<float> sky; // rescaled sky values (corrected for relative transparency by 'fluxscale')
QVector<long> xoffset; // number of pixels between the left border of coadd.fits and the resampled image
QVector<long> yoffset; // number of pixels between the lower border of coadd.fits and the resampled image
QVector< QVector<long> > badpixindex;
QVector< QVector<long> > block_coadd_index;
QVector< QVector<float> > block_coadd_image;
QDir coaddDir;
QString coaddDirName = "";
QString thelidir;
QString userdir;
int *verbosity;
void freeMemoryBlocks();
void freeMemoryVectors();
void getCoaddInfo();
void getGeometries();
void getImages();
void getBlocksize();
bool get_coaddblock(const int index, const long block, QVector<float> &resampledData, QVector<long> &resampledCoaddIndex);
void identify_bad_pixels(const QVector<float> &gooddata, const QVector<long> &gooddataind, const long ¤tpixel,
const long &ngoodweight, QVector<std::pair<long,long>> &bpp);
void initStorage();
void stackfilter_rejectmax(const QVector<float> &gooddata, float &meanval, float &rmsval);
void stackfilter_rejectminmax(const QVector<float> &gooddata, float &meanval, float &rmsval);
void updateBadPixelIndex(const QVector<std::pair<long, long> > bpp);
void writeWeight();
void stackfilter_MAD(const QVector<float> &gooddata, float &meanval, float &rmsval);
};
#endif // SWARPFILTER_H
| 3,952
|
C++
|
.h
| 88
| 40.534091
| 126
| 0.720052
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,556
|
fileprogresscounter.h
|
schirmermischa_THELI/src/tools/fileprogresscounter.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef FILEPROGRESSCOUNTER_H
#define FILEPROGRESSCOUNTER_H
#include <QObject>
#include <QDir>
#include <QTimer>
#include <QFile>
class FileProgressCounter : public QObject
{
Q_OBJECT
public:
explicit FileProgressCounter(QString dirname, QString filter, int numtotimages, float *progressDep,
QObject *parent = nullptr);
explicit FileProgressCounter(QString dirname, long finalsize, float *progressDep, QObject *parent = nullptr);
QDir dir;
QString dirName;
QStringList filterList;
int numTotImages = 0;
QTimer *timer = nullptr;
QFileInfo fi;
long finalSize = 0;
float *progress;
signals:
void progressUpdate(float progress);
public slots:
void numberFileProgress();
void sizeFileProgress();
void stopFileProgressTimerReceived();
};
#endif // FILEPROGRESSCOUNTER_H
| 1,542
|
C++
|
.h
| 43
| 32.418605
| 113
| 0.769334
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,557
|
polygon.h
|
schirmermischa_THELI/src/tools/polygon.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef POLYGON_H
#define POLYGON_H
#include <QVector>
void polygon2vertices(QString polystring, QVector<float> &vertx, QVector<float> &verty);
void addCircle_bool(const long n, const long m, float x, float y, float r, QString senseMode, QVector<bool> &mask);
void addPolygon_bool(const long n, const long m, const QVector<float> &vertx, const QVector<float> &verty, const QString senseMode, QVector<bool> &mask);
void addPolygon_float(const long n, const long m, const QVector<float> &vertx, const QVector<float> &verty, QString senseMode, QVector<float> &weight);
void addRegionFilesToMask(const long n, const long m, QString regionFile, QVector<bool> &mask, bool &isChipMasked);
void addRegionFilesToWeight(const long n, const long m, QString regionFile, QVector<float> &mask);
void region2circle(QString circlestring, float &x, float &y, float &r);
/*
Polygon tester (pnpoly), implemented in pnpoly_T() below
Copyright (c) 1970-2003, Wm. Randolph Franklin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
(1) Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimers.
(2) Redistributions in binary form must reproduce the above copyright notice in
the documentation and/or other materials provided with the distribution.
(3) The name of W. Randolph Franklin may not be used to endorse or promote
products derived from this Software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
template<class T>
bool pnpoly_T(const QVector<T> &vertx, const QVector<T> &verty, const T testx, const T testy)
{
long i, j;
long nvert = vertx.length();
bool c = false;
for (i=0, j=nvert-1; i<nvert; j=i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c; // false if point is outside polygon, true if inside, true or false if exactly on the connecting line
}
#endif // POLYGON_H
| 3,523
|
C++
|
.h
| 61
| 55.57377
| 153
| 0.772556
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,558
|
controller.h
|
schirmermischa_THELI/src/processingInternal/controller.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
// The controller class keeps track of all data defined in the data directory tree,
// and whether it is kept in memory or on disk, throughout the processing.
// It also defines all the processing functions, kept separately in processing.cc
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <omp.h>
#include "data.h"
#include "mask.h"
#include "dockwidgets/memoryviewer.h"
#include "dockwidgets/confdockwidget.h"
#include "dockwidgets/monitor.h"
#include "../threading/scampworker.h"
#include "../threading/swarpworker.h"
#include "../tools/fileprogresscounter.h"
#include "photinst.h"
#include "../iview/iview.h"
#include "../query/query.h"
#include "../tools/cpu.h"
#include "../tools/ram.h"
#include <QObject>
#include <QList>
#include <QMainWindow>
#include <QDir>
#include <QLineEdit>
#include <QTextStream>
#include <QCheckBox>
#include <QComboBox>
#include <QProcess>
#include <QMap>
class MainWindow; // forward declaration to access GUI members
class Data; // circular include directives triggered by memoryworker
class Query; // circular include directives triggered by memoryworker
class MemoryViewer;
class Controller : public QMainWindow
{
Q_OBJECT
private:
bool taskRunning = false;
QString thelidir;
QString userdir;
QMap<QString,QString> commentMap;
struct QPairSecondComparer
{
template<typename T1, typename T2>
bool operator()(const QPair<T1,T2> & a, const QPair<T1,T2> & b) const
{
return a.second < b.second;
}
};
QDir dir;
QString dirName;
QString tmpCoaddDir;
Data *tmpCoaddData;
// IView *checkplotViewer;
FileProgressCounter *numberFileCounter;
FileProgressCounter *sizeFileCounter;
long coaddNumImages = 0;
QString swarpCommand;
QString coaddDirName;
QString coaddScienceDir;
QString scampScienceDir;
QString anetDir;
QString scampHeadersDir;
QString scampPlotsDir;
QString coaddUniqueID;
QString scampCommand;
QString sourceExtractorCommandOptions;
QString scampDir;
int processID;
bool scampSolutionAcceptanceState = false;
QVector<PhotInst*> photInstruments;
QVector<QVector<long>> overscanX;
QVector<QVector<long>> overscanY;
QVector<QVector<long>> dataSection;
bool globalweights_created = false;
long splitterMemoryUsed = 0;
double rad = 3.1415926535 / 180.;
float minCoaddSaturationValue = 1.e12;
QString statusAtDistribute = "";
instrumentDataType altInstData; // For instruments with e.g. simultaneous optical and NIR detectors requiring different masks during HDU reformatting
QMap<QString,QStringList> headerDictionary;
QMap<QString,QString> filterDictionary;
QMap<QString,QString> instrumentDictionary;
int recurseCounter = 0;
// Processing functions
void checkSuccessProcessing(const Data *data);
// void decrementCurrentThreads(omp_lock_t &lock);
QVector<QString> getBackgroundThresholds(const int loop, const bool twoPass, const QString DT, const QString DMIN, bool &doSourceDetection);
void getDetectorSections();
QList<QVector<float> > getNonlinearityCoefficients();
// void incrementCurrentThreads(omp_lock_t &lock);
void memoryDecideDeletableStatus(Data *data, bool deletable);
void parseDataDir(QLineEdit *le, QList<Data *> &DT_x);
void pushParallelizationToData(QList<Data *> DT_x);
void pushParallelizationToData(Data *data);
// void rejectChipsWithBrightStars(QList<MyImage *> backgroundList, QList<QVector<double> > &brightStarList);
// int reserveAvailableThreads(omp_lock_t &lock);
void retrieveBrightStars(Data *data, QList<QVector<double>> &brightStarList);
// void makeThreadsAvailable(omp_lock_t &lock, int numberThreadsBlocked);
void selectImagesDynamically(const QList<MyImage *> &backgroundList, const double &mjd_ref);
void selectImagesStatically(const QList<MyImage *> &backgroundList, MyImage *scienceImage);
void selectImagesFromSequence(QList<MyImage *> &backgroundList, const int &nGroups, const int &nLength, const int ¤tExp);
// Data handling
// void restoreData(MyImage *myImage, QString backupDir);
// Sky subtraction
void skysubModel(Data *scienceData, QString DT, QString DMIN, QString expFactor, QString kernelWidth);
void skysubPolynomialFit(Data *scienceData);
QList<MyImage*> measureSkyInBlankRegions(Data *scienceData, QString method = "");
void skysubConstantFromArea(Data *scienceData);
void skysubConstantReferenceChip(Data *scienceData, QString DT, QString DMIN, QString expFactor, QString kernelWidth);
void skysubConstantEachChip(Data *scienceData, QString DT, QString DMIN, QString expFactor, QString kernelWidth);
// Coaddition
void coaddPrepare(QString filterArg);
void coaddSmoothEdge();
void coaddPrepareProjectPM(QFile &headerFileOld, QString newHeaderName, QString refDE, double mjdobsZero, double mjdobsNow);
void coaddPrepareProjectRotation();
void coaddPrepareBuildSwarpCommand(QString refRA, QString refDE);
void coaddResampleBuildSwarpCommand(QString imageList, int i);
void coaddCoadditionBuildSwarpCommand(QString imageList);
void foldCoaddFits();
float coaddTexptime = 0.;
float coaddSkyvalue = 0.;
QString coaddFilter = "";
float coaddGain = 0.;
double mjdStart = 0.;
double mjdEnd = 0.;
double mjdMedian = 0.;
QString minDateObs = ""; // for the coadded image
QString maxDateObs = ""; // for the coadded image
// Astrometry
bool manualCoordsUpdate(Data *scienceData, QString mode);
void prepareScampRun(Data *scienceData);
long prepareScampCats(Data *scienceData, long &totNumObjects);
QString getUserParamLineEdit(const QLineEdit *le);
QString getUserParamCheckBox(const QCheckBox *cb);
QString getUserParamComboBox(const QComboBox *cb);
void buildScampCommand(Data *scienceData);
void sendMemoryPreferenceToImages(QList<Data*> DT_x);
int countBackgroundImages(QList<MyImage *> list, QString baseName);
// int getInternalThreads(int chip);
void populateCommentMap();
void pushBeginMessage(const QString idstring, const QString targetdir);
void pushConfigCoadd();
void pushConfigAstromphotom();
void pushConfigGetCatalogFromWeb();
void pushConfigGetCatalogFromImage();
void pushConfigCreatesourcecat();
void pushEndMessage(QString idstring, const QString targetdir);
bool idChipsWithBrightStars(Data *skyData, QList<QVector<double> > &brightStarList);
void flagImagesWithBrightStars(const QList<MyImage *> &backgroundList);
void getNumberOfActiveImages(Data *&data);
// void incrementProgress();
// void incrementProgressHalfStep();
// void incrementProgressCombinedStep();
// void rereadDataDir(QLineEdit *le, QList<Data *> &DT_x);
void doCrossCorrelation(Data *scienceData);
long coaddCoadditionGetSize();
void splitScampHeaders();
void scampCalcFluxscale();
int getMaxPhotInst();
// void provideHeaderInfo(Data *scpublic QMainWindowienceData);
void buildSourceExtractorCommandOptions();
void detectionInternal(Data *scienceData, QString minFWHM, QString maxFlag, QString maxEll);
void detectionSourceExtractor(Data *scienceData, QString minFWHM, QString maxFlag, QString maxEll);
void mergeInternal(Data *scienceData, QString minFWHM, QString maxFlag, QString maxEll);
void mergeSourceExtractor(Data *scienceData);
void populateHeaderDictionary();
void populateFilterDictionary();
long makeListofAllImages(QList<MyImage *> &allMyImages, Data *data);
// void updateMyImagesWithScampSolution(Data *scienceData);
void doImageQualityAnalysis();
void collectGaiaRaDec(MyImage *image, QVector<double> &dec, QVector<double> &ra, QVector<QVector<double> > &output);
void releaseMemory(float RAMneeded, int numThreads, QString mode = "");
long getNumObjectsScampCat(QString cat);
void satisfyMaxMemorySetting();
long getNumObjectsSourceExtractorCat(QString cat);
void emitSourceCountMessage(long &nobj, QString baseName);
void printCfitsioError(QString funcName, int status);
void printCfitsioWarning(QString funcName, int status);
void updateImageAndData(MyImage *image, Data *data);
void maskObjectsInSkyImagesPass1(const int chip, Data *skyData, Data *scienceData, const bool twoPass, const QString dt,
const QString dmin, const bool convolution, const QString expFactor);
void maskObjectsInSkyImagesPass2(const int chip, Data *skyData, Data *scienceData, const bool twoPass, const QString dt,
const QString dmin, const bool convolution, const QString expFactor,
const bool rescaleModel);
bool filterBackgroundList(const int chip, Data *skyData, MyImage *it, QString &backExpList, const int nGroups, const int nLength,
const int currentExposure, const QString mode);
// void maskObjectsInSkyImagesPass1_newParallel(Data *skyData, Data *scienceData, const QList<MyImage *> &backgroundList,
// const bool twoPass, const QString dt, const QString dmin, const bool convolution,
// const QString expFactor, const int threadID);
// void maskObjectsInSkyImagesPass2_newParallel(Data *skyData, Data *scienceData, MyImage *combinedImage, const QList<MyImage *> &backgroundList,
// const bool twoPass, const QString dt, const QString dmin, const bool convolution,
// const QString expFactor, const int chip, const bool rescaleModel,
// const int threadID, const QString mode);
void sendBackgroundMessage(const QString mode, const bool staticmodeldone, const QString basename, const int pass);
/*
void processBackgroundStatic(Data *scienceData, Data *skyData, const float nimg, QVector<QString> &numBackExpList,
QString dt, QString dmin, QString expFactor, QString nlow1,
QString nhigh1, QString nlow2, QString nhigh2,
const bool twoPass, const bool convolution, const bool rescaleModel,
const int nGroups, const int nLength, QVector<bool> &staticImagesWritten);
void processBackgroundDynamic(Data *scienceData, Data *skyData, const float nimg, QVector<QString> &numBackExpList,
QString dt, QString dmin, QString expFactor, QString nlow1,
QString nhigh1, QString nlow2, QString nhigh2,
const bool twoPass, const bool convolution, const bool rescaleModel,
const int nGroups, const int nLength, QVector<bool> &staticImagesWritten);
*/
void processBackground(Data *scienceData, Data *skyData, const float nimg, QVector<QString> &numBackExpList,
const QString dt, const QString dmin, const QString expFactor, const QString nlow1,
const QString nhigh1, const QString nlow2, const QString nhigh2,
const bool twoPass, const bool convolution, const bool rescaleModel,
const int nGroups, const int nLength, QString mode, QVector<bool> &staticImagesWritten);
void uniformMJDOBS(QDir &dir);
void finalizeSplitter(Data *data);
bool updateDataDirs(Data *data);
void initAltInstrumentData(QString instrumentNameFullPath);
void resetAltInstrumentData();
void testOverscan(QVector<int> &overscan);
void provideAlternativeMask();
void pushConfigHDUreformat();
void pushConfigProcessbias();
void pushConfigProcessdark();
void pushConfigProcessflat();
void pushConfigProcessflatoff();
void pushConfigBackground();
void pushConfigCollapse();
void pushConfigBinnedpreview();
void pushConfigGlobalweight();
void pushConfigIndividualweight();
void pushConfigSkysubModel();
void pushConfigSkysubConst();
void pushConfigSkysubPoly();
void flagLowDetectionImages(Data *scienceData, long &numExpRejected, long &numImgRejected);
void doDataFitInRAM(const long nImages, const long storageSize);
bool testResetDesire(const Data *data);
void runAnet(Data *scienceData);
void prepareAnetRun(Data *scienceData);
long getNumAnetChips(QString ahead);
long makeAnetHeaderList(Data *scienceData);
bool setupBackgroundList(int chip, Data *skyData, const QString &chipName);
void combineAllBackgroundUsabilityFlags(const QList<MyImage *> &backgroundList);
void getMinimumSaturationValue();
bool isExposureActive(QList<MyImage *> exposure);
private slots:
// void displayRAMload();
// void displayMemoryTotalUsed();
// void displayCPUload();
void displayProgress();
// void displayDriveSpace();
// The following can also be under 'private', but then the declaration must be preceded like this:
// Q_INVOKABLE QString taskHDUreformat();
void taskInternalProcessbias();
void taskInternalProcessdark();
void taskInternalProcessflatoff();
void taskInternalProcessflat();
void taskInternalProcessscience();
void taskInternalBackground();
void taskInternalCollapse();
void taskInternalBinnedpreview();
void taskInternalGlobalweight();
void taskInternalIndividualweight();
void taskInternalCreatesourcecat();
void taskInternalSkysub();
void taskInternalCoaddition();
void taskInternalGetCatalogFromWEB();
void taskInternalGetCatalogFromIMAGE();
void taskInternalHDUreformat();
void taskInternalResolveTargetSidereal();
void taskInternalRestoreHeader();
// void taskInternalCopyZeroOrder();
void taskInternalAstromphotom();
void taskInternalSeparate();
// void processExternalStdout();
// void processExternalStderr();
void finishedPreparationReceived();
void waitForResamplingThreads(int threadID);
void finishedScampReceived();
void fieldMatchedReceived();
void showScampCheckPlotsReceived();
void registerScampSolutionAcceptance(bool scampSolutionAccepted);
void continueWithCopyZeroOrder();
void copyZeroOrder();
void swarpErrorFoundReceived();
void scampErrorFoundReceived();
void addToProgressBarReceived(const float differential);
// void splitterMemoryReceived(long memoryUsed);
public:
explicit Controller(const instrumentDataType *instrumentData, QString statusold, ConfDockWidget *cdw, Monitor *processMonitor,
MainWindow *parent = nullptr);
~Controller();
// Multi-threading (accessed from e.g. memory viewer)
omp_lock_t lock;
omp_lock_t memoryLock;
omp_lock_t wcsLock;
omp_lock_t genericLock;
omp_lock_t progressLock;
omp_lock_t backgroundLock;
// QTimer *ramTimer;
// QTimer *cpuTimer;
QTimer *progressTimer;
// QTimer *driveTimer;
int maxCPU = 1; // Overall, maximum number of CPUs to be used
int localMaxCPU = 1; // depending on how the parallelization is made, and how many images we have, we may run with fewer threads
int maxExternalThreads = 1; // Maximum number of threads working on chips; equal or smaller than maxCPU
int maxInternalThreads = 1; // Maximum number of threads working on images; equal or smaller than maxCPU - maxExternalThreads
int maxThreadsIO = 1; // Maximum number of IO threads
long maxRAM = 512; // Max RAM in MB available for processing
int currentExternalThreads = 0; // The current number of external running threads (over different chips)
int currentInternalThreads = 0; // The current number of internal running threads (over images of the same chip)
int currentThreadsRunning = 0;
int availableThreads = 1;
bool useGPU = false;
int verbosity = 0;
bool userYield = false;
bool userStop = false;
bool userKill = false;
bool abortProcess = false; // Triggered by critical() signals emitted anywhere
bool swapWarningShown = false;
bool dataTreeUpdateOngoing = false;
QString currentSwarpProcess = "";
QString mainDirName;
QString instrument_dir;
Query *gaiaQuery;
bool gaiaQueryDone = false;
bool alwaysStoreData = false;
bool minimizeMemoryUsage = false;
bool homeDirWarningShowed = false;
float progress = 0.;
long numActiveImages = 0;
float progressStepSize = 0.;
float progressHalfStepSize = 0.;
float progressCombinedStepSize = 0.;
QString taskBasename;
QString instructions;
QString backupDirName = "";
QString statusOld = "";
QString statusNew = "";
QString lastTaskExecuted = ""; // needed to detect whether a task is repeated or not (must restore memory accordingly)
bool isTaskRepeated = false;
// DT = "DataTree"
// The lists contain multiple entries, e.g. if three different BIAS dirs are defined
QList<Data*> DT_BIAS;
QList<Data*> DT_DARK;
QList<Data*> DT_FLAT;
QList<Data*> DT_FLATOFF;
QList<Data*> DT_SCIENCE;
QList<Data*> DT_SKY;
QList<Data*> DT_STANDARD;
QList<QList<Data*>> masterListDT;
Data* GLOBALWEIGHTS = nullptr;
Mask *mask = nullptr;
Mask *altMask = nullptr; // for GROND types with different simultaneous detectors
MainWindow *mainGUI;
ConfDockWidget *cdw;
const instrumentDataType *instData;
Monitor *monitor;
MemoryViewer *memoryViewer;
bool successProcessing = true; // Reset externally to 'true' when clicking the 'start' button
void mapDataTree();
void taskProcessbias();
void runTask();
Data* getData(QList<Data*> DT_x, QString dirName);
Data* getDataAll(QString dirName);
QString manualCoordUpdateMode = "";
QVector<QThread*> workerThreads;
QVector<SwarpWorker*> swarpWorkers;
QVector<bool> threadsFinished;
bool workersInit = false;
bool workerThreadsInit = false;
QThread *workerThreadPrepare = nullptr;
QThread *workerThreadCoadd = nullptr;
QThread *workerThread = nullptr;
SwarpWorker *swarpWorker = nullptr;
ScampWorker *scampWorker = nullptr;
bool workerInit = false;
bool workerThreadInit = false;
Data *coaddScienceData;
Data *scampScienceData;
Data *currentData = nullptr;
QString currentDirName = "";
QVector<QProcess*> externalProcesses;
QVector<QString> swarpCommands;
QProcess *externalProcess;
QByteArray *stdoutByteArray;
QByteArray *stderrByteArray;
// Function pointers;
// Updated externally by MainWindow::updateControllerFunctors()
float (*combineOverscan_ptr) (const QVector<float> &, const QVector<bool> &, long);
float (*combineBias_ptr) (const QVector<float> &, const QVector<bool> &, long);
float (*combineDark_ptr) (const QVector<float> &, const QVector<bool> &, long);
float (*combineFlatoff_ptr) (const QVector<float> &, const QVector<bool> &, long);
float (*combineFlat_ptr) (const QVector<float> &, const QVector<bool> &, long);
float (*combineBackground_ptr) (const QVector<float> &, const QVector<bool> &, long);
void checkForUnsavedImages(long &numUnsavedLatest, long &numUnsavedAll);
void wipeDataTree();
void writeUnsavedImagesToDrive(bool includeBackup);
// QStringList getFilterList(QString scienceDir);
void downloadGaiaCatalog(Data *scienceData);
void downloadGaiaCatalog(Data *scienceData, QString radius);
void releaseAllMemory();
void restoreAllRawData();
void updateMasterList();
void connectDataWithMemoryViewer();
QLineEdit *getDataTreeLineEdit(Data *data);
void getFieldCenter(Data *data, QString &alphaCenter, QString &deltaCenter);
bool isMainDirHome();
void populateInstrumentDictionary();
bool isImageTooBig(QString name);
signals:
void loadViewer(QString dirname, QString filter, QString mode);
void messageAvailable(QString message, QString type);
void appendOK();
void showMessageBox(QString trigger, QString part1, QString part2);
void progressUpdate(float progress);
void targetResolved(QString alpha, QString delta);
void resetProgressBar();
void swarpStartResampling();
void swarpStartCoaddition();
void swarpStartSwarpfilter();
void swarpStartUpdate();
void showScampCheckPlots();
void scienceDataDirUpdated(QString allDir);
void clearMemoryView();
void populateMemoryView();
void stopFileProgressTimer();
void addBackupDirToMemoryviewer(QString scienceDir);
void loadAbsZP(QString coaddImagePath, float maxVal);
void updateMemoryProgressBar(long splitterMemory);
void forceFinish();
void refreshMemoryViewer();
public slots:
void activationWarningReceived(QString imagestatus, QString drivestatus);
void updateAll();
// void updateSingle();
void loadPreferences();
void updateMemoryPreference(bool isRAMminimized);
void updateIntermediateDataPreference(QString intermediateDataPreference);
void criticalReceived();
void warningReceived();
void messageAvailableReceived(QString message, QString type);
void appendOKReceived();
void showMessageBoxReceived(QString trigger, QString part1, QString part2);
void updateVerbosity(int verbosityLevel);
// void progressUpdateReceived(float progress);
void dataTreeEditedReceived();
void newProjectLoadedReceived();
void coaddResample();
void coaddSwarpfilter();
void coaddCoaddition();
void coaddUpdate();
void rereadScienceDataDirReceived();
void setMemoryLockReceived(bool locked);
void setWCSLockReceived(bool locked);
void absZeroPointCloseReceived();
void resetErrorStatusReceived(QString dirName);
};
#endif // CONTROLLER_H
| 22,790
|
C++
|
.h
| 471
| 42.881104
| 155
| 0.730664
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,559
|
data.h
|
schirmermischa_THELI/src/processingInternal/data.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
// The 'data' class keeps the references to all FITS images
// encountered in a single directory.
// It triggers a 'read-from-disk' when an image is required for some task.
// It dumps images to disk if memory runs low or if the user requests it.
// It defines the various processing functions that can operate on the data.
// The processing functions read and update the successProcessing flag for each chip
// (similar to the cfitsio status flag)
#ifndef DATA_H
#define DATA_H
#include "mask.h"
#include "../myimage/myimage.h"
#include "../instrumentdata.h"
#include "../processingStatus/processingStatus.h"
#include <omp.h>
#include <QObject>
#include <QMap>
#include <QDir>
#include <QString>
#include <QVector>
#include <QLineEdit>
class Data : public QObject
{
Q_OBJECT
public:
explicit Data(const instrumentDataType *instrumentData, Mask *detectorMask, QString maindirname,
QString subdirname, int *verbose);
~Data();
struct ImageInfo {
QStringList fullName;
QStringList baseName;
QStringList filter;
QList<int> chip;
QList<int> naxis1;
QList<int> naxis2;
QList<double> mjdobs;
};
ImageInfo imageInfo;
Mask *mask;
ProcessingStatus *processingStatus = nullptr;
const instrumentDataType *instData;
bool successProcessing = true;
QDir dir;
QString dirName = "";
QString status = "";
QString statusAfterProcessing = "";
QString mainDirName = "";
QString subDirName = "";
QString dataType = "";
QMap<QString,int> mapName;
QMap<int,int> mapNaxis1;
QMap<int,int> mapNaxis2;
bool userYield = false;
bool userStop = false;
bool userKill = false;
double rad = 3.1415926535 / 180.;
omp_lock_t progressLock;
float *progress;
long numActiveImages = 0;
float progressStepSize = 0.;
float progressCombinedStepSize = 0.;
// Pointing characteristics
double RAcenter = -100.;
double DECcenter = -100.;
double searchRadius = -100.;
// Multi-threading; params set externally by 'controller'
int maxCPU = 1; // Overall, maximum number of CPUs to be used
int maxExternalThreads = 1; // Maximum number of threads working on chips; equal or smaller than maxCPU
int maxInternalThreads = 1; // Maximum number of threads working on images; equal or smaller than maxCPU - maxExternalThreads
int maxThreadsIO = 1; // Maximum number of IO threads
long maxRAM = 0; // Max amount of RAM available for processing (MB)
int currentExternalThreads = 0; // The current number of external running threads (over different chips)
int currentInternalThreads = 0; // The current number of internal running threads (over images of the same chips)
bool useGPU = false;
int *verbosity;
bool dataInitialized = false;
bool isTaskRepeated = false;
QVector<bool> staticModelDone;
bool currentlyDebayering = false;
// A 2D list, 1st axis has one entry for each chip.
// The 2nd axis keeps references to all FITS files of that chip (in memory or on disk)
QVector<QList<MyImage*>> myImageList; // A list of all images per chip [chip][image]
QVector<QList<MyImage*>> bayerList; // A list of all debayered images (only needed for memory calculations)
QVector<QList<MyImage*>> exposureList; // A list of all images per exposure [exposure][chip]
// A list of master calibration files, one for each chip (if applicable for this structure)
QVector<MyImage*> combinedImage;
QString pathBackupL1 = "";
QString pathBackupL2 = "";
QString pathBackupL3 = "";
QString statusBackupL1 = "";
QString statusBackupL2 = "";
QString statusBackupL3 = "";
float maskValue = -1e9;
long numImages = 0;
long numMasterCalibs = 0;
bool hasAllMasterCalibs = false;
QVector<int> uniqueChips; // length: numChips
// QString checkGeometry();
bool hasImages();
// bool getHeaders();
void clearImageInfo();
// QStringList collectNamesForChip(int chip);
// QStringList collectNamesForFilter(QString filter);
// void maskInit(Mask &mask, long n, long m);
// QVector<long> getOverscanArea(QString axis, int chip);
// QString getMasterFilename(QString type, int chip);
// Processing functions
void combineImagesCalib(int chip, float (*combineFunction_ptr) (const QVector<float> &, const QVector<bool> &, long), const QString nlow, const QString nhigh,
const QString dirName, const QString subDirName, const QString dataType);
void combineImages(const int chip, const QString nlowString, const QString nhighString, const QString currentImage, const QString mode,
const QString dirName, const QString subDirName, QVector<bool> &dataStaticModelDone);
// void combineImages_newParallel(int chip, MyImage *masterCombined, QList<MyImage *> &backgroundList, QString nlow, QString nhigh, QString currentImage, QString mode, const QString subDirName);
void deleteMyImageList();
// void forceStatus(int chip, QString status);
void loadCombinedImage(int chip);
void populate(QString statusString);
void repopulate(int chip, QList<MyImage *> replacementList);
// void resetDataCurrentToBackup(int chip);
// bool setModeFlag(int chip, QString min, QString max);
void writeCombinedImage(int chip);
// bool writeImages(int chip, QString statusString);
void resetUserAbort();
// Flags that control whether a task is actually executed (or skipped)
// These are set externally by the controller
// bool overscanFlag = false;
// bool biasFlag = false;
// bool darkFlag = false;
// bool flatoffFlag = false;
// bool flatFlag = false;
bool rescaleFlag = false; // Whether the images in this group have to be rescaled to the same mode when combining them (FLAT: yes, BIAS: no)
// Memory functions
// float memoryCurrentFootprint(bool globalweights = false);
// float memoryNeeded(int chip);
// void memoryFreeDataX(int chip, QString dataX);
void memorySetDeletable(int chip, QString dataX, bool deletable);
void getGainNormalization();
bool getPointingCharacteristics();
void initGlobalWeight(int chip, Data *flatData, QString filter, bool sameWeight, QString flatMin, QString flatMax);
void resetGlobalWeight(QString filter);
void thresholdGlobalWeight(int chip, const Data *comparisonData, const QString filter, const QString threshMin, const QString threshMax);
void detectDefects(int chip, Data *flatData, const QString scienceFilter, const bool sameWeight,
const QString defectKernel, const QString defectRowTol, const QString defectColTol, const QString defectClusTol);
void writeGlobalWeights(int chip, QString filter);
bool collectMJD();
// Reset functions for the taskInternal processes
void resetProcessbackground();
void resetObjectMasking();
void populateExposureList();
void getModeCombineImages(int chip);
QVector<double> getKeyFromAllImages(const QString key);
void checkPresenceOfMasterCalibs();
void reportModeCombineImages();
void countUnsavedImages(long &numUnsavedLatest, long &numUnsavedAll);
// bool containsUnsavedImages();
void writeUnsavedImagesToDrive(bool includeBackup);
void broadcastNumberOfFiles();
int identifyClusters(QString toleranceString);
void setSuccess(bool state);
void resetSuccessProcessing();
float releaseMemory(float RAMneededThisThread, float RAMneededAllThreads, float currentTotalmemoryUsed, QString mode = "");
void protectMemory();
void unprotectMemory(int chip);
void releaseAllMemory();
void restoreBackupLevel(QString backupDirName);
void transferBackupInfo();
void restoreFromDirectory(QString backupDirName);
bool restoreFromBackupLevel(QString level, QString &newStatusRAM);
void restoreRAWDATA();
bool checkStatusConsistency();
void emitStatusChanged();
bool hasMatchingPartnerFiles(QString testDirName, QString suffix, bool abort = true);
bool checkTaskRepeatStatus(QString taskBasename);
void resetStaticModel();
void writeBackgroundModel(const int &chip, const QString &mode, const QString &basename, bool &staticImageWritten);
// void getModeCombineImagesBackground(int chip, MyImage *image);
// void writeBackgroundModel_newParallel(int chip, MyImage *combinedBackgroundImage, QString mode, QString basename,
// int threadID, omp_lock_t &backLock, bool &staticImageWritten);
void cleanBackgroundModelStatus();
bool checkForRawData();
void applyMask(int chip, QString filter);
void resetBackupInfo();
void removeCatalogs();
bool doesCoaddContainRaDec(const QString &refRA, const QString &refDEC);
void unprotectMemoryForBackground(int chip);
void checkModeIsPresent();
bool isEmpty();
public slots:
void setMemoryLockReceived(bool locked);
void setWCSLockReceived(bool locked);
void modelUpdateReceiver(QString chipName);
void pushMessageAvailable(QString message, QString type);
void pushWarning();
void pushCritical();
void criticalFromQueryReceived();
// void pushErrorOccurred();
private:
QString thelidir;
QString userdir;
bool workerInit = false;
bool workerThreadInit = false;
float maskVal = -1.e9;
// void incrementCurrentThreads(int ¤tThreads, omp_lock_t &lock);
// void decrementCurrentThreads(int ¤tThreads, omp_lock_t &lock);
// void getFixedHeaderKeys(QString filename, QStringList &badImages);
QVector<float> getNormalizedRescaleFactors(int chip, QVector<long> &goodIndex, QString mode);
// void printCfitsioError(QString funcName, int status);
void doImagesOverlap(const MyImage &imgRef, MyImage &imgTest, const float tolerance);
bool checkForUnassignedImages(int &groupNumber);
void findOverlappingImages(const MyImage *img, float tolerance);
void releaseMemoryCombined(float &RAMfreed, const float RAMneededThisThread);
void releaseMemoryIndividual(const QStringList &datalist, float &RAMfreed, const float RAMneededThisThread);
void removeCurrentFITSfiles();
void releaseMemoryDebayer(float &RAMfreed, const float RAMneededThisThread);
private slots:
signals:
void modelUpdateNeeded(QString chipName);
// Passed through from MyImage:
void messageAvailable(QString message, QString type);
void showMessageBox(QString trigger, QString part1, QString part2);
void appendOK();
void critical();
void warning();
void progressUpdate(float progress);
void addToProgressBar(float differential);
void resetProgressBar();
void setMemoryLock(bool locked);
void setWCSLock(bool locked);
void globalModelUpdateNeeded();
void updateModelHeaderLine();
void statusChanged(QString newStatus);
void errorOccurredInMyImage();
};
#endif // DATA_H
| 11,777
|
C++
|
.h
| 246
| 43.365854
| 197
| 0.736072
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,560
|
mask.h
|
schirmermischa_THELI/src/processingInternal/mask.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MASK_H
#define MASK_H
#include "../instrumentdata.h"
#include <QObject>
// This class is used to create boolean masks for images (one mask per detector).
// Value == false: good pixel (unmasked)
// Value == true: bad pixel (masked)
class Mask : public QObject
{
Q_OBJECT
public:
explicit Mask(const instrumentDataType *instrumentData, QObject *parent = nullptr);
QVector< QVector<bool> > globalMask;
QVector<bool> isChipMasked;
void addImage(int chip, QVector<float> segmentationMap, bool invert);
void invert();
void reset();
void initMasks();
const instrumentDataType *instData;
private:
// See polygon.h for further functionality
// void addRegionFiles(int chip, QString regionFile);
// void addRectangle(int chip, QVector<long> rect, bool invert);
// void addCircle(int chip, float x, float y, float r, QString senseMode);
// void addPolygon(int chip, QVector<float> &vertx, QVector<float> &verty, QString senseMode);
// void polygon2vertices(QString polystring, QVector<float> &vertx, QVector<float> &verty);
// void region2circle(QString circlestring, float &x, float &y, float &r);
signals:
public slots:
};
#endif // MASK_H
| 1,889
|
C++
|
.h
| 45
| 39.688889
| 97
| 0.757923
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,561
|
photinst.h
|
schirmermischa_THELI/src/processingInternal/photinst.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef PHOTINST_H
#define PHOTINST_H
#include <QObject>
#include <QVector>
#include <QMap>
class PhotInst : public QObject
{
Q_OBJECT
public:
explicit PhotInst(QObject *parent = nullptr);
// Scamp photometric instruments
QVector<double> fluxScale;
QVector<double> expTime;
QVector<double> RZP;
QStringList baseName;
QMap<long,long> indexMap;
void getRZP();
signals:
private:
long numExp = 0;
public slots:
};
#endif // PHOTINST_H
| 1,157
|
C++
|
.h
| 37
| 28.837838
| 75
| 0.778681
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,563
|
imstatsreadme.h
|
schirmermischa_THELI/src/readmes/imstatsreadme.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef IMSTATSREADME_H
#define IMSTATSREADME_H
#include <QDialog>
namespace Ui {
class ImstatsReadme;
}
class ImstatsReadme : public QDialog
{
Q_OBJECT
public:
explicit ImstatsReadme(QWidget *parent = nullptr);
~ImstatsReadme();
private slots:
private:
Ui::ImstatsReadme *ui;
};
#endif // IMSTATSREADME_H
| 1,007
|
C++
|
.h
| 31
| 30.580645
| 75
| 0.798755
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,564
|
multidirreadme.h
|
schirmermischa_THELI/src/readmes/multidirreadme.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MULTIDIRREADME_H
#define MULTIDIRREADME_H
#include <QDialog>
namespace Ui {
class MultidirReadme;
}
class MultidirReadme : public QDialog
{
Q_OBJECT
public:
explicit MultidirReadme(QWidget *parent = nullptr);
~MultidirReadme();
private:
Ui::MultidirReadme *ui;
};
#endif // MULTIDIRREADME_H
| 999
|
C++
|
.h
| 30
| 31.4
| 75
| 0.799582
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,565
|
acknowledging.h
|
schirmermischa_THELI/src/readmes/acknowledging.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef ACKNOWLEDGING_H
#define ACKNOWLEDGING_H
#include <QDialog>
namespace Ui {
class Acknowledging;
}
class Acknowledging : public QDialog
{
Q_OBJECT
public:
explicit Acknowledging(QWidget *parent = 0);
~Acknowledging();
private:
Ui::Acknowledging *ui;
};
#endif // ACKNOWLEDGING_H
| 985
|
C++
|
.h
| 30
| 30.933333
| 75
| 0.79661
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,567
|
scampreadme.h
|
schirmermischa_THELI/src/readmes/scampreadme.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SCAMPREADME_H
#define SCAMPREADME_H
#include <QDialog>
namespace Ui {
class ScampReadme;
}
class ScampReadme : public QDialog
{
Q_OBJECT
public:
explicit ScampReadme(QWidget *parent = nullptr);
~ScampReadme();
private slots:
private:
Ui::ScampReadme *ui;
};
#endif // SCAMPREADME_H
| 991
|
C++
|
.h
| 31
| 30.064516
| 75
| 0.795359
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,568
|
swarpreadme.h
|
schirmermischa_THELI/src/readmes/swarpreadme.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SWARPREADME_H
#define SWARPREADME_H
#include <QDialog>
namespace Ui {
class SwarpReadme;
}
class SwarpReadme : public QDialog
{
Q_OBJECT
public:
explicit SwarpReadme(long openfiles, long maxopenfiles, QWidget *parent = 0);
~SwarpReadme();
private:
Ui::SwarpReadme *ui;
long openFiles = 0;
long maxOpenFiles = 0;
};
#endif // SWARPREADME_H
| 1,056
|
C++
|
.h
| 32
| 30.875
| 81
| 0.786561
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,569
|
datamodel.h
|
schirmermischa_THELI/src/datamodel/datamodel.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef DATAMODEL_H
#define DATAMODEL_H
#include "../processingInternal/data.h"
#include "../myimage/myimage.h"
#include <QAbstractTableModel>
#include <QColor>
#include <QList>
class Data;
class DataModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit DataModel(Data *someData, QObject *parent = nullptr);
explicit DataModel(Data *someData, QString weight, QObject *parent = nullptr);
explicit DataModel(QObject *parent = nullptr);
// Header:
Q_INVOKABLE QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Data *myData;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QList<MyImage*> imageList;
QList<MyImage*> exposureList;
QString modelType = "science"; // can be "calib", "weight", and "globalweight";
// Add and remove data:
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
void updateImageList();
void updateheaderLineExternal();
private slots:
void modelUpdateReceiver(QString chipName);
void updateHeaderLine(long row);
void updateHeaderLineGlobal();
public slots:
void beginResetModelReceived();
void endResetModelReceived();
private:
int numImages = 0;
QColor orange = QColor("#f39c12");
QColor blue = QColor("#3498d8");
QColor green = QColor("#16a085");
QColor red = QColor("#e74c3c");
QColor turquois = QColor("#49ebc5");
QColor grey = QColor("#dddddd");
QColor white = QColor("#ffffff");
QColor getColorDrive(bool flag);
QColor getColorRAM(bool flag);
QColor getColorState(MyImage::active_type state);
QColor getColorImage(MyImage::active_type state);
QString getIndicator(bool flag);
bool setData(const QModelIndex &index, const QVariant &value, int role);
Qt::ItemFlags flags(const QModelIndex &index) const;
signals:
void activationWarning(QString imagestatus, QString drivestatus);
void refreshMemoryViewer();
void activationChanged();
// void writeImageToDisk(MyImage *myImage) const;
};
#endif // DATAMODEL_H
| 3,298
|
C++
|
.h
| 76
| 39.75
| 121
| 0.752577
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,570
|
worker.h
|
schirmermischa_THELI/src/threading/worker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef WORKER_H
#define WORKER_H
#include <QAbstractEventDispatcher>
#include <QObject>
#include <QThread>
#include <QDebug>
class Worker : public QObject
{
Q_OBJECT
public:
explicit Worker(QObject *parent = 0);
signals:
void started();
void finished();
void messageAvailable(QString message, QString type);
public slots:
void pause();
void resume();
void cancel();
protected:
enum State { IDLE, RUNNING, PAUSED };
State state = IDLE;
bool isCancelled();
};
#endif // WORKER_H
| 1,209
|
C++
|
.h
| 39
| 28.512821
| 75
| 0.768166
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,571
|
anetworker.h
|
schirmermischa_THELI/src/threading/anetworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef ANETWORKER_H
#define ANETWORKER_H
#include "worker.h"
#include <QObject>
#include <QProcess>
#include <QStringList>
class AnetWorker : public Worker
{
Q_OBJECT
public:
explicit AnetWorker(QString command, QString dir, QObject *parent = nullptr);
QString anetCommand;
QString anetDirName;
QProcess *extProcess = nullptr;
QStringList failedImages = QStringList();
void abort(); // Currently not used anywhere
public slots:
void runAnet();
private slots:
void processExternalStdout();
void processExternalStderr();
signals:
void errorFound();
void didNotSolve();
void messageAvailable(QString message, QString type);
};
#endif // ANETWORKER_H
| 1,390
|
C++
|
.h
| 41
| 31.243902
| 81
| 0.780195
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,572
|
memoryworker.h
|
schirmermischa_THELI/src/threading/memoryworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MEMORYWORKER_H
#define MEMORYWORKER_H
#include "worker.h"
#include "../processingInternal/data.h"
#include "../dockwidgets/memoryviewer.h"
class MemoryViewer;
class MemoryWorker : public Worker
{
Q_OBJECT
public:
explicit MemoryWorker(MemoryViewer *memViewer, QObject *parent = 0);
explicit MemoryWorker(Data *datadir, QObject *parent = 0);
MyImage *myImage = nullptr;
QString path = "";
Data *data = nullptr;
public slots:
void MemoryViewerDumpImagesToDrive();
void DataDumpImagesToDrive();
void dumpImageToDrive();
// void processActiveStatusChanged();
private:
MemoryViewer *memoryViewer = nullptr;
// Data *data;
omp_lock_t progressLock;
float progress = 0.;
float progressStepSize = 0.;
void incrementProgress();
signals:
void progressUpdate(float progress);
void resetProgressBar();
};
#endif // MEMORYWORKER_H
| 1,585
|
C++
|
.h
| 46
| 31.695652
| 75
| 0.769382
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,573
|
swarpworker.h
|
schirmermischa_THELI/src/threading/swarpworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SWARPWORKER_H
#define SWARPWORKER_H
#include "worker.h"
#include <QObject>
#include <QProcess>
class SwarpWorker : public Worker
{
Q_OBJECT
public:
explicit SwarpWorker(QString command, QString dir, QString type, QObject *parent = nullptr);
QString swarpCommand;
QString coaddDirName;
QString swarpType;
int threadID = 0;
QProcess *extProcess = nullptr;
void abort();
public slots:
void runSwarp();
signals:
void finishedPreparation();
void errorFound();
void finishedResampling(int threadID);
void finishedCoaddition();
void messageAvailable(QString message, QString type);
private slots:
void processExternalStderr();
};
#endif // SWARPWORKER_H
| 1,402
|
C++
|
.h
| 42
| 30.619048
| 96
| 0.779346
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,574
|
mainguiworker.h
|
schirmermischa_THELI/src/threading/mainguiworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MAINGUIWORKER_H
#define MAINGUIWORKER_H
#include "worker.h"
#include "../processingInternal/controller.h"
#include <QObject>
class MainGUIWorker : public Worker
{
Q_OBJECT
public:
explicit MainGUIWorker(Controller *mycontroller, QStringList mycommands, QObject *parent = nullptr);
QStringList commands;
Controller *controller;
bool yield = false;
public slots:
void runTask();
private slots:
signals:
void updateStatus(QString taskBasename, bool success);
};
#endif // MAINGUIWORKER_H
| 1,209
|
C++
|
.h
| 34
| 33.294118
| 104
| 0.796552
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,575
|
scampworker.h
|
schirmermischa_THELI/src/threading/scampworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SCAMPWORKER_H
#define SCAMPWORKER_H
#include "worker.h"
#include <QObject>
#include <QProcess>
class ScampWorker : public Worker
{
Q_OBJECT
public:
explicit ScampWorker(QString command, QString dir, QString shortname, QObject *parent = nullptr);
QString scampCommand;
QString scampDirName;
QString shortName;
QProcess *extProcess = nullptr;
void abort();
public slots:
void runScamp();
private slots:
// void processExternalStdout();
void processExternalStderr();
signals:
void errorFound();
void fieldMatched();
void finishedScamp();
void messageAvailable(QString message, QString type);
};
#endif // SCAMPWORKER_H
| 1,368
|
C++
|
.h
| 41
| 30.707317
| 101
| 0.779558
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,576
|
sourceextractorworker.h
|
schirmermischa_THELI/src/threading/sourceextractorworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef SOURCEEXTRACTORWORKER_H
#define SOURCEEXTRACTORWORKER_H
#include "worker.h"
#include <QObject>
#include <QProcess>
class SourceExtractorWorker : public Worker
{
Q_OBJECT
public:
explicit SourceExtractorWorker(QString command, QString dir, QObject *parent = nullptr);
QString sourceExtractorCommand;
QString sourceExtractorDirName;
QProcess *extProcess = nullptr;
void abort(); // Currently not used anywhere
public slots:
void runSourceExtractor();
private slots:
void processExternalStdout();
void processExternalStderr();
signals:
void errorFound();
void messageAvailable(QString message, QString type);
};
#endif // SOURCEEXTRACTOR_H
| 1,379
|
C++
|
.h
| 38
| 33.710526
| 92
| 0.796226
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,577
|
abszpworker.h
|
schirmermischa_THELI/src/threading/abszpworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef ABSZPWORKER_H
#define ABSZPWORKER_H
#include "../abszp/abszeropoint.h"
#include "worker.h"
#include <QObject>
class AbsZeroPoint;
class AbszpWorker : public Worker
{
Q_OBJECT
public:
explicit AbszpWorker(AbsZeroPoint *abszeropoint, QObject *parent = nullptr);
QString abszpCommand;
QString abszpDirName;
AbsZeroPoint *absZeroPoint;
bool yield = false;
public slots:
void runTask();
private slots:
void processExternalStdout();
void processExternalStderr();
signals:
};
#endif // ABSZPWORKER_H
| 1,227
|
C++
|
.h
| 37
| 30.72973
| 80
| 0.791134
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,578
|
colorpictureworker.h
|
schirmermischa_THELI/src/threading/colorpictureworker.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef COLORPICTUREWORKER_H
#define COLORPICTUREWORKER_H
#include "../colorpicture/colorpicture.h"
#include "worker.h"
#include <QObject>
// Forward declaration, because 'include colorpciture.h' includes this worker
class ColorPicture;
class ColorPictureWorker : public Worker
{
Q_OBJECT
public:
explicit ColorPictureWorker(ColorPicture *colorpicture, QString workmode, QObject *parent = nullptr);
ColorPicture *colorPicture;
QString workMode;
bool yield = false;
public slots:
void runTask();
signals:
void tasknameReturned(QString workmode);
};
#endif // COLORPICTUREWORKER_H
| 1,295
|
C++
|
.h
| 35
| 34.771429
| 105
| 0.801606
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,579
|
colorpicture.h
|
schirmermischa_THELI/src/colorpicture/colorpicture.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef COLORPICTURE_H
#define COLORPICTURE_H
#include "../threading/colorpictureworker.h"
#include "../iview/iview.h"
#include "../query/query.h"
#include "refcatdata.h"
#include <QMainWindow>
#include <QStringListModel>
#include <QComboBox>
#include <QString>
#include <QButtonGroup>
#include <QTableView>
class ColorPictureWorker;
namespace Ui {
class ColorPicture;
}
class ColorPicture : public QMainWindow
{
Q_OBJECT
public:
explicit ColorPicture(QString main = "", QWidget *parent = nullptr);
~ColorPicture();
bool iViewOpen = false;
int verbosity = 0;
int maxCPU = 1;
void taskInternalColorCalib();
void taskInternalCropCoadds();
void taskInternalFits2Tiff();
void taskInternalBBNBratio();
void taskInternalBBNBcombine();
signals:
void colorFactorChanged(float redFactor, float blueFactor);
void messageAvailable(QString message, QString type);
void progressUpdate(float progress);
void resetProgressBar();
void finished();
void showMessageBox(QString trigger, QString part1, QString part2);
void updateNrefStars(QString name, long number);
void addCombinedImage(MyImage *myImage);
public slots:
void taskFinished(QString taskname);
void updateVerbosity(int verbosityLevel);
private slots:
void addCombinedImageReceived(MyImage *combinedImage);
void criticalReceived();
void displayMessage(QString message, QString type);
void measureStatistics(long x, long y);
void on_abortPushButton_clicked();
void on_actionClose_triggered();
void on_createTiffPushButton_clicked();
void on_redComboBox_currentIndexChanged(int index);
void on_greenComboBox_currentIndexChanged(int index);
void on_blueComboBox_currentIndexChanged(int index);
void on_narrowbandComboBox_currentTextChanged(const QString &arg1);
void on_broadbandComboBox_currentTextChanged(const QString &arg1);
void on_getRatioPushButton_clicked();
void on_previewCalibPushButton_clicked();
void on_calibratePushButton_clicked();
void on_selectDirPushButton_clicked();
void on_getCoaddsPushButton_clicked();
void on_clearCoaddsPushButton_clicked();
void on_BBNBcombinePushButton_clicked();
void sendColorFactors();
void setWCSLockReceived(bool locked);
void updateCalibFactors();
void updateColorFactorsExternal(QString redFactor, QString blueFactor);
void updateImageListView();
void updateFilterRatio();
void updateIviewStatus();
void updateTiff();
void updateNrefStarsReceived(QString name, long number);
void validate();
private:
QString mainDir;
Ui::ColorPicture *ui;
QString thelidir;
QString userdir;
QStringListModel *coaddImageModel;
QStringListModel *coaddDirModel;
IView *iView;
QButtonGroup *resultButtonGroup = new QButtonGroup(this);
QPalette buttonPalette;
bool statisticsRetrieved = false;
QThread *workerThread;
ColorPictureWorker *colorpictureWorker;
omp_lock_t wcsLock;
float bbnbFluxRatio = 1.0;
float bbnbFluxRatioError = 0.0;
QList<MyImage*> coaddList; // all coadds, including weights
QList<MyImage*> croppedList; // only the cropped coadded images, without the weights
QStringList refCatList = {"SDSS", "ATLAS-REFCAT2", "SKYMAPPER", "PANSTARRS"};
Query *SDSSquery = new Query(&verbosity);
Query *ATLASquery = new Query(&verbosity);
Query *PANSTARRSquery = new Query(&verbosity);
Query *SKYMAPPERquery = new Query(&verbosity);
RefCatData *SDSS = new RefCatData("SDSS", this);
RefCatData *ATLAS = new RefCatData("ATLAS-REFCAT2", this);
RefCatData *SKYMAPPER = new RefCatData("SKYMAPPER", this);
RefCatData *PANSTARRS = new RefCatData("PANSTARRS", this);
typedef struct {
QString catname;
QString nstars;
QString bfac;
QString gfac;
QString rfac;
QString bfacerr;
QString gfacerr;
QString rfacerr;
} _photcatresult_;
_photcatresult_ photcatresult[5];
void addDirectories();
void checkCalibrationFactor(QLineEdit *le);
void findRecursion(const QString &path, QStringList *result);
void readFilterRatioResults(QString filename);
void resetResultButtonGroup(QString resetLabels = "");
void refreshComboBoxes();
void showDone(QPushButton *pushButton, QString text);
void toggleCalibResult();
void loadPreferences();
void filterSolarTypeStars(QList<Query *> queryList);
void colorCalibSegmentImages();
void colorCalibRetrieveCatalogs(QList<Query *> queryList);
void colorCalibMatchReferenceCatalog(const QVector<QVector<double> > &matchedRGB, RefCatData *REFCAT, float tolerance);
void colorCalibMatchCatalogs();
MyImage *identifyCroppedMyImage(QString name);
QVector<QVector<double> > getObjectData(MyImage *myImage);
void updateBBNBcombine();
void writeG2refcat(const QString refcatName, const QVector<QVector<double> > matchedREFCAT);
void writeRGBTIFF(QVector<float> &R, QVector<float> &G, QVector<float> &B, long n, long m, float min, float max, QString path);
void filterReferenceCatalog(RefCatData *REFCAT, MyImage *channelImage);
};
#endif // COLORPICTURE_H
| 5,897
|
C++
|
.h
| 146
| 36.130137
| 131
| 0.759224
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,580
|
refcatdata.h
|
schirmermischa_THELI/src/colorpicture/refcatdata.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef REFCATDATA_H
#define REFCATDATA_H
#include <QObject>
#include <QVector>
class RefCatData : public QObject
{
Q_OBJECT
public:
explicit RefCatData(QString refcatname, QObject *parent = nullptr);
QVector<double> ra;
QVector<double> de;
QVector<float> mag1;
QVector<float> mag2;
QVector<float> mag3;
QVector<float> mag4;
QVector<float> mag5;
long numRefSources = 0;
long numG2Sources = 0;
QString name = "";
QString resultString = "";
void clear();
signals:
public slots:
};
#endif // REFCATDATA_H
| 1,244
|
C++
|
.h
| 39
| 29.128205
| 75
| 0.763423
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,581
|
myimage.h
|
schirmermischa_THELI/src/myimage/myimage.h
|
/*
Copyright (C) 2019 Mischa Schirmer
This file is part of THELI.
THELI 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 3 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.
You should have received a copy of the GNU General Public License
along with this program in the LICENSE file.
If not, see https://www.gnu.org/licenses/ .
*/
#ifndef MYIMAGE_H
#define MYIMAGE_H
#include "../tools/detectedobject.h"
#include "../threading/sourceextractorworker.h"
#include "../threading/anetworker.h"
#include "../processingStatus/processingStatus.h"
#include "../instrumentdata.h"
#include "fitsio2.h"
#include <gsl/gsl_vector.h>
#include <omp.h>
#include <wcs.h>
#include <QObject>
// This class keeps track of an individual image, its memory/disk state,
// processing status, previous processing states, file name, FITS file handles,
// associated weight and mask images, geometry, filter, exposure time, seeing
// and RZP
class MyImage : public QObject
{
Q_OBJECT
private:
void stayWithinBounds(QVector<long> &vertices);
void stayWithinBounds(long &coord, QString axis);
float polynomialSum(float x, QVector<float> coefficients);
// ================= BACKGROUND MODELING ===========================
long nGridPoints = 0; // Number of grid points
int gridStep = 0; // Linear distance between grid points
int filterSize = 0; // spatial scale on which the image should be filtered
int subSample = 1; // GSL The factor by which the grid should be subSampled; at least twice the kernel width
int n_grid = 0; // number of grid points along naxis1
int m_grid = 0; // number of grid points along naxis2
int pad_l = 0; // number of pad pixels left edge; same as padWidth w
int pad_b = 0; // number of pad pixels bottom edge; same as padWidth w
int pad_r = 0; // number of pad pixels right edge; same as padWidth w unless +1 to make even dimension
int pad_t = 0; // number of pad pixels top edge; same as padWidth w unless +1 to make even dimension
long n_pad = 0; // NAXIS1 of the padded image
long m_pad = 0; // NAXIS2 of the padded image
QString splineMode = "smooth"; // "smooth" or "interpolate"
QString padMode = "normal"; // Whether the image is padded "normal" or "dyadic"
QVector<float> backStatsGrid; // the statistics for the grid (background value for each grid point)
QVector<float> rmsStatsGrid; // the statistics for the grid (rms value for each grid point)
QVector<QVector<long>> grid; // the grid on which we calculate statistics
QVector<long> padDims; // contains left, bottom, right, top pad dimensions, and then overall n_pad and m_pad
int numExt = 1; // Number of etensions in a FITS file
void planGrid();
void getGridStatistics();
void filterGridStatistics();
void fitBackgroundGSL();
void getPadDimensions();
void padImage();
void padCorner(int width, QString corner, long ipadmin, long ipadmax, long jpadmin, long jpadmax);
void padEdgeLR(int width, QString edge, long ipadmin, long ipadmax, long jpadmin, long jpadmax);
void padEdgeBT(int width, QString edge, long ipadmin, long ipadmax, long jpadmin, long jpadmax);
int padCorr(int i, int w, int max);
void replaceBlankGridStatistics();
void clearBackgroundMemory();
// void backgroundModel(int filtersize, QString splinemode); public function
// =================================================================
// ================== Image segmentation ===========================
void thresholdImage();
bool insideImage(QPoint p);
void floodFill(const QPoint startPoint, QList<long> &objectPixelIndices, long &objID,
QVector<long> &dataSegmentation, const long DMIN);
QVector<float> directConvolve(const QVector<float> &data);
void writeObjectMask(QString fileName);
// =================================================================
QVector<long> locateSkyNode(const double alpha, const double delta, const double radius);
void printCfitsioError(QString funcName, int status);
void median2D(const QVector<float> &data_in, QVector<float> &data_out, int filtersize);
void pushDownToL3();
void pushDownToL2();
void pushDownToL1(QString backupDir);
void pullUpFromL1();
void pullUpFromL2();
void pullUpFromL3();
void wipeL1();
void wipeL2();
void wipeL3();
void readImageBackupL1();
void replaceCardInFullHeaderString(QString keyname, double value);
void readHeader(fitsfile **fptr, int *status);
void extractKeywordDouble(QString card, QString key, double &value);
void extractKeywordFloat(QString card, QString key, float &value);
void extractKeywordLong(QString card, QString key, long &value);
void extractKeywordInt(QString card, QString key, int &value);
void extractKeywordString(QString card, QString key, QString &value);
void initTHELIheader(int *status);
void checkTHELIheader(int *status);
void propagateHeader(fitsfile *fptr, QVector<QString> header);
bool write(QString fileName, const QVector<float> &data,
const float exptime, const QString filter, const QVector<QString> header);
void writeConstImage(QString fileName, const float constValue, const QVector<QString> header);
bool writeDebayer(QString fileName, const float exptime, const QString filter,
const QVector<QString> header);
void writeSegmentation(QString fileName);
void readDataWeight(fitsfile **fptr, int *status);
bool doesHeaderContain(QString keyword);
public:
explicit MyImage(QString pathname, QString filename, QString statusString, int chipnumber,
const QVector<bool> &mask, int *verbose, QObject *parent = nullptr);
explicit MyImage(QString fullPathName, const QVector<bool> &mask, int *verbose, QObject *parent = nullptr);
explicit MyImage(QObject *parent = nullptr);
// A series of flags telling the status of a MyImage
enum active_type {
ACTIVE, // The image is active (will be used in coaddition and all processing steps)
INACTIVE, // Image is inactive (for whatever reason, parked in inactive/)
BADSTATS, // Image was flagged as having bad seeing/ throughput etc (parked in inactive/badStatistics/)
BADBACK, // Image was flagged because the background could not be modeled (parked in inactive/badBackground/)
NOASTROM, // Image was flagged because astrometric information could not be found
LOWDETECTION, // Image was flagged because it has insufficiently many source detections for astrometry
DELETED, // Image was manually deleted by the user (cannot be found anymore on disk)
};
active_type activeState = ACTIVE;
active_type oldState = activeState; // needed by memoryViewer;
~MyImage();
struct wcsprm *wcs;
bool wcsInit = false;
char *fullheader = nullptr;
ProcessingStatus *processingStatus;
int maxCPU = 1; // In case we work on a single image, e.g. for abszeropoint, we can speed up calculations
QList<QVector<double>> skyPolyfitNodes;
QVector<float> apertures;
QThread *workerThread = nullptr;
SourceExtractorWorker *sourceExtractorWorker = nullptr;
AnetWorker *anetWorker = nullptr;
// bool lockForInitWCSneeded = true;
// Defining data
QString path = "";
QString pathBackupL1 = "";
QString pathBackupL2 = "";
QString pathBackupL3 = "";
QString pathExtension = "";
QString weightPath = path+"../WEIGHTS/";
QString weightName = "";
QString name = "";
QString baseName = ""; // "image_1AB" in case of image_1AB.fits
QString rootName = ""; // "image" in case of image_1AB.fits
QString chipName = ""; // "image_1" in case of image_1AB.fits
QString filter = "";
QString statusBackupL1 = "";
QString statusBackupL2 = "";
QString statusBackupL3 = "";
QString baseNameBackupL1 = "";
QString baseNameBackupL2 = "";
QString baseNameBackupL3 = "";
bool metadataTransferred = false;
int groupNumber = -1; // The association of images this image belongs to (an overlapping group on sky)
bool minimizeMemoryUsage = false;
bool headerInfoProvided = false;
bool processingFinished = false; // Reset to false every time a process starts; If finised, external jobs use this flag to force a
// dump to drive to be able to release memory
bool isTaskRepeated = false;
bool fullheaderAllocated = false;
int numHeaderKeys = 0;
QString fullHeaderString = "";
bool hasTHELIheader = false;
bool addGainNormalization = false;
QList<DetectedObject*> objectList;
QVector<QString> header;
QString sourceExtractorCommand;
QString anetCommand;
bool anetSolved = true;
// Static image characteristics
// Once running, the chipNumber always starts with 1,
// contrary to the 'chip' variable which starts at 0
int chipNumber = 0;
long naxis1 = 0;
long naxis2 = 0;
float matchingTolerance = 2./3600.; // default matching tolerance = 2 arcsec;
long dim = 0;
// Status flags
bool imageInMemory = false;
bool backupL1InMemory = false;
bool backupL2InMemory = false;
bool backupL3InMemory = false;
bool backupL1OnDrive = false;
bool backupL2OnDrive = false;
bool backupL3OnDrive = false;
bool imageOnDrive = false;
bool weightInMemory = false;
bool weightOnDrive = false;
bool headerRead = false;
bool modeDetermined = false;
bool hasMJDread = false;
bool validFile = true; // Is the file valid
bool validMode = true; // Is the statistical mode within accepted range
bool validBackground = true; // Is the image accepted to contribute to a background model (no if e.g. bright star)
bool validDetector = true; // Is the detector alive
// Data characteristics
QString dateobs = "";
QString bunit = "";
double crval1 = 0.;
double crval2 = 0.;
double mjdobs = 0;
float geolon = 0.0; // Earth coordinates
float geolat = 0.; // Earth coordinates
float fwhm = -1.0; // FWHM estimate based on GAIA point sources
float fwhm_est = -1.0; // median FWHM of all detected sources in an image
float RZP = 0; // SCAMP output
float exptime = 0;
float airmass = 1.0;
float ellipticity = -1.0; // estimate based on GAIA point sources
float ellipticity_est = -1.0; // median ellipticity based on all detected sources
float FLXSCALE = 0.; // SCAMP output
float skyValue = -1e9; // previously set to zero
float skySigma = -1;
float gain = 1.0; // Read from raw fits header; fallback: taken from instrument config file
float plateScale = 0.; // in arcsec
float radius = 0.; // image radius in degrees
float gainNormalization = 1.0;
int bitpix = -32;
// Processing stages
QVector<float> dataCurrent; // Contains the current state of processing. Processing is done on it, will then be pushed down into first backup level
QVector<float> dataBackupL1; // First backup level
QVector<float> dataBackupL2; // Second backup level
QVector<float> dataBackupL3; // Third backup level
QVector<float> dataMeasure; // temporary (for object detection)
const QVector<bool> &globalMask; // Global mask (e.g. vignetting, permanently bad pixels; same for all images)
QVector<bool> objectMask; // Object mask (used for background modeling and sky subtraction)
bool backgroundPushedDown = false; // Used to detect whether a backup copy was made already during twopass background correction
bool globalMaskAvailable = true; // Unless we load an external image, e.g. for absolute zeropoint
bool weightModified = false; // Identifies if the individual weight is different from the global weight
// Memory stages (to decide what can be deleted and what not)
bool dataWeight_deletable = false;
bool dataCurrent_deletable = false;
bool dataBackupL1_deletable = false;
bool dataBackupL2_deletable = true; // should always be true (apart from when we populate it)
bool dataBackupL3_deletable = true; // should always be true (apart from when we populate it)
bool dataBackground_deletable = false;
bool successProcessing = true; // A flag that is updated everytime we do something to the image
int backgroundBlock = 0;
QString procInfo = "";
float meanExposureBackground = 0.;
// Flags to decide whether the image is used in a current background calculation or not
bool useForBackground = false; // Overall flag
bool useForBackgroundSequence = false; // Whether the image can be used from a 'LIRIS-style' sequence splitting
bool useForBackgroundWindowed = false; // Whether the image can be used because it falls within the current group, statically or dynamically
bool useForBackgroundStars = false; // Whether the image can be used because it does not contain bright sources
bool hasBrightStars = false;
int *verbosity;
omp_lock_t backgroundLock;
omp_lock_t objectLock;
// The image corners in RA/DEC (e.g. to check whether a bright star is inside or outside)
double alpha_ul = 0.;
double alpha_ur = 0.;
double alpha_ll = 0.;
double alpha_lr = 0.;
double delta_ul = 0.;
double delta_ur = 0.;
double delta_ll = 0.;
double delta_lr = 0.;
double alpha_ctr = 0.; // Image center coords
double delta_ctr = 0.;
// Transformations for binned mosaics
double tcd11 = 0.;
double tcd12 = 0.;
double tcd21 = 0.;
double tcd22 = 0.;
double tcrpix1 = 0.;
double tcrpix2 = 0.;
// Associated data
QVector<float> dataWeight;
QVector<float> dataWeightSmooth;
QVector<float> dataTIFF;
// QVector<uint> mask;
float maskValue = 0.;
float saturationValue = 1.e9;
float saturationValueL1 = 1.e9;
float saturationValueL2 = 1.e9;
float saturationValueL3 = 1.e9;
bool allocatedImageFITS = false;
// =============== Astrometric solution ===================
QVector<float> dataXcorr;
// ================= BACKGROUND MODELING ===========================
QVector<float> dataBackground; // The background model
bool backupCopyBackgroundMade = false;
bool hasBrightStarsChecked = false;
// =================================================================
// ================== Image segmentation ===========================
QVector<long> dataSegmentation;
bool backgroundModelDone = false;
bool segmentationDone = false;
bool maskExpansionDone = false;
bool objectMaskDone = false;
bool objectMaskDonePass1 = false;
bool objectMaskDonePass2 = false;
bool leftBackgroundWindow = false; // used to mark the memory for deletion
bool enteredBackgroundWindow = false;
// =================================================================
// QVector<float> retainUnmaskedData(int sampleDensity = 1);
// QVector<float> retainUnmaskedDataThresholded(float minVal, float maxVal, int sampleDensity = 1);
// void subtractPolynomialSkyFit(gsl_vector *c, int order);
void add(float value);
void addExludedRegionToMask(long imin, long imax, long jmin, long jmax);
void appendToScampCatalogInternal(fitsfile *fptr, QString minFWHM_string, QString maxFlag_string, QString maxEll_string, bool empty = false);
void appendToScampCatalogSourceExtractor(fitsfile *fptr);
void applyBackgroundModel(const MyImage *backgroundImage, QString mode, bool rescaleFlag);
void applyMask();
void applyPolygons();
void backgroundModel(int filtersize, QString splinemode);
void backupOrigHeader(int chip);
void buildAnetCommand();
void buildAnetCommand(QString pixscale_maxerr);
void buildSourceExtractorCommand();
void calcMedianSeeingEllipticity();
void calcMedianSeeingEllipticitySex(QString catName = "", int extnum = 0);
void checkBrightStars(const QList<QVector<double> > &brightStarList, float safetyDistance, float plateScale);
void checkCorrectMaskSize(const instrumentDataType *instData);
void checkTaskRepeatStatus(QString taskBasename);
void checkWCSsanity();
void collapseCorrection(QString threshold, QString direction);
QVector<double> collectObjectParameter(QString paramName);
void collectSeeingParameters(QVector<QVector<double> > &outputParams, QVector<double> &outputMag, int goodChip);
bool containsRaDec(QString alphaStr, QString deltaStr);
bool containsRaDec(double alpha, double delta);
void cornersToRaDec();
void cosmicsFilter(QString aggressiveness);
void createSourceExtractorCatalog();
void createSourceExtractorCatalog_old();
void divide(float value);
void divideFlat(const MyImage *flatImage);
void dumpToDriveIfPossible();
void emitModelUpdateNeeded();
void estimateMatchingTolerance();
void evaluateSkyNodes(const QVector<double> alpha, const QVector<double> delta, const QVector<double> radius);
QString extractAnetOutput();
QVector<double> extractCDmatrix();
QVector<float> extractPixelValues(long xmin, long xmax, long ymin, long ymax);
void filterSourceExtractorCatalog(QString minFWHM, QString maxFlag, QString maxEll);
void freeAll();
void freeAncillaryData(QVector<float> &data);
void freeData();
float freeData(QString type);
void freeData(QVector<float> &data);
void freeWeight();
QString getKeyword(QString key);
void getMJD();
void getMeanBackground();
void getMode(bool determineMode);
double getPlateScale();
void illuminationCorrection(int chip, QString thelidir, QString instName, QString filter);
bool informSwarpfilter(long &naxis1, long &naxis2, double &crpix1, double &crpix2, double &sky, double &fluxscale, bool checkFluxScale);
void initFITS(fitsfile **fptr, QString loadFileName, int *status);
void initWCS();
void initWeightfromGlobalWeight(const QList<MyImage *> &gwList);
bool isActive();
void laplaceFilter(QVector<float> &dataFiltered);
void linkWeight(QString globalWeightName, QString linkName);
bool loadData(QString loadFileName = "");
bool loadDataThreadSafe(QString loadFileName = "");
void loadDataSection(long xmin, long xmax, long ymin, long ymax, float *dataSect);
void loadHeader(QString loadFileName = "");
void makeBackgroundBackup();
void makeCutout(long xmin, long xmax, long ymin, long ymax);
void makeDriveBackup(QString backupDirName, QString statusOld);
bool makeL1Current();
bool makeL2Current();
bool makeL3Current();
void makeMemoryBackup();
void makeXcorrData();
void maskBloomingSpike(QString instType, QString range, QString minVal, bool requested, QString bloomMin = "", QString bloomMax = "");
void maskExpand(QString expFactor, bool writeObjectmaskImage = false);
void maskSaturatedPixels(QString tolerance, bool requested);
void mergeObjectWithGlobalMask();
void multiply(float value, QString mode = "");
void normalizeFlat();
void protectMemory();
void pullUp();
void pushDown(QString backupDir);
void readData(fitsfile **fptr, int *status);
void readFILTER(QString loadFileName = "");
void readImage(QString loadFileName);
void readImage(bool determineMode = true);
void readImageThreadSafe(bool determineMode = true);
void readImageBackupL1Launch();
void readWeight();
void releaseAllDetectionMemory();
void releaseBackgroundMemory(QString mode = "");
void releaseBackgroundMemoryBackgroundModel();
void releaseDetectionPixelMemory();
void releaseMemoryForBackground();
void removeSourceCatalogs();
void resetObjectMasking();
void roundEdgeOfWeight(float edge, bool roundEdge);
void runAnetCommand();
bool scanAstromHeader(int chip, QString mode);
void segmentImage(const QString DTstring, const QString DMINstring, const bool convolution, const bool writeSegImage = false);
void setActiveState(active_type state);
void setBackgroundLock(bool locked);
void setDeletable();
void setModeFlag(QString min, QString max);
void setObjectLock(bool locked);
void setupBackgroundData(const bool &isTaskRepeated, const QString &backupDir);
void setupBackgroundData_newParallel(const bool &isTaskRepeated, const QString &backupDir);
void setupCalibDataInMemory(bool createBackup, bool determineMode, bool mustRereadFromDisk);
void setupCoaddMode();
void setupData(bool isTaskRepeated, bool createBackup, bool determineMode, QString backupDir = "");
void setupDataInMemorySimple(bool determineMode);
void showProcInfo();
void sky2xy(const double alpha, const double delta, double &x, double &y);
void sourceExtractorCatToAnet();
void sourceExtractorCatToIview();
void subtract(float value, QString mode = "");
void subtractBackgroundModel();
void subtractBias();
void subtractBias(QVector<float> const &dataCurrent, QString dataType);
void subtractBias(const MyImage *biasImage, QString dataType);
void subtractSkyFit(int order, gsl_vector *c, bool saveSkyModel);
void thresholdWeight(QString imageMin, QString imageMax);
void toTIFF(int bit, float minthresh, float maxthresh, bool zscaleing = false, float grey = 0., float gamma = 1.0);
void transferObjectsToMask();
void unprotectMemory();
void unprotectMemoryForBackground();
void unprotectMemoryWeight();
void updateCRVALCDinHeader();
void updateCRVALCDinHeaderOnDrive();
void updateCRVALCRPIXCDinHeader();
void updateCRVALinHeader();
void updateCRVALinHeaderOnDrive();
void updateHeaderValue(QString keyName, QString keyValue);
void updateHeaderValue(QString keyName, double keyValue, char format = 'f');
void updateHeaderValue(QString keyName, float keyValue, char format = 'f');
void updateHeaderValueInFITS(QString keyName, QString keyValue);
void updateInactivePath();
void updateKeywordInHeader(QString key, QString value);
void updateMode();
void updateProcInfo(QString text);
void updateHeaderSaturation();
void updateZeroOrderOnDrive(QString updateMode);
void writeBackgroundModel();
void writeCatalog(QString minFWHM_string, QString maxFlag_string, QString maxEll_string);
void writeConstSkyImage(float constValue);
void writeImage(QString fileName = "", QString filter = "", float exptime = -1.0, bool addGain = false);
void writeImageTIFF(QString fileName = "", QString filter = "", float exptime = -1.0, bool addGain = false);
void writeImageBackupL1();
void writeImageBackupL2();
void writeImageBackupL3();
void writeImageDebayer(bool addGain = false);
void writeWeight(QString fileName = "");
void writeWeightSmoothed(QString fileName);
void xtalk(int method, float scale, QString direction = "", int nsection = -1);
void xy2sky(const double x, const double y, double &alpha, double &delta);
bool isTooBig();
signals:
void modelUpdateNeeded(QString chipName);
void messageAvailable(QString message, QString type);
void setMemoryLock(bool locked);
void setWCSLock(bool locked);
void critical();
void imageTooBig();
void warning();
void errorOccurred();
void WCSupdated();
public slots:
void messageAvailableReceived(QString message, QString type);
void anetOutputReceived(QString message, QString type);
private slots:
void errorFoundReceived();
void didNotSolveReceived();
};
#endif // MYIMAGE_H
| 24,414
|
C++
|
.h
| 474
| 46.529536
| 154
| 0.70386
|
schirmermischa/THELI
| 35
| 5
| 4
|
GPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,582
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_36_SineWaveMidiSynth/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2020
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_36_sineWaveMidiSynthAudioProcessorEditor::Plugex_36_sineWaveMidiSynthAudioProcessorEditor (Plugex_36_sineWaveMidiSynthAudioProcessor& p,
AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts),
keyboardComponent (p.keyboardState, MidiKeyboardComponent::horizontalKeyboard)
{
setSize (500, 280);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("lightgreen");
title.setText("Plugex - 36 - Sine Wave Midi Synth", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
gainLabel.setText("Gain", NotificationType::dontSendNotification);
gainLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&gainLabel);
gainKnob.setLookAndFeel(&plugexLookAndFeel);
gainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
gainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&gainKnob);
gainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain", gainKnob));
addAndMakeVisible(keyboardComponent);
}
Plugex_36_sineWaveMidiSynthAudioProcessorEditor::~Plugex_36_sineWaveMidiSynthAudioProcessorEditor()
{
}
//==============================================================================
void Plugex_36_sineWaveMidiSynthAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_36_sineWaveMidiSynthAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto gainArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100);
gainLabel.setBounds(gainArea.removeFromTop(20));
gainKnob.setBounds(gainArea);
area.removeFromTop(12);
keyboardComponent.setBounds(area.removeFromBottom(80));
}
| 2,774
|
C++
|
.cpp
| 54
| 45.666667
| 143
| 0.671243
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,584
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_26_Doppler/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_26_dopplerAudioProcessorEditor::Plugex_26_dopplerAudioProcessorEditor (Plugex_26_dopplerAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("purple");
title.setText("Plugex - 26 - Ping-pong Doppler", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Frequency", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
depthLabel.setText("Depth", NotificationType::dontSendNotification);
depthLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&depthLabel);
depthKnob.setLookAndFeel(&plugexLookAndFeel);
depthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
depthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&depthKnob);
depthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "depth", depthKnob));
}
Plugex_26_dopplerAudioProcessorEditor::~Plugex_26_dopplerAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
depthKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_26_dopplerAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_26_dopplerAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto freqArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
auto depthArea = area2.withSizeKeepingCentre(80, 100);
depthLabel.setBounds(depthArea.removeFromTop(20));
depthKnob.setBounds(depthArea);
area.removeFromTop(12);
}
| 3,502
|
C++
|
.cpp
| 69
| 46.536232
| 149
| 0.708664
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,585
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_26_Doppler/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 3) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String depthSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float depthSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(0.01f, 1.0f, 0.001f, 0.5f),
0.05f, freqSliderValueToText, freqSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("depth"), String("Depth"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
25.0f, depthSliderValueToText, depthSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_26_dopplerAudioProcessor::Plugex_26_dopplerAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
depthParameter = parameters.getRawParameterValue("depth");
}
Plugex_26_dopplerAudioProcessor::~Plugex_26_dopplerAudioProcessor()
{
}
//==============================================================================
const String Plugex_26_dopplerAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_26_dopplerAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_26_dopplerAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_26_dopplerAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_26_dopplerAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_26_dopplerAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_26_dopplerAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_26_dopplerAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_26_dopplerAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_26_dopplerAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_26_dopplerAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
lfoPhase = 0.0f;
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
depthSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
depthSmoothed.setCurrentAndTargetValue(*depthParameter);
delayLine.setup(sampleRate / 2.f, currentSampleRate);
lowpassFilter.setup(sampleRate);
lowpassFilter.setType(0);
lowpassFilter.setQ(0.707);
}
void Plugex_26_dopplerAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_26_dopplerAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_26_dopplerAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
depthSmoothed.setTargetValue(*depthParameter);
if (totalNumOutputChannels < 2) {
return;
}
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float currentFreq = freqSmoothed.getNextValue();
float currentDepth = depthSmoothed.getNextValue() * 0.0099f;
float sumValue = 0.0f;
if (totalNumInputChannels == 1) {
sumValue = buffer.getWritePointer(0)[i];
} else {
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer (channel);
sumValue += channelData[i];
}
}
float lfo = jmin(lfoPhase, 1.f - lfoPhase) * 2.f;
float delayTime = (0.5f - jmin(lfo, 1.f - lfo));
float filterFreq = powf(jmin(lfo, 1.f - lfo), 2.f) * 20000.f + 200.f;
auto* channelDataL = buffer.getWritePointer(0);
auto* channelDataR = buffer.getWritePointer(1);
lfoPhase += currentFreq / currentSampleRate;
if (lfoPhase >= 1.0f) {
lfoPhase -= 1.0f;
}
float sampleRead = delayLine.read(delayTime * currentDepth + 0.001f);
delayLine.write(sumValue);
lowpassFilter.setFreq(filterFreq);
float filtered = lowpassFilter.process(sampleRead);
channelDataL[i] = filtered * cosf(lfo * M_PI * 0.5f);
channelDataR[i] = filtered * sinf(lfo * M_PI * 0.5f);
}
}
//==============================================================================
bool Plugex_26_dopplerAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_26_dopplerAudioProcessor::createEditor()
{
return new Plugex_26_dopplerAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_26_dopplerAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_26_dopplerAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_26_dopplerAudioProcessor();
}
| 8,909
|
C++
|
.cpp
| 220
| 34.2
| 109
| 0.641704
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,586
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_00_VisualDesign/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_00_visualDesignAudioProcessorEditor::Plugex_00_visualDesignAudioProcessorEditor (Plugex_00_visualDesignAudioProcessor& p)
: AudioProcessorEditor (&p), processor (p)
{
setSize (400, 600);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("pink");
title.setText("Plugex - common LookAndFeel !", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
label.setText("This is a Label widget !", NotificationType::dontSendNotification);
addAndMakeVisible(&label);
knob.setLookAndFeel(&plugexLookAndFeel);
knob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
knob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
knob.setNumDecimalPlacesToDisplay(3);
addAndMakeVisible(&knob);
hbar.setLookAndFeel(&plugexLookAndFeel);
hbar.setSliderStyle(Slider::LinearBar);
hbar.setNumDecimalPlacesToDisplay(3);
addAndMakeVisible(&hbar);
hslider.setLookAndFeel(&plugexLookAndFeel);
hslider.setSliderStyle(Slider::LinearHorizontal);
hslider.setTextBoxStyle(Slider::TextBoxRight, false, 80, 20);
hslider.setNumDecimalPlacesToDisplay(3);
addAndMakeVisible(&hslider);
vbar.setLookAndFeel(&plugexLookAndFeel);
vbar.setSliderStyle(Slider::LinearBarVertical);
vbar.setNumDecimalPlacesToDisplay(3);
addAndMakeVisible(&vbar);
vslider.setLookAndFeel(&plugexLookAndFeel);
vslider.setSliderStyle(Slider::LinearVertical);
vslider.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
vslider.setNumDecimalPlacesToDisplay(3);
addAndMakeVisible(&vslider);
combo.setLookAndFeel(&plugexLookAndFeel);
combo.addItemList({"Frites", "Sauce", "Fromage"}, 1);
combo.setSelectedId(1);
addAndMakeVisible(&combo);
button1.setLookAndFeel(&plugexLookAndFeel);
button1.setButtonText("Simple button");
addAndMakeVisible(&button1);
button2.setLookAndFeel(&plugexLookAndFeel);
button2.setButtonText("Two-state button");
button2.setClickingTogglesState(true);
addAndMakeVisible(&button2);
toggle.setLookAndFeel(&plugexLookAndFeel);
toggle.setButtonText("Toggle button");
addAndMakeVisible(&toggle);
multiSliderLabel.setText("This is a MultiSlider widget !", NotificationType::dontSendNotification);
addAndMakeVisible(&multiSliderLabel);
multiSlider.addListener(this);
multiSlider.setLookAndFeel(&plugexLookAndFeel);
addAndMakeVisible(&multiSlider);
}
Plugex_00_visualDesignAudioProcessorEditor::~Plugex_00_visualDesignAudioProcessorEditor()
{
}
void Plugex_00_visualDesignAudioProcessorEditor::multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) {
std::cout << "Vector size = " << value.size() << std::endl;
}
//==============================================================================
void Plugex_00_visualDesignAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_00_visualDesignAudioProcessorEditor::resized()
{
int width = getWidth();
auto area = getLocalBounds().reduced(12, 12);
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
label.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
auto area2 = area.removeFromTop(128);
vbar.setBounds(area2.removeFromLeft(48));
area2.removeFromLeft(12);
vslider.setBounds(area2.removeFromLeft(84));
area2.removeFromLeft(12);
knob.setBounds(area2.removeFromTop(84).removeFromLeft(84));
area.removeFromTop(12);
hbar.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
hslider.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
combo.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
button1.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
button2.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
toggle.setBounds(area.removeFromTop(24));
area.removeFromTop(12);
multiSliderLabel.setBounds(area.removeFromTop(20));
multiSlider.setBounds(area.withSizeKeepingCentre(width-20, 100));
}
| 4,966
|
C++
|
.cpp
| 109
| 40.266055
| 129
| 0.706642
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,588
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_13_Clipping/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_13_clippingAudioProcessorEditor::Plugex_13_clippingAudioProcessorEditor (Plugex_13_clippingAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("red");
title.setText("Plugex - 13 - Hard Clipping", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
threshLabel.setText("Threshold", NotificationType::dontSendNotification);
threshLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&threshLabel);
threshKnob.setLookAndFeel(&plugexLookAndFeel);
threshKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
threshKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&threshKnob);
threshAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "thresh", threshKnob));
cutoffLabel.setText("Cutoff", NotificationType::dontSendNotification);
cutoffLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&cutoffLabel);
cutoffKnob.setLookAndFeel(&plugexLookAndFeel);
cutoffKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
cutoffKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&cutoffKnob);
cutoffAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "cutoff", cutoffKnob));
}
Plugex_13_clippingAudioProcessorEditor::~Plugex_13_clippingAudioProcessorEditor()
{
threshKnob.setLookAndFeel(nullptr);
cutoffKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_13_clippingAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_13_clippingAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto threshArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
threshLabel.setBounds(threshArea.removeFromTop(20));
threshKnob.setBounds(threshArea);
auto cutoffArea = area2.withSizeKeepingCentre(80, 100);
cutoffLabel.setBounds(cutoffArea.removeFromTop(20));
cutoffKnob.setBounds(cutoffArea);
area.removeFromTop(12);
}
| 3,551
|
C++
|
.cpp
| 69
| 47.246377
| 152
| 0.713086
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,589
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_13_Clipping/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
static String threshSliderValueToText(float value) {
return String(value, 3) + String(" x");
}
static float threshSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String cutoffSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float cutoffSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("thresh"), String("Thresh"), String(),
NormalisableRange<float>(0.01f, 1.0f, 0.001f, 0.5f),
0.5f, threshSliderValueToText, threshSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("cutoff"), String("Cutoff"), String(),
NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f),
1000.0f, cutoffSliderValueToText, cutoffSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_13_clippingAudioProcessor::Plugex_13_clippingAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
threshParameter = parameters.getRawParameterValue("thresh");
cutoffParameter = parameters.getRawParameterValue("cutoff");
}
Plugex_13_clippingAudioProcessor::~Plugex_13_clippingAudioProcessor()
{
}
//==============================================================================
const String Plugex_13_clippingAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_13_clippingAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_13_clippingAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_13_clippingAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_13_clippingAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_13_clippingAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_13_clippingAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_13_clippingAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_13_clippingAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_13_clippingAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_13_clippingAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
threshSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
threshSmoothed.setCurrentAndTargetValue(*threshParameter);
cutoffSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
cutoffSmoothed.setCurrentAndTargetValue(*cutoffParameter);
for (int channel = 0; channel < 2; channel++) {
lowpassFilter[channel].setup(sampleRate);
}
}
void Plugex_13_clippingAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_13_clippingAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_13_clippingAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
threshSmoothed.setTargetValue(*threshParameter);
cutoffSmoothed.setTargetValue(*cutoffParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float currentThresh = threshSmoothed.getNextValue();
float currentCutoff = cutoffSmoothed.getNextValue();
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
lowpassFilter[channel].setFreq(currentCutoff);
auto* channelData = buffer.getWritePointer (channel);
channelData[i] = channelData[i] > currentThresh ? currentThresh : channelData[i] < -currentThresh ? -currentThresh : channelData[i];
channelData[i] *= 0.7071f / currentThresh;
channelData[i] = lowpassFilter[channel].process(channelData[i]);
}
}
}
//==============================================================================
bool Plugex_13_clippingAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_13_clippingAudioProcessor::createEditor()
{
return new Plugex_13_clippingAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_13_clippingAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_13_clippingAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_13_clippingAudioProcessor();
}
| 8,111
|
C++
|
.cpp
| 195
| 35.476923
| 144
| 0.650395
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,590
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_21_Chorus/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_21_chorusAudioProcessorEditor::Plugex_21_chorusAudioProcessorEditor (Plugex_21_chorusAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("orange");
title.setText("Plugex - 21 - Chorus", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
depthLabel.setText("Depth", NotificationType::dontSendNotification);
depthLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&depthLabel);
depthKnob.setLookAndFeel(&plugexLookAndFeel);
depthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
depthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&depthKnob);
depthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "depth", depthKnob));
feedbackLabel.setText("Feedback", NotificationType::dontSendNotification);
feedbackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&feedbackLabel);
feedbackKnob.setLookAndFeel(&plugexLookAndFeel);
feedbackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
feedbackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&feedbackKnob);
feedbackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "feedback", feedbackKnob));
balanceLabel.setText("Balance", NotificationType::dontSendNotification);
balanceLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&balanceLabel);
balanceKnob.setLookAndFeel(&plugexLookAndFeel);
balanceKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
balanceKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&balanceKnob);
balanceAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "balance", balanceKnob));
}
Plugex_21_chorusAudioProcessorEditor::~Plugex_21_chorusAudioProcessorEditor()
{
depthKnob.setLookAndFeel(nullptr);
feedbackKnob.setLookAndFeel(nullptr);
balanceKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_21_chorusAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_21_chorusAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto depthArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
depthLabel.setBounds(depthArea.removeFromTop(20));
depthKnob.setBounds(depthArea);
auto feedbackArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
feedbackLabel.setBounds(feedbackArea.removeFromTop(20));
feedbackKnob.setBounds(feedbackArea);
auto balanceArea = area2.withSizeKeepingCentre(80, 100);
balanceLabel.setBounds(balanceArea.removeFromTop(20));
balanceKnob.setBounds(balanceArea);
area.removeFromTop(12);
}
| 4,319
|
C++
|
.cpp
| 81
| 48.938272
| 146
| 0.731336
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,591
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_21_Chorus/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String depthSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float depthSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("depth"), String("Depth"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
25.0f, depthSliderValueToText, depthSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("feedback"), String("Feedback"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
40.0f, depthSliderValueToText, depthSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("balance"), String("Balance"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
50.0f, depthSliderValueToText, depthSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_21_chorusAudioProcessor::Plugex_21_chorusAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
depthParameter = parameters.getRawParameterValue("depth");
feedbackParameter = parameters.getRawParameterValue("feedback");
balanceParameter = parameters.getRawParameterValue("balance");
}
Plugex_21_chorusAudioProcessor::~Plugex_21_chorusAudioProcessor()
{
}
//==============================================================================
const String Plugex_21_chorusAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_21_chorusAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_21_chorusAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_21_chorusAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_21_chorusAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_21_chorusAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_21_chorusAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_21_chorusAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_21_chorusAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_21_chorusAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_21_chorusAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
depthSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
depthSmoothed.setCurrentAndTargetValue(*depthParameter);
feedbackSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
feedbackSmoothed.setCurrentAndTargetValue(*feedbackParameter);
balanceSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
balanceSmoothed.setCurrentAndTargetValue(*balanceParameter);
float srFactor = currentSampleRate / 44100.f;
for (int line = 0; line < 8; line++) {
for (int channel = 0; channel < 2; channel++) {
lfoDelayTime[line][channel].setup(currentSampleRate);
float delayLineLength = (centerDelayTimes[0] * srFactor * 2.f + 0.005f);
delayLine[line][channel].setup(delayLineLength, currentSampleRate);
}
}
}
void Plugex_21_chorusAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_21_chorusAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_21_chorusAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
depthSmoothed.setTargetValue(*depthParameter);
feedbackSmoothed.setTargetValue(*feedbackParameter);
balanceSmoothed.setTargetValue(*balanceParameter);
for (int i = 0; i < buffer.getNumSamples(); i++) {
float currentDepth = depthSmoothed.getNextValue() * 0.02;
float currentFeedback = feedbackSmoothed.getNextValue() * 0.01;
float currentBalance = balanceSmoothed.getNextValue() * 0.01;
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
float totalSignal = 0.f;
auto* channelData = buffer.getWritePointer (channel);
for (int line = 0; line < 8; line++) {
lfoDelayTime[line][channel].setFreq(lfoFrequencies[line] + channel * 0.01f);
float delayTime = delayTimeDevs[line] * currentDepth * lfoDelayTime[line][channel].process() + centerDelayTimes[line];
float sampleRead = delayLine[line][channel].read(delayTime);
delayLine[line][channel].write(channelData[i] + sampleRead * currentFeedback);
totalSignal += sampleRead;
}
totalSignal *= 0.25;
channelData[i] = channelData[i] + (totalSignal - channelData[i]) * currentBalance;
}
}
}
//==============================================================================
bool Plugex_21_chorusAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_21_chorusAudioProcessor::createEditor()
{
return new Plugex_21_chorusAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_21_chorusAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_21_chorusAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_21_chorusAudioProcessor();
}
| 9,229
|
C++
|
.cpp
| 210
| 36.980952
| 134
| 0.642753
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,592
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_20_Flanger/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_20_flangerAudioProcessorEditor::Plugex_20_flangerAudioProcessorEditor (Plugex_20_flangerAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("orange");
title.setText("Plugex - 20 - Flanger", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Frequency", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
delayLabel.setText("Central Delay", NotificationType::dontSendNotification);
delayLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&delayLabel);
delayKnob.setLookAndFeel(&plugexLookAndFeel);
delayKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
delayKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&delayKnob);
delayAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "delay", delayKnob));
depthLabel.setText("Depth", NotificationType::dontSendNotification);
depthLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&depthLabel);
depthKnob.setLookAndFeel(&plugexLookAndFeel);
depthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
depthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&depthKnob);
depthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "depth", depthKnob));
}
Plugex_20_flangerAudioProcessorEditor::~Plugex_20_flangerAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
delayKnob.setLookAndFeel(nullptr);
depthKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_20_flangerAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_20_flangerAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto freqArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
auto delayArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
delayLabel.setBounds(delayArea.removeFromTop(20));
delayKnob.setBounds(delayArea);
auto depthArea = area2.withSizeKeepingCentre(80, 100);
depthLabel.setBounds(depthArea.removeFromTop(20));
depthKnob.setBounds(depthArea);
area.removeFromTop(12);
}
| 4,238
|
C++
|
.cpp
| 81
| 47.938272
| 149
| 0.725818
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,593
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_20_Flanger/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 3) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String delaySliderValueToText(float value) {
return String(value, 2) + String(" ms");
}
static float delaySliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String depthSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float depthSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(0.01f, 1.0f, 0.001f, 0.5f),
0.1f, freqSliderValueToText, freqSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("delay"), String("Delay"), String(),
NormalisableRange<float>(1.0f, 10.0f, 0.01f, 1.0f),
5.0f, delaySliderValueToText, delaySliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("depth"), String("Depth"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
100.0f, depthSliderValueToText, depthSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_20_flangerAudioProcessor::Plugex_20_flangerAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
delayParameter = parameters.getRawParameterValue("delay");
depthParameter = parameters.getRawParameterValue("depth");
}
Plugex_20_flangerAudioProcessor::~Plugex_20_flangerAudioProcessor()
{
}
//==============================================================================
const String Plugex_20_flangerAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_20_flangerAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_20_flangerAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_20_flangerAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_20_flangerAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_20_flangerAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_20_flangerAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_20_flangerAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_20_flangerAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_20_flangerAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_20_flangerAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
lfoPhase = 0.0f;
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
delaySmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
delaySmoothed.setCurrentAndTargetValue(*delayParameter);
depthSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
depthSmoothed.setCurrentAndTargetValue(*depthParameter);
for (int channel = 0; channel < 2; channel++) {
delayLine[channel].setup(0.25f, currentSampleRate);
}
}
void Plugex_20_flangerAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_20_flangerAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_20_flangerAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
delaySmoothed.setTargetValue(*delayParameter);
depthSmoothed.setTargetValue(*depthParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float currentFreq = freqSmoothed.getNextValue();
float currentDelay = delaySmoothed.getNextValue() * 0.001f;
float currentDepth = depthSmoothed.getNextValue() * 0.0099f;
float lfoDelayTime = sinf(lfoPhase * M_PI * 2) * (currentDelay * currentDepth) + currentDelay;
lfoPhase += currentFreq / currentSampleRate;
if (lfoPhase >= 1.0f) {
lfoPhase -= 1.0f;
}
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float sampleRead = delayLine[channel].read(lfoDelayTime);
auto* channelData = buffer.getWritePointer (channel);
delayLine[channel].write(channelData[i]);
channelData[i] = channelData[i] + (sampleRead - channelData[i]) * 0.5f;
}
}
}
//==============================================================================
bool Plugex_20_flangerAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_20_flangerAudioProcessor::createEditor()
{
return new Plugex_20_flangerAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_20_flangerAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_20_flangerAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_20_flangerAudioProcessor();
}
| 9,086
|
C++
|
.cpp
| 218
| 35.256881
| 110
| 0.647447
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,594
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_04_FirstOrderLP/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_04_firstOrderLpAudioProcessorEditor::Plugex_04_firstOrderLpAudioProcessorEditor (Plugex_04_firstOrderLpAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("green");
title.setText("Plugex - 04 - First Order Lowpass Filter", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
}
Plugex_04_firstOrderLpAudioProcessorEditor::~Plugex_04_firstOrderLpAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_04_firstOrderLpAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_04_firstOrderLpAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto freqArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
area.removeFromTop(12);
}
| 2,518
|
C++
|
.cpp
| 52
| 44.596154
| 164
| 0.685375
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,595
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_04_FirstOrderLP/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f),
1000.0f, freqSliderValueToText, freqSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_04_firstOrderLpAudioProcessor::Plugex_04_firstOrderLpAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
}
Plugex_04_firstOrderLpAudioProcessor::~Plugex_04_firstOrderLpAudioProcessor()
{
}
//==============================================================================
const String Plugex_04_firstOrderLpAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_04_firstOrderLpAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_04_firstOrderLpAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_04_firstOrderLpAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_04_firstOrderLpAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_04_firstOrderLpAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_04_firstOrderLpAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_04_firstOrderLpAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_04_firstOrderLpAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_04_firstOrderLpAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_04_firstOrderLpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
memset(lastFilteredSample, 0, sizeof(float) * 2);
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
}
void Plugex_04_firstOrderLpAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_04_firstOrderLpAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_04_firstOrderLpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float coefficient = expf(-2.0f * M_PI * freqSmoothed.getNextValue() / currentSampleRate);
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer (channel);
lastFilteredSample[channel] = channelData[i] + (lastFilteredSample[channel] - channelData[i]) * coefficient;
channelData[i] = lastFilteredSample[channel];
}
}
}
//==============================================================================
bool Plugex_04_firstOrderLpAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_04_firstOrderLpAudioProcessor::createEditor()
{
return new Plugex_04_firstOrderLpAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_04_firstOrderLpAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_04_firstOrderLpAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_04_firstOrderLpAudioProcessor();
}
| 7,283
|
C++
|
.cpp
| 181
| 34.690608
| 120
| 0.653447
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,596
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_37_SineAdsrMidiSynth/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2020
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_37_sineAdsrMidiSynthAudioProcessorEditor::Plugex_37_sineAdsrMidiSynthAudioProcessorEditor (Plugex_37_sineAdsrMidiSynthAudioProcessor& p,
AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts),
keyboardComponent (p.keyboardState, MidiKeyboardComponent::horizontalKeyboard)
{
setSize (500, 280);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("lightgreen");
title.setText("Plugex - 37 - Sine ADSR Midi Synth", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
attackLabel.setText("Attack", NotificationType::dontSendNotification);
attackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&attackLabel);
attackKnob.setLookAndFeel(&plugexLookAndFeel);
attackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
attackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&attackKnob);
attackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "attack", attackKnob));
decayLabel.setText("Decay", NotificationType::dontSendNotification);
decayLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&decayLabel);
decayKnob.setLookAndFeel(&plugexLookAndFeel);
decayKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
decayKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&decayKnob);
decayAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "decay", decayKnob));
sustainLabel.setText("Sustain", NotificationType::dontSendNotification);
sustainLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&sustainLabel);
sustainKnob.setLookAndFeel(&plugexLookAndFeel);
sustainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
sustainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&sustainKnob);
sustainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sustain", sustainKnob));
releaseLabel.setText("Release", NotificationType::dontSendNotification);
releaseLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&releaseLabel);
releaseKnob.setLookAndFeel(&plugexLookAndFeel);
releaseKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
releaseKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&releaseKnob);
releaseAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "release", releaseKnob));
gainLabel.setText("Gain", NotificationType::dontSendNotification);
gainLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&gainLabel);
gainKnob.setLookAndFeel(&plugexLookAndFeel);
gainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
gainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&gainKnob);
gainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain", gainKnob));
addAndMakeVisible(keyboardComponent);
}
Plugex_37_sineAdsrMidiSynthAudioProcessorEditor::~Plugex_37_sineAdsrMidiSynthAudioProcessorEditor()
{
attackKnob.setLookAndFeel(nullptr);
decayKnob.setLookAndFeel(nullptr);
sustainKnob.setLookAndFeel(nullptr);
releaseKnob.setLookAndFeel(nullptr);
gainKnob.setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_37_sineAdsrMidiSynthAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_37_sineAdsrMidiSynthAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area1 = area.removeFromTop(100);
auto attackArea = area1.removeFromLeft(width/5.0f).withSizeKeepingCentre(80, 100);
attackLabel.setBounds(attackArea.removeFromTop(20));
attackKnob.setBounds(attackArea);
auto decayArea = area1.removeFromLeft(width/5.0f).withSizeKeepingCentre(80, 100);
decayLabel.setBounds(decayArea.removeFromTop(20));
decayKnob.setBounds(decayArea);
auto sustainArea = area1.removeFromLeft(width/5.0f).withSizeKeepingCentre(80, 100);
sustainLabel.setBounds(sustainArea.removeFromTop(20));
sustainKnob.setBounds(sustainArea);
auto releaseArea = area1.removeFromLeft(width/5.0f).withSizeKeepingCentre(80, 100);
releaseLabel.setBounds(releaseArea.removeFromTop(20));
releaseKnob.setBounds(releaseArea);
auto gainArea = area1.removeFromTop(100).withSizeKeepingCentre(80, 100);
gainLabel.setBounds(gainArea.removeFromTop(20));
gainKnob.setBounds(gainArea);
area.removeFromTop(12);
keyboardComponent.setBounds(area.removeFromBottom(80));
}
| 5,928
|
C++
|
.cpp
| 105
| 50.933333
| 143
| 0.744464
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,598
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_39_WaveModMidiSynth/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2020
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_39_waveModMidiSynthAudioProcessorEditor::Plugex_39_waveModMidiSynthAudioProcessorEditor (Plugex_39_waveModMidiSynthAudioProcessor& p,
AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts),
keyboardComponent (p.keyboardState, MidiKeyboardComponent::horizontalKeyboard)
{
setSize (700, 520);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("lightgreen");
title.setText("Plugex - 39 - Wave Mod Midi Synth", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
attackLabel.setText("Attack", NotificationType::dontSendNotification);
attackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&attackLabel);
attackKnob.setLookAndFeel(&plugexLookAndFeel);
attackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
attackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&attackKnob);
attackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "attack", attackKnob));
decayLabel.setText("Decay", NotificationType::dontSendNotification);
decayLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&decayLabel);
decayKnob.setLookAndFeel(&plugexLookAndFeel);
decayKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
decayKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&decayKnob);
decayAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "decay", decayKnob));
sustainLabel.setText("Sustain", NotificationType::dontSendNotification);
sustainLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&sustainLabel);
sustainKnob.setLookAndFeel(&plugexLookAndFeel);
sustainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
sustainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&sustainKnob);
sustainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sustain", sustainKnob));
releaseLabel.setText("Release", NotificationType::dontSendNotification);
releaseLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&releaseLabel);
releaseKnob.setLookAndFeel(&plugexLookAndFeel);
releaseKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
releaseKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&releaseKnob);
releaseAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "release", releaseKnob));
//------------------------------------------------------------------------------------------------------------------
lfotypeLabel.setText("LFO Wave Type", NotificationType::dontSendNotification);
lfotypeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&lfotypeLabel);
lfotypeCombo.setLookAndFeel(&plugexLookAndFeel);
lfotypeCombo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1);
lfotypeCombo.setSelectedId(1);
addAndMakeVisible(&lfotypeCombo);
lfotypeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "lfotype", lfotypeCombo));
lfofreqLabel.setText("LFO Freq", NotificationType::dontSendNotification);
lfofreqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&lfofreqLabel);
lfofreqKnob.setLookAndFeel(&plugexLookAndFeel);
lfofreqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
lfofreqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&lfofreqKnob);
lfofreqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lfofreq", lfofreqKnob));
lfodepthLabel.setText("LFO Depth", NotificationType::dontSendNotification);
lfodepthLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&lfodepthLabel);
lfodepthKnob.setLookAndFeel(&plugexLookAndFeel);
lfodepthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
lfodepthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&lfodepthKnob);
lfodepthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lfodepth", lfodepthKnob));
lfoRouteFreq.setLookAndFeel(&plugexLookAndFeel);
lfoRouteFreq.setButtonText("OSC Freq");
addAndMakeVisible(&lfoRouteFreq);
lfoRouteFreqAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfoRouteFreq", lfoRouteFreq));
lfoRouteFreqInv.setLookAndFeel(&plugexLookAndFeel);
lfoRouteFreqInv.setButtonText("inv");
addAndMakeVisible(&lfoRouteFreqInv);
lfoRouteFreqInvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfoRouteFreqInv", lfoRouteFreqInv));
lfoRouteSharp.setLookAndFeel(&plugexLookAndFeel);
lfoRouteSharp.setButtonText("OSC Bright");
addAndMakeVisible(&lfoRouteSharp);
lfoRouteSharpAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfoRouteSharp", lfoRouteSharp));
lfoRouteSharpInv.setLookAndFeel(&plugexLookAndFeel);
lfoRouteSharpInv.setButtonText("inv");
addAndMakeVisible(&lfoRouteSharpInv);
lfoRouteSharpInvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfoRouteSharpInv", lfoRouteSharpInv));
lfoRouteGain.setLookAndFeel(&plugexLookAndFeel);
lfoRouteGain.setButtonText("OSC Gain");
addAndMakeVisible(&lfoRouteGain);
lfoRouteGainAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfoRouteGain", lfoRouteGain));
lfoRouteGainInv.setLookAndFeel(&plugexLookAndFeel);
lfoRouteGainInv.setButtonText("inv");
addAndMakeVisible(&lfoRouteGainInv);
lfoRouteGainInvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfoRouteGainInv", lfoRouteGainInv));
//------------------------------------------------------------------------------------------------------------------
typeLabel.setText("Wave Type", NotificationType::dontSendNotification);
typeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&typeLabel);
typeCombo.setLookAndFeel(&plugexLookAndFeel);
typeCombo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1);
typeCombo.setSelectedId(1);
addAndMakeVisible(&typeCombo);
typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type", typeCombo));
sharpLabel.setText("Bright", NotificationType::dontSendNotification);
sharpLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&sharpLabel);
sharpKnob.setLookAndFeel(&plugexLookAndFeel);
sharpKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
sharpKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&sharpKnob);
sharpAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sharp", sharpKnob));
gainLabel.setText("Gain", NotificationType::dontSendNotification);
gainLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&gainLabel);
gainKnob.setLookAndFeel(&plugexLookAndFeel);
gainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
gainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&gainKnob);
gainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain", gainKnob));
stereoToggle.setLookAndFeel(&plugexLookAndFeel);
stereoToggle.setButtonText("Stereo");
addAndMakeVisible(&stereoToggle);
stereoToggleAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "stereo", stereoToggle));
//------------------------------------------------------------------------------------------------------------------
addAndMakeVisible(keyboardComponent);
}
Plugex_39_waveModMidiSynthAudioProcessorEditor::~Plugex_39_waveModMidiSynthAudioProcessorEditor()
{
attackKnob.setLookAndFeel(nullptr);
decayKnob.setLookAndFeel(nullptr);
sustainKnob.setLookAndFeel(nullptr);
releaseKnob.setLookAndFeel(nullptr);
lfotypeCombo.setLookAndFeel(nullptr);
lfofreqKnob.setLookAndFeel(nullptr);
lfodepthKnob.setLookAndFeel(nullptr);
lfoRouteFreq.setLookAndFeel(nullptr);
lfoRouteFreqInv.setLookAndFeel(nullptr);
lfoRouteSharp.setLookAndFeel(nullptr);
lfoRouteSharpInv.setLookAndFeel(nullptr);
lfoRouteGain.setLookAndFeel(nullptr);
lfoRouteGainInv.setLookAndFeel(nullptr);
typeCombo.setLookAndFeel(nullptr);
sharpKnob.setLookAndFeel(nullptr);
gainKnob.setLookAndFeel(nullptr);
stereoToggle.setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_39_waveModMidiSynthAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_39_waveModMidiSynthAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area1 = area.removeFromTop(100);
auto attackArea = area1.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
attackLabel.setBounds(attackArea.removeFromTop(20));
attackKnob.setBounds(attackArea);
auto decayArea = area1.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
decayLabel.setBounds(decayArea.removeFromTop(20));
decayKnob.setBounds(decayArea);
auto sustainArea = area1.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
sustainLabel.setBounds(sustainArea.removeFromTop(20));
sustainKnob.setBounds(sustainArea);
auto releaseArea = area1.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
releaseLabel.setBounds(releaseArea.removeFromTop(20));
releaseKnob.setBounds(releaseArea);
auto area2 = area.removeFromTop(140);
auto lfotypeArea = area2.removeFromLeft(width/3.f).withSizeKeepingCentre(200, 100);
lfotypeLabel.setBounds(lfotypeArea.removeFromTop(20));
lfotypeCombo.setBounds(lfotypeArea.removeFromTop(60).withSizeKeepingCentre(200, 24));
auto lfofreqArea = area2.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
lfofreqLabel.setBounds(lfofreqArea.removeFromTop(20));
lfofreqKnob.setBounds(lfofreqArea);
auto lfodepthArea = area2.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
lfodepthLabel.setBounds(lfodepthArea.removeFromTop(20));
lfodepthKnob.setBounds(lfodepthArea);
auto lfoRouteArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(200, 100);
auto lfoRouteAreaItemHeight = lfoRouteArea.getHeight() / 3.f;
auto lfoRouteFreqArea = lfoRouteArea.removeFromTop(lfoRouteAreaItemHeight);
lfoRouteFreq.setBounds(lfoRouteFreqArea.removeFromLeft(130));
lfoRouteFreqInv.setBounds(lfoRouteFreqArea);
auto lfoRouteSharpArea = lfoRouteArea.removeFromTop(lfoRouteAreaItemHeight);
lfoRouteSharp.setBounds(lfoRouteSharpArea.removeFromLeft(130));
lfoRouteSharpInv.setBounds(lfoRouteSharpArea);
auto lfoRouteGainArea = lfoRouteArea.removeFromTop(lfoRouteAreaItemHeight);
lfoRouteGain.setBounds(lfoRouteGainArea.removeFromLeft(130));
lfoRouteGainInv.setBounds(lfoRouteGainArea);
auto area3 = area.removeFromTop(100);
auto typeArea = area3.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
typeLabel.setBounds(typeArea.removeFromTop(20));
typeCombo.setBounds(typeArea.removeFromTop(60).withSizeKeepingCentre(200, 24));
auto sharpArea = area3.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
sharpLabel.setBounds(sharpArea.removeFromTop(20));
sharpKnob.setBounds(sharpArea);
auto gainArea = area3.removeFromLeft(width/6.0f).withSizeKeepingCentre(80, 100);
gainLabel.setBounds(gainArea.removeFromTop(20));
gainKnob.setBounds(gainArea);
auto stereoToggleArea = area3.removeFromLeft(width/3.0f).withSizeKeepingCentre(200, 100);
stereoToggle.setBounds(stereoToggleArea.withSizeKeepingCentre(stereoToggleArea.getWidth(), 20.f));
area.removeFromTop(12);
keyboardComponent.setBounds(area.removeFromBottom(80));
}
| 13,512
|
C++
|
.cpp
| 218
| 56.587156
| 143
| 0.759531
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,600
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_05_FirstOrderHP/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_05_firstOrderHpAudioProcessorEditor::Plugex_05_firstOrderHpAudioProcessorEditor (Plugex_05_firstOrderHpAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("green");
title.setText("Plugex - 05 - First Order Highpass Filter", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
}
Plugex_05_firstOrderHpAudioProcessorEditor::~Plugex_05_firstOrderHpAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_05_firstOrderHpAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_05_firstOrderHpAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto freqArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
area.removeFromTop(12);
}
| 2,519
|
C++
|
.cpp
| 52
| 44.615385
| 164
| 0.685504
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,601
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_05_FirstOrderHP/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f),
1000.0f, freqSliderValueToText, freqSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_05_firstOrderHpAudioProcessor::Plugex_05_firstOrderHpAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
}
Plugex_05_firstOrderHpAudioProcessor::~Plugex_05_firstOrderHpAudioProcessor()
{
}
//==============================================================================
const String Plugex_05_firstOrderHpAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_05_firstOrderHpAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_05_firstOrderHpAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_05_firstOrderHpAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_05_firstOrderHpAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_05_firstOrderHpAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_05_firstOrderHpAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_05_firstOrderHpAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_05_firstOrderHpAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_05_firstOrderHpAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_05_firstOrderHpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
memset(lastFilteredSample, 0, sizeof(float) * 2);
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
}
void Plugex_05_firstOrderHpAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_05_firstOrderHpAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_05_firstOrderHpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float coefficient = expf(-2.0f * M_PI * freqSmoothed.getNextValue() / currentSampleRate);
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer (channel);
lastFilteredSample[channel] = channelData[i] + (lastFilteredSample[channel] - channelData[i]) * coefficient;
channelData[i] -= lastFilteredSample[channel];
}
}
}
//==============================================================================
bool Plugex_05_firstOrderHpAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_05_firstOrderHpAudioProcessor::createEditor()
{
return new Plugex_05_firstOrderHpAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_05_firstOrderHpAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_05_firstOrderHpAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_05_firstOrderHpAudioProcessor();
}
| 7,284
|
C++
|
.cpp
| 181
| 34.696133
| 120
| 0.653354
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,602
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_19_SmoothDelay/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_19_smoothDelayAudioProcessorEditor::Plugex_19_smoothDelayAudioProcessorEditor (Plugex_19_smoothDelayAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("orange");
title.setText("Plugex - 19 - Smooth Delay", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
timeLabel.setText("Delay Time", NotificationType::dontSendNotification);
timeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&timeLabel);
timeKnob.setLookAndFeel(&plugexLookAndFeel);
timeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
timeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&timeKnob);
timeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "time", timeKnob));
feedbackLabel.setText("Feedback", NotificationType::dontSendNotification);
feedbackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&feedbackLabel);
feedbackKnob.setLookAndFeel(&plugexLookAndFeel);
feedbackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
feedbackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&feedbackKnob);
feedbackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "feedback", feedbackKnob));
balanceLabel.setText("Balance", NotificationType::dontSendNotification);
balanceLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&balanceLabel);
balanceKnob.setLookAndFeel(&plugexLookAndFeel);
balanceKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
balanceKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&balanceKnob);
balanceAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "balance", balanceKnob));
}
Plugex_19_smoothDelayAudioProcessorEditor::~Plugex_19_smoothDelayAudioProcessorEditor()
{
timeKnob.setLookAndFeel(nullptr);
feedbackKnob.setLookAndFeel(nullptr);
balanceKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_19_smoothDelayAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_19_smoothDelayAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto timeArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
timeLabel.setBounds(timeArea.removeFromTop(20));
timeKnob.setBounds(timeArea);
auto feedbackArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
feedbackLabel.setBounds(feedbackArea.removeFromTop(20));
feedbackKnob.setBounds(feedbackArea);
auto balanceArea = area2.withSizeKeepingCentre(80, 100);
balanceLabel.setBounds(balanceArea.removeFromTop(20));
balanceKnob.setBounds(balanceArea);
area.removeFromTop(12);
}
| 4,349
|
C++
|
.cpp
| 81
| 49.308642
| 161
| 0.732767
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,603
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_19_SmoothDelay/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String timeSliderValueToText(float value) {
return String(value, 2) + String(" ms");
}
static float timeSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String feedbackSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float feedbackSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("time"), String("Time"), String(),
NormalisableRange<float>(0.01f, 1000.0f, 0.01f, 0.3f),
100.0f, timeSliderValueToText, timeSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("feedback"), String("Feedback"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
0.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("balance"), String("Balance"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
50.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_19_smoothDelayAudioProcessor::Plugex_19_smoothDelayAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
timeParameter = parameters.getRawParameterValue("time");
feedbackParameter = parameters.getRawParameterValue("feedback");
balanceParameter = parameters.getRawParameterValue("balance");
}
Plugex_19_smoothDelayAudioProcessor::~Plugex_19_smoothDelayAudioProcessor()
{
}
//==============================================================================
const String Plugex_19_smoothDelayAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_19_smoothDelayAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_19_smoothDelayAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_19_smoothDelayAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_19_smoothDelayAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_19_smoothDelayAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_19_smoothDelayAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_19_smoothDelayAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_19_smoothDelayAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_19_smoothDelayAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_19_smoothDelayAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
writePosition = 0;
crossFadeTime = samplesPerBlock;
waitingTime = 0;
waitingClock = 0;
currentDelay = 1;
delay1Gain = 0.0f;
delay2Gain = 1.0f;
gain1Increment = gain2Increment = 0.0f;
timeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
timeSmoothed.setCurrentAndTargetValue(*timeParameter);
feedbackSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
feedbackSmoothed.setCurrentAndTargetValue(*feedbackParameter);
balanceSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
balanceSmoothed.setCurrentAndTargetValue(*balanceParameter);
for (int channel = 0; channel < 2; channel++) {
delayLine[channel].setup(1.f, currentSampleRate);
}
}
void Plugex_19_smoothDelayAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_19_smoothDelayAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_19_smoothDelayAudioProcessor::computeDelayTime(float delayTime) {
if (waitingClock == 0) {
currentDelay = (currentDelay + 1) % 2;
waitingTime = floor(delayTime * currentSampleRate + 0.5);
if (crossFadeTime > waitingTime) {
crossFadeTime = waitingTime;
}
if (crossFadeTime <= 0) {
crossFadeTime = 1;
}
if (currentDelay == 0) {
delay1Time = delayTime;
gain1Increment = 1.0 / crossFadeTime;
gain2Increment = -gain1Increment;
} else {
delay2Time = delayTime;
gain2Increment = 1.0 / crossFadeTime;
gain1Increment = -gain2Increment;
}
}
waitingClock += 1;
if (waitingClock == waitingTime) {
waitingClock = 0;
}
}
void Plugex_19_smoothDelayAudioProcessor::updateAmplitude() {
delay1Gain += gain1Increment;
delay1Gain = delay1Gain < 0.0f ? 0.0f : delay1Gain > 1.0f ? 1.0f : delay1Gain;
delay2Gain += gain2Increment;
delay2Gain = delay2Gain < 0.0f ? 0.0f : delay2Gain > 1.0f ? 1.0f : delay2Gain;
}
void Plugex_19_smoothDelayAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
timeSmoothed.setTargetValue(*timeParameter);
feedbackSmoothed.setTargetValue(*feedbackParameter);
balanceSmoothed.setTargetValue(*balanceParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float currentTime = timeSmoothed.getNextValue() * 0.001;
float currentFeedback = feedbackSmoothed.getNextValue() * 0.01;
float currentBalance = balanceSmoothed.getNextValue() * 0.01;
computeDelayTime(currentTime);
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float sampleRead = delayLine[channel].read(delay1Time) * delay1Gain;
sampleRead += delayLine[channel].read(delay2Time) * delay2Gain;
auto* channelData = buffer.getWritePointer (channel);
delayLine[channel].write(channelData[i] + sampleRead * currentFeedback);
channelData[i] = channelData[i] + (sampleRead - channelData[i]) * currentBalance;
}
updateAmplitude();
}
}
//==============================================================================
bool Plugex_19_smoothDelayAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_19_smoothDelayAudioProcessor::createEditor()
{
return new Plugex_19_smoothDelayAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_19_smoothDelayAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_19_smoothDelayAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_19_smoothDelayAudioProcessor();
}
| 10,343
|
C++
|
.cpp
| 248
| 35.060484
| 115
| 0.65013
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,604
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_00_TemplateFFT/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_00_templateFftAudioProcessorEditor::Plugex_00_templateFftAudioProcessorEditor (Plugex_00_templateFftAudioProcessor& p,
AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("blue");
title.setText("Plugex - 00 - FFT Template", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
description.setText("FFT template passing the signal unchanged", NotificationType::dontSendNotification);
description.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&description);
orderLabel.setText("FFT Size", NotificationType::dontSendNotification);
orderLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&orderLabel);
orderCombo.setLookAndFeel(&plugexLookAndFeel);
orderCombo.addItemList({"64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384"}, 6);
orderCombo.setSelectedId(10);
addAndMakeVisible(&orderCombo);
orderAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "order", orderCombo));
overlapsLabel.setText("FFT Overlaps", NotificationType::dontSendNotification);
overlapsLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&overlapsLabel);
overlapsCombo.setLookAndFeel(&plugexLookAndFeel);
overlapsCombo.addItemList({"2", "4", "8"}, 1);
overlapsCombo.setSelectedId(2);
addAndMakeVisible(&overlapsCombo);
overlapsAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "overlaps", overlapsCombo));
wintypeLabel.setText("Window Type", NotificationType::dontSendNotification);
wintypeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&wintypeLabel);
wintypeCombo.setLookAndFeel(&plugexLookAndFeel);
wintypeCombo.addItemList({"Rectangular", "Triangular", "Hanning", "Hamming", "Blackman", "Blackman-Harris 4 terms",
"Blackman-Harris 7 terms", "Flat Top", "Half Sine"}, 1);
wintypeCombo.setSelectedId(3);
addAndMakeVisible(&wintypeCombo);
wintypeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "wintype", wintypeCombo));
}
Plugex_00_templateFftAudioProcessorEditor::~Plugex_00_templateFftAudioProcessorEditor()
{
orderCombo.setLookAndFeel(nullptr);
overlapsCombo.setLookAndFeel(nullptr);
wintypeCombo.setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_00_templateFftAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_00_templateFftAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
description.setBounds(area.removeFromTop(24).withSizeKeepingCentre(getWidth() - 20, 24));
area.removeFromTop(12);
auto area2 = area.removeFromTop(60);
auto orderArea = area2.removeFromLeft(width / 3.0f);
orderLabel.setBounds(orderArea.removeFromTop(20));
orderCombo.setBounds(orderArea.removeFromTop(60).withSizeKeepingCentre(120, 24));
auto overlapsArea = area2.removeFromLeft(width / 3.0f);
overlapsLabel.setBounds(overlapsArea.removeFromTop(20));
overlapsCombo.setBounds(overlapsArea.removeFromTop(60).withSizeKeepingCentre(120, 24));
wintypeLabel.setBounds(area2.removeFromTop(20));
wintypeCombo.setBounds(area2.removeFromTop(60).withSizeKeepingCentre(120, 24));
area.removeFromTop(12);
}
| 4,627
|
C++
|
.cpp
| 83
| 50.072289
| 126
| 0.708426
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,605
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_00_TemplateFFT/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("order"), String("Order"), String(),
NormalisableRange<float>(6.0f, 14.0f, 1.f, 1.0f),
6.0f, nullptr, nullptr));
parameters.push_back(std::make_unique<Parameter>(String("overlaps"), String("Overlaps"), String(),
NormalisableRange<float>(1.0f, 3.0f, 1.f, 1.0f),
2.0f, nullptr, nullptr));
parameters.push_back(std::make_unique<Parameter>(String("wintype"), String("Wintype"), String(),
NormalisableRange<float>(1.0f, 9.0f, 1.f, 1.0f),
3.0f, nullptr, nullptr));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_00_templateFftAudioProcessor::Plugex_00_templateFftAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
orderParameter = parameters.getRawParameterValue("order");
overlapsParameter = parameters.getRawParameterValue("overlaps");
wintypeParameter = parameters.getRawParameterValue("wintype");
lastOrder = (int)*orderParameter;
lastOverlaps = 1 << (int)*overlapsParameter;
lastWintype = (int)*overlapsParameter;
for (auto channel = 0; channel < 2; channel++) {
fftEngine[channel].setup(lastOrder, lastOverlaps, lastWintype);
fftEngine[channel].addListener(this);
}
}
Plugex_00_templateFftAudioProcessor::~Plugex_00_templateFftAudioProcessor()
{
}
//==============================================================================
const String Plugex_00_templateFftAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_00_templateFftAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_00_templateFftAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_00_templateFftAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_00_templateFftAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_00_templateFftAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_00_templateFftAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_00_templateFftAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_00_templateFftAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_00_templateFftAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_00_templateFftAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
// Use this method as the place to do any pre-playback
// initialisation that you need..
}
void Plugex_00_templateFftAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_00_templateFftAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_00_templateFftAudioProcessor::fftEngineFrameReady(FFTEngine *engine, float *fftData, int fftSize) {
// Function callback to process FFT frames.
}
void Plugex_00_templateFftAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
int order = (int) *orderParameter;
int overlaps = 1 << (int) *overlapsParameter;
int wintype = (int) *wintypeParameter;
for (auto channel = 0; channel < totalNumInputChannels; channel++) {
if (order != lastOrder || overlaps != lastOverlaps) {
fftEngine[channel].setup(order, overlaps, wintype);
}
if (wintype != lastWintype) {
fftEngine[channel].setWintype(wintype);
}
auto *channelData = buffer.getWritePointer(channel);
for (int i = 0; i < buffer.getNumSamples(); i++) {
channelData[i] = fftEngine[channel].process(channelData[i]);
}
}
lastOrder = order;
lastOverlaps = overlaps;
lastWintype = wintype;
}
//==============================================================================
bool Plugex_00_templateFftAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_00_templateFftAudioProcessor::createEditor()
{
return new Plugex_00_templateFftAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_00_templateFftAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_00_templateFftAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_00_templateFftAudioProcessor();
}
| 8,239
|
C++
|
.cpp
| 194
| 35.412371
| 112
| 0.628091
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,606
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_23_Phaser/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_23_phaserAudioProcessorEditor::Plugex_23_phaserAudioProcessorEditor (Plugex_23_phaserAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("orange");
title.setText("Plugex - 23 - Phaser", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
spreadLabel.setText("Spread", NotificationType::dontSendNotification);
spreadLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&spreadLabel);
spreadKnob.setLookAndFeel(&plugexLookAndFeel);
spreadKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
spreadKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&spreadKnob);
spreadAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "spread", spreadKnob));
qLabel.setText("Q", NotificationType::dontSendNotification);
qLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&qLabel);
qKnob.setLookAndFeel(&plugexLookAndFeel);
qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&qKnob);
qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob));
feedbackLabel.setText("Feedback", NotificationType::dontSendNotification);
feedbackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&feedbackLabel);
feedbackKnob.setLookAndFeel(&plugexLookAndFeel);
feedbackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
feedbackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&feedbackKnob);
feedbackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "feedback", feedbackKnob));
}
Plugex_23_phaserAudioProcessorEditor::~Plugex_23_phaserAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
spreadKnob.setLookAndFeel(nullptr);
qKnob.setLookAndFeel(nullptr);
feedbackKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_23_phaserAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_23_phaserAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area1 = area.removeFromTop(100);
auto freqArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
auto spreadArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
spreadLabel.setBounds(spreadArea.removeFromTop(20));
spreadKnob.setBounds(spreadArea);
auto qArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
qLabel.setBounds(qArea.removeFromTop(20));
qKnob.setBounds(qArea);
auto feedbackArea = area1.withSizeKeepingCentre(80, 100);
feedbackLabel.setBounds(feedbackArea.removeFromTop(20));
feedbackKnob.setBounds(feedbackArea);
area.removeFromTop(12);
}
| 4,956
|
C++
|
.cpp
| 93
| 48.774194
| 146
| 0.736689
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,607
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_23_Phaser/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String spreadSliderValueToText(float value) {
return String(value, 2) + String(" x");
}
static float spreadSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String qSliderValueToText(float value) {
return String(value, 2) + String(" Q");
}
static float qSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String feedbackSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float feedbackSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(20.0f, 10000.0f, 0.01f, 0.3f),
100.0f, freqSliderValueToText, freqSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("spread"), String("spread"), String(),
NormalisableRange<float>(0.5f, 2.0f, 0.01f, 1.0f),
1.25f, spreadSliderValueToText, spreadSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("q"), String("Q"), String(),
NormalisableRange<float>(0.5f, 20.0f, 0.01f, 0.3f),
1.0f, qSliderValueToText, qSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("feedback"), String("Feedback"), String(),
NormalisableRange<float>(0.f, 100.0f, 0.01f, 1.0f),
25.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_23_phaserAudioProcessor::Plugex_23_phaserAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
spreadParameter = parameters.getRawParameterValue("spread");
qParameter = parameters.getRawParameterValue("q");
feedbackParameter = parameters.getRawParameterValue("feedback");
}
Plugex_23_phaserAudioProcessor::~Plugex_23_phaserAudioProcessor()
{
}
//==============================================================================
const String Plugex_23_phaserAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_23_phaserAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_23_phaserAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_23_phaserAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_23_phaserAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_23_phaserAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_23_phaserAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_23_phaserAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_23_phaserAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_23_phaserAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_23_phaserAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
spreadSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
spreadSmoothed.setCurrentAndTargetValue(*spreadParameter);
qSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
qSmoothed.setCurrentAndTargetValue(*qParameter);
feedbackSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
feedbackSmoothed.setCurrentAndTargetValue(*feedbackParameter);
for (int filter = 0; filter < 8; filter++) {
for (int channel = 0; channel < 2; channel++) {
allpassFilter[filter][channel].setup(currentSampleRate);
}
}
lastFilterOutput[0] = lastFilterOutput[1] = 0.0f;
}
void Plugex_23_phaserAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_23_phaserAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_23_phaserAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
spreadSmoothed.setTargetValue(*spreadParameter);
qSmoothed.setTargetValue(*qParameter);
feedbackSmoothed.setTargetValue(*feedbackParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float freq = freqSmoothed.getNextValue();
float spread = spreadSmoothed.getNextValue();
float q = qSmoothed.getNextValue();
float feedback = feedbackSmoothed.getNextValue() * 0.01f;
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer (channel);
float filterFreq = freq;
float filterInput = channelData[i] + lastFilterOutput[channel] * feedback;
for (int filter = 0; filter < 8; filter++) {
allpassFilter[filter][channel].setParameters(filterFreq, q, 4);
filterInput = allpassFilter[filter][channel].process(filterInput);
filterFreq *= spread;
}
lastFilterOutput[channel] = filterInput;
channelData[i] = (channelData[i] + filterInput) * 0.7071f;
}
}
}
//==============================================================================
bool Plugex_23_phaserAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_23_phaserAudioProcessor::createEditor()
{
return new Plugex_23_phaserAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_23_phaserAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_23_phaserAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_23_phaserAudioProcessor();
}
| 9,992
|
C++
|
.cpp
| 233
| 35.969957
| 115
| 0.645801
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,608
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_24_Panner/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_24_pannerAudioProcessorEditor::Plugex_24_pannerAudioProcessorEditor (Plugex_24_pannerAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("purple");
title.setText("Plugex - 24 - Panner", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
panLabel.setText("Pan", NotificationType::dontSendNotification);
panLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&panLabel);
panKnob.setLookAndFeel(&plugexLookAndFeel);
panKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
panKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&panKnob);
panAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "pan", panKnob));
typeLabel.setText("Algorithm", NotificationType::dontSendNotification);
typeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&typeLabel);
typeCombo.setLookAndFeel(&plugexLookAndFeel);
typeCombo.addItemList({"Linear", "Square Root", "Sine / Cosine"}, 1);
typeCombo.setSelectedId(1);
addAndMakeVisible(&typeCombo);
typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type", typeCombo));
}
Plugex_24_pannerAudioProcessorEditor::~Plugex_24_pannerAudioProcessorEditor()
{
panKnob.setLookAndFeel(nullptr);
typeCombo.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_24_pannerAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_24_pannerAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto panArea = area2.removeFromLeft(width/2.f).withSizeKeepingCentre(80, 100);
panLabel.setBounds(panArea.removeFromTop(20));
panKnob.setBounds(panArea);
auto typeArea = area2.withSizeKeepingCentre(120, 100);
typeLabel.setBounds(typeArea.removeFromTop(20));
typeCombo.setBounds(typeArea.removeFromTop(60).withSizeKeepingCentre(120, 24));
area.removeFromTop(12);
}
| 3,479
|
C++
|
.cpp
| 69
| 46.188406
| 146
| 0.702455
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,609
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_24_Panner/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String panSliderValueToText(float value) {
return String(value, 2) + String(" L<>R");
}
static float panSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("pan"), String("Pan"), String(),
NormalisableRange<float>(0.0f, 1.0f, 0.01f, 1.f),
0.5f, panSliderValueToText, panSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("type"), String("Type"), String(),
NormalisableRange<float>(0.0f, 2.0f, 1.f, 1.0f),
0.0f, nullptr, nullptr));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_24_pannerAudioProcessor::Plugex_24_pannerAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
panParameter = parameters.getRawParameterValue("pan");
typeParameter = parameters.getRawParameterValue("type");
}
Plugex_24_pannerAudioProcessor::~Plugex_24_pannerAudioProcessor()
{
}
//==============================================================================
const String Plugex_24_pannerAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_24_pannerAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_24_pannerAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_24_pannerAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_24_pannerAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_24_pannerAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_24_pannerAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_24_pannerAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_24_pannerAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_24_pannerAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_24_pannerAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
panSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
panSmoothed.setCurrentAndTargetValue(*panParameter);
}
void Plugex_24_pannerAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_24_pannerAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_24_pannerAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
panSmoothed.setTargetValue(*panParameter);
if (totalNumOutputChannels < 2) {
return;
}
for (int i = 0; i < buffer.getNumSamples(); i++) {
float pan = panSmoothed.getNextValue();
float sumValue = 0.0f;
if (totalNumInputChannels == 1) {
sumValue = buffer.getWritePointer(0)[i];
} else {
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer (channel);
sumValue += channelData[i];
}
}
auto* channelDataL = buffer.getWritePointer(0);
auto* channelDataR = buffer.getWritePointer(1);
if (*typeParameter == 0.f) {
channelDataL[i] = sumValue * (1.f - pan);
channelDataR[i] = sumValue * pan;
} else if (*typeParameter == 0.f) {
channelDataL[i] = sumValue * sqrtf(1.f - pan);
channelDataR[i] = sumValue * sqrtf(pan);
} else {
channelDataL[i] = sumValue * cosf(pan * M_PI / 2.f);
channelDataR[i] = sumValue * sinf(pan * M_PI / 2.f);
}
}
}
//==============================================================================
bool Plugex_24_pannerAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_24_pannerAudioProcessor::createEditor()
{
return new Plugex_24_pannerAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_24_pannerAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_24_pannerAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_24_pannerAudioProcessor();
}
| 7,775
|
C++
|
.cpp
| 199
| 33.361809
| 104
| 0.634626
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,610
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_28_Gate/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_28_gateAudioProcessorEditor::Plugex_28_gateAudioProcessorEditor (Plugex_28_gateAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("grey");
title.setText("Plugex - 28 - Noise Gate", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
threshLabel.setText("Threshold", NotificationType::dontSendNotification);
threshLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&threshLabel);
threshKnob.setLookAndFeel(&plugexLookAndFeel);
threshKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
threshKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&threshKnob);
threshAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "thresh", threshKnob));
risetimeLabel.setText("Rise TIme", NotificationType::dontSendNotification);
risetimeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&risetimeLabel);
risetimeKnob.setLookAndFeel(&plugexLookAndFeel);
risetimeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
risetimeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&risetimeKnob);
risetimeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "risetime", risetimeKnob));
falltimeLabel.setText("Fall Time", NotificationType::dontSendNotification);
falltimeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&falltimeLabel);
falltimeKnob.setLookAndFeel(&plugexLookAndFeel);
falltimeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
falltimeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&falltimeKnob);
falltimeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "falltime", falltimeKnob));
lookaheadLabel.setText("Look Ahead", NotificationType::dontSendNotification);
lookaheadLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&lookaheadLabel);
lookaheadKnob.setLookAndFeel(&plugexLookAndFeel);
lookaheadKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
lookaheadKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&lookaheadKnob);
lookaheadAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lookahead", lookaheadKnob));
}
Plugex_28_gateAudioProcessorEditor::~Plugex_28_gateAudioProcessorEditor()
{
threshKnob.setLookAndFeel(nullptr);
risetimeKnob.setLookAndFeel(nullptr);
falltimeKnob.setLookAndFeel(nullptr);
lookaheadKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_28_gateAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_28_gateAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area1 = area.removeFromTop(100);
auto threshArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
threshLabel.setBounds(threshArea.removeFromTop(20));
threshKnob.setBounds(threshArea);
auto risetimeArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
risetimeLabel.setBounds(risetimeArea.removeFromTop(20));
risetimeKnob.setBounds(risetimeArea);
auto falltimeArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
falltimeLabel.setBounds(falltimeArea.removeFromTop(20));
falltimeKnob.setBounds(falltimeArea);
auto lookaheadArea = area1.withSizeKeepingCentre(80, 100);
lookaheadLabel.setBounds(lookaheadArea.removeFromTop(20));
lookaheadKnob.setBounds(lookaheadArea);
area.removeFromTop(12);
}
| 5,154
|
C++
|
.cpp
| 93
| 50.903226
| 140
| 0.746269
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,611
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_28_Gate/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String threshSliderValueToText(float value) {
return String(value, 2) + String(" dB");
}
static float threshSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String risetimeSliderValueToText(float value) {
return String(value, 2) + String(" ms");
}
static float risetimeSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String lookaheadSliderValueToText(float value) {
return String(value, 2) + String(" ms");
}
static float lookaheadSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("thresh"), String("Tresh"), String(),
NormalisableRange<float>(-90.0f, 0.0f, 0.01f, 1.0f),
-60.0f, threshSliderValueToText, threshSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("risetime"), String("Risetime"), String(),
NormalisableRange<float>(0.01f, 500.0f, 0.01f, 0.3f),
5.0f, risetimeSliderValueToText, risetimeSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("falltime"), String("Falltime"), String(),
NormalisableRange<float>(0.01f, 500.0f, 0.01f, 0.3f),
10.0f, risetimeSliderValueToText, risetimeSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("lookahead"), String("LookAhead"), String(),
NormalisableRange<float>(0.01f, 10.0f, 0.01f, 1.0f),
5.0f, lookaheadSliderValueToText, lookaheadSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_28_gateAudioProcessor::Plugex_28_gateAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
threshParameter = parameters.getRawParameterValue("thresh");
risetimeParameter = parameters.getRawParameterValue("risetime");
falltimeParameter = parameters.getRawParameterValue("falltime");
lookaheadParameter = parameters.getRawParameterValue("lookahead");
}
Plugex_28_gateAudioProcessor::~Plugex_28_gateAudioProcessor()
{
}
//==============================================================================
const String Plugex_28_gateAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_28_gateAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_28_gateAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_28_gateAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_28_gateAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_28_gateAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_28_gateAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_28_gateAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_28_gateAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_28_gateAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_28_gateAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
threshSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
threshSmoothed.setCurrentAndTargetValue(*threshParameter);
risetimeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
risetimeSmoothed.setCurrentAndTargetValue(*risetimeParameter);
falltimeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
falltimeSmoothed.setCurrentAndTargetValue(*falltimeParameter);
lookaheadSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
lookaheadSmoothed.setCurrentAndTargetValue(*lookaheadParameter);
for (int channel = 0; channel < 2; channel++) {
lowpassFilter[channel].setup(currentSampleRate);
gateFilter[channel].setup(currentSampleRate);
lookaheadDelay[channel].setup(0.015, currentSampleRate);
}
}
void Plugex_28_gateAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_28_gateAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_28_gateAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
threshSmoothed.setTargetValue(*threshParameter);
risetimeSmoothed.setTargetValue(*risetimeParameter);
falltimeSmoothed.setTargetValue(*falltimeParameter);
lookaheadSmoothed.setTargetValue(*lookaheadParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float thresh = powf(10.0f, threshSmoothed.getNextValue() * 0.05f);
float risetime = risetimeSmoothed.getNextValue() * 0.001f;
float falltime = falltimeSmoothed.getNextValue() * 0.001f;
float lookahead = lookaheadSmoothed.getNextValue() * 0.001f;
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer (channel);
float rectified = channelData[i] < 0.0f ? -channelData[i] : channelData[i];
lowpassFilter[channel].setFreq(10.0f);
float follower = lowpassFilter[channel].process(rectified);
float gate;
if (follower >= thresh) {
gateFilter[channel].setFreq(1.0f / risetime);
gate = gateFilter[channel].process(1.0f);
} else {
gateFilter[channel].setFreq(1.0f / falltime);
gate = gateFilter[channel].process(0.0f);
}
float delayedSample = lookaheadDelay[channel].read(lookahead);
lookaheadDelay[channel].write(channelData[i]);
channelData[i] = delayedSample * gate;
}
}
}
//==============================================================================
bool Plugex_28_gateAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_28_gateAudioProcessor::createEditor()
{
return new Plugex_28_gateAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_28_gateAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_28_gateAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_28_gateAudioProcessor();
}
| 10,173
|
C++
|
.cpp
| 231
| 36.865801
| 116
| 0.648013
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,612
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_01_AmplitudeLinear/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_01_amplitudeLinearAudioProcessorEditor::Plugex_01_amplitudeLinearAudioProcessorEditor (Plugex_01_amplitudeLinearAudioProcessor& p,
AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("blue");
title.setText("Plugex - 01 - Amplitude Linear", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
gainLabel.setText("Gain", NotificationType::dontSendNotification);
gainLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&gainLabel);
gainKnob.setLookAndFeel(&plugexLookAndFeel);
gainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
gainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&gainKnob);
gainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain", gainKnob));
}
Plugex_01_amplitudeLinearAudioProcessorEditor::~Plugex_01_amplitudeLinearAudioProcessorEditor()
{
}
//==============================================================================
void Plugex_01_amplitudeLinearAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_01_amplitudeLinearAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto gainArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100);
gainLabel.setBounds(gainArea.removeFromTop(20));
gainKnob.setBounds(gainArea);
area.removeFromTop(12);
}
| 2,557
|
C++
|
.cpp
| 51
| 44.529412
| 137
| 0.659008
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,614
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_27_AutoWah/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_27_autoWahAudioProcessorEditor::Plugex_27_autoWahAudioProcessorEditor (Plugex_27_autoWahAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("grey");
title.setText("Plugex - 27 - Auto-Wah", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
responseLabel.setText("Speediness", NotificationType::dontSendNotification);
responseLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&responseLabel);
responseKnob.setLookAndFeel(&plugexLookAndFeel);
responseKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
responseKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&responseKnob);
responseAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "response", responseKnob));
maxFreqLabel.setText("Max Freq", NotificationType::dontSendNotification);
maxFreqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&maxFreqLabel);
maxFreqKnob.setLookAndFeel(&plugexLookAndFeel);
maxFreqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
maxFreqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&maxFreqKnob);
maxFreqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "maxFreq", maxFreqKnob));
qLabel.setText("Filter Q", NotificationType::dontSendNotification);
qLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&qLabel);
qKnob.setLookAndFeel(&plugexLookAndFeel);
qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&qKnob);
qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob));
}
Plugex_27_autoWahAudioProcessorEditor::~Plugex_27_autoWahAudioProcessorEditor()
{
responseKnob.setLookAndFeel(nullptr);
maxFreqKnob.setLookAndFeel(nullptr);
qKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_27_autoWahAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_27_autoWahAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto responseArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
responseLabel.setBounds(responseArea.removeFromTop(20));
responseKnob.setBounds(responseArea);
auto maxFreqArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
maxFreqLabel.setBounds(maxFreqArea.removeFromTop(20));
maxFreqKnob.setBounds(maxFreqArea);
auto qArea = area2.withSizeKeepingCentre(80, 100);
qLabel.setBounds(qArea.removeFromTop(20));
qKnob.setBounds(qArea);
area.removeFromTop(12);
}
| 4,268
|
C++
|
.cpp
| 81
| 48.308642
| 149
| 0.727316
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,616
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_07_ButterworthLP/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_07_butterworthLpAudioProcessorEditor::Plugex_07_butterworthLpAudioProcessorEditor (Plugex_07_butterworthLpAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("green");
title.setText("Plugex - 07 - Butterworth Lowpass", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
}
Plugex_07_butterworthLpAudioProcessorEditor::~Plugex_07_butterworthLpAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_07_butterworthLpAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_07_butterworthLpAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto freqArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
area.removeFromTop(12);
}
| 2,743
|
C++
|
.cpp
| 55
| 45.927273
| 167
| 0.68818
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,617
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_07_ButterworthLP/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f),
1000.0f, freqSliderValueToText, freqSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_07_butterworthLpAudioProcessor::Plugex_07_butterworthLpAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
}
Plugex_07_butterworthLpAudioProcessor::~Plugex_07_butterworthLpAudioProcessor()
{
}
//==============================================================================
const String Plugex_07_butterworthLpAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_07_butterworthLpAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_07_butterworthLpAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_07_butterworthLpAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_07_butterworthLpAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_07_butterworthLpAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_07_butterworthLpAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_07_butterworthLpAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_07_butterworthLpAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_07_butterworthLpAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_07_butterworthLpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
memset(lastInputSample1, 0, sizeof(float) * 2);
memset(lastInputSample2, 0, sizeof(float) * 2);
memset(lastFilteredSample1, 0, sizeof(float) * 2);
memset(lastFilteredSample2, 0, sizeof(float) * 2);
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
}
void Plugex_07_butterworthLpAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_07_butterworthLpAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_07_butterworthLpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float cf = freqSmoothed.getNextValue();
float sqrt2 = sqrtf(2.0f);
float c = 1.0f / tanf(M_PI / currentSampleRate * cf);
float c2 = c * c;
float a0 = 1.0f / (1.0f + sqrt2 * c + c2);
float a1 = 2.0f * a0;
float a2 = a0;
float b1 = a1 * (1.0f - c2);
float b2 = a0 * (1.0f - sqrt2 * c + c2);
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer (channel);
float filtered = a0 * channelData[i] + a1 * lastInputSample1[channel] + a2 * lastInputSample2[channel] -
b1 * lastFilteredSample1[channel] - b2 * lastFilteredSample2[channel];
lastInputSample2[channel] = lastInputSample1[channel];
lastInputSample1[channel] = channelData[i];
lastFilteredSample2[channel] = lastFilteredSample1[channel];
channelData[i] = lastFilteredSample1[channel] = filtered;
}
}
}
//==============================================================================
bool Plugex_07_butterworthLpAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_07_butterworthLpAudioProcessor::createEditor()
{
return new Plugex_07_butterworthLpAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_07_butterworthLpAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_07_butterworthLpAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_07_butterworthLpAudioProcessor();
}
| 8,021
|
C++
|
.cpp
| 195
| 35.169231
| 117
| 0.646452
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,618
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_15_ArctanDistortion/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_15_arctanDistortionAudioProcessorEditor::Plugex_15_arctanDistortionAudioProcessorEditor (Plugex_15_arctanDistortionAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("red");
title.setText("Plugex - 15 - Arctan Distortion", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
driveLabel.setText("Drive", NotificationType::dontSendNotification);
driveLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&driveLabel);
driveKnob.setLookAndFeel(&plugexLookAndFeel);
driveKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
driveKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&driveKnob);
driveAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "drive", driveKnob));
cutoffLabel.setText("Cutoff", NotificationType::dontSendNotification);
cutoffLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&cutoffLabel);
cutoffKnob.setLookAndFeel(&plugexLookAndFeel);
cutoffKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
cutoffKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&cutoffKnob);
cutoffAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "cutoff", cutoffKnob));
}
Plugex_15_arctanDistortionAudioProcessorEditor::~Plugex_15_arctanDistortionAudioProcessorEditor()
{
driveKnob.setLookAndFeel(nullptr);
cutoffKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_15_arctanDistortionAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_15_arctanDistortionAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto driveArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
driveLabel.setBounds(driveArea.removeFromTop(20));
driveKnob.setBounds(driveArea);
auto cutoffArea = area2.withSizeKeepingCentre(80, 100);
cutoffLabel.setBounds(cutoffArea.removeFromTop(20));
cutoffKnob.setBounds(cutoffArea);
area.removeFromTop(12);
}
| 3,591
|
C++
|
.cpp
| 69
| 47.826087
| 176
| 0.716371
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,620
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_09_ButterworthBP/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_09_butterworthBpAudioProcessorEditor::Plugex_09_butterworthBpAudioProcessorEditor (Plugex_09_butterworthBpAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("green");
title.setText("Plugex - 09 - Butterworth Bandpass", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
qLabel.setText("Resonance", NotificationType::dontSendNotification);
qLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&qLabel);
qKnob.setLookAndFeel(&plugexLookAndFeel);
qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&qKnob);
qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob));
}
Plugex_09_butterworthBpAudioProcessorEditor::~Plugex_09_butterworthBpAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
qKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_09_butterworthBpAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_09_butterworthBpAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto freqArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
auto qArea = area2.withSizeKeepingCentre(80, 100);
qLabel.setBounds(qArea.removeFromTop(20));
qKnob.setBounds(qArea);
area.removeFromTop(12);
}
| 3,482
|
C++
|
.cpp
| 69
| 46.231884
| 167
| 0.706942
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,621
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_09_ButterworthBP/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String qSliderValueToText(float value) {
return String(value, 2) + String(" Q");
}
static float qSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f),
1000.0f, freqSliderValueToText, freqSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("q"), String("Q"), String(),
NormalisableRange<float>(0.5f, 50.0f, 0.01f, 0.5f),
1.0f, qSliderValueToText, qSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_09_butterworthBpAudioProcessor::Plugex_09_butterworthBpAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
qParameter = parameters.getRawParameterValue("q");
}
Plugex_09_butterworthBpAudioProcessor::~Plugex_09_butterworthBpAudioProcessor()
{
}
//==============================================================================
const String Plugex_09_butterworthBpAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_09_butterworthBpAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_09_butterworthBpAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_09_butterworthBpAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_09_butterworthBpAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_09_butterworthBpAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_09_butterworthBpAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_09_butterworthBpAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_09_butterworthBpAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_09_butterworthBpAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_09_butterworthBpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
memset(lastInputSample1, 0, sizeof(float) * 2);
memset(lastInputSample2, 0, sizeof(float) * 2);
memset(lastFilteredSample1, 0, sizeof(float) * 2);
memset(lastFilteredSample2, 0, sizeof(float) * 2);
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
qSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
qSmoothed.setCurrentAndTargetValue(*qParameter);
}
void Plugex_09_butterworthBpAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_09_butterworthBpAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_09_butterworthBpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
qSmoothed.setTargetValue(*qParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float cf = freqSmoothed.getNextValue();
float bw = cf / qSmoothed.getNextValue();
float piOnSr = M_PI / currentSampleRate;
float c = 1.0f / tanf(piOnSr * bw);
float d = 2.0f * cosf(2.0f * piOnSr * cf);
float a0 = 1.0f / (1.0f + c);
float a2 = -a0;
float b1 = a2 * c * d;
float b2 = a0 * (c - 1.0f);
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer (channel);
float filtered = a0 * channelData[i] + a2 * lastInputSample2[channel] -
b1 * lastFilteredSample1[channel] - b2 * lastFilteredSample2[channel];
lastInputSample2[channel] = lastInputSample1[channel];
lastInputSample1[channel] = channelData[i];
lastFilteredSample2[channel] = lastFilteredSample1[channel];
channelData[i] = lastFilteredSample1[channel] = filtered;
}
}
}
//==============================================================================
bool Plugex_09_butterworthBpAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_09_butterworthBpAudioProcessor::createEditor()
{
return new Plugex_09_butterworthBpAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_09_butterworthBpAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_09_butterworthBpAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_09_butterworthBpAudioProcessor();
}
| 8,693
|
C++
|
.cpp
| 208
| 35.471154
| 112
| 0.646478
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,622
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_18_Delay/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_18_delayAudioProcessorEditor::Plugex_18_delayAudioProcessorEditor (Plugex_18_delayAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("orange");
title.setText("Plugex - 18 - Delay Line", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
timeLabel.setText("Delay Time", NotificationType::dontSendNotification);
timeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&timeLabel);
timeKnob.setLookAndFeel(&plugexLookAndFeel);
timeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
timeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&timeKnob);
timeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "time", timeKnob));
feedbackLabel.setText("Feedback", NotificationType::dontSendNotification);
feedbackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&feedbackLabel);
feedbackKnob.setLookAndFeel(&plugexLookAndFeel);
feedbackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
feedbackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&feedbackKnob);
feedbackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "feedback", feedbackKnob));
balanceLabel.setText("Balance", NotificationType::dontSendNotification);
balanceLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&balanceLabel);
balanceKnob.setLookAndFeel(&plugexLookAndFeel);
balanceKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
balanceKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&balanceKnob);
balanceAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "balance", balanceKnob));
}
Plugex_18_delayAudioProcessorEditor::~Plugex_18_delayAudioProcessorEditor()
{
timeKnob.setLookAndFeel(nullptr);
feedbackKnob.setLookAndFeel(nullptr);
balanceKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_18_delayAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_18_delayAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto timeArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
timeLabel.setBounds(timeArea.removeFromTop(20));
timeKnob.setBounds(timeArea);
auto feedbackArea = area2.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100);
feedbackLabel.setBounds(feedbackArea.removeFromTop(20));
feedbackKnob.setBounds(feedbackArea);
auto balanceArea = area2.withSizeKeepingCentre(80, 100);
balanceLabel.setBounds(balanceArea.removeFromTop(20));
balanceKnob.setBounds(balanceArea);
area.removeFromTop(12);
}
| 4,305
|
C++
|
.cpp
| 81
| 48.765432
| 143
| 0.729962
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,623
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_18_Delay/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String timeSliderValueToText(float value) {
return String(value, 2) + String(" ms");
}
static float timeSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String feedbackSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float feedbackSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("time"), String("Time"), String(),
NormalisableRange<float>(0.01f, 1000.0f, 0.01f, 0.3f),
100.0f, timeSliderValueToText, timeSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("feedback"), String("Feedback"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
0.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("balance"), String("Balance"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
50.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_18_delayAudioProcessor::Plugex_18_delayAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
timeParameter = parameters.getRawParameterValue("time");
feedbackParameter = parameters.getRawParameterValue("feedback");
balanceParameter = parameters.getRawParameterValue("balance");
}
Plugex_18_delayAudioProcessor::~Plugex_18_delayAudioProcessor()
{
}
//==============================================================================
const String Plugex_18_delayAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_18_delayAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_18_delayAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_18_delayAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_18_delayAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_18_delayAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_18_delayAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_18_delayAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_18_delayAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_18_delayAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_18_delayAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
writePosition = 0;
timeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
timeSmoothed.setCurrentAndTargetValue(*timeParameter);
feedbackSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
feedbackSmoothed.setCurrentAndTargetValue(*feedbackParameter);
balanceSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
balanceSmoothed.setCurrentAndTargetValue(*balanceParameter);
for (int channel = 0; channel < 2; channel++) {
delayLine[channel].reset( new float[static_cast<int>(currentSampleRate) + 1]);
for (int i = 0; i < static_cast<int>(currentSampleRate) + 1; i++) {
delayLine[channel][i] = 0.0f;
}
}
}
void Plugex_18_delayAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_18_delayAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_18_delayAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
timeSmoothed.setTargetValue(*timeParameter);
feedbackSmoothed.setTargetValue(*feedbackParameter);
balanceSmoothed.setTargetValue(*balanceParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float currentTime = timeSmoothed.getNextValue();
float currentFeedback = feedbackSmoothed.getNextValue() * 0.01;
float currentBalance = balanceSmoothed.getNextValue() * 0.01;
float delayTimeInSamples = currentTime * 0.001 * currentSampleRate;
float readPosition = writePosition - delayTimeInSamples;
if (readPosition < 0) {
readPosition += currentSampleRate;
} else if (readPosition >= currentSampleRate) {
readPosition -= currentSampleRate;
}
int readPosIntegerPart = static_cast<int>(readPosition);
float readPosFloatPart = readPosition - readPosIntegerPart;
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float previous = delayLine[channel][readPosIntegerPart];
float next = delayLine[channel][readPosIntegerPart + 1];
float sampleRead = previous + (next - previous) * readPosFloatPart;
auto* channelData = buffer.getWritePointer (channel);
delayLine[channel][writePosition] = channelData[i] + sampleRead * currentFeedback;
if (writePosition == 0) {
delayLine[channel][currentSampleRate] = delayLine[channel][0];
}
channelData[i] = channelData[i] + (sampleRead - channelData[i]) * currentBalance;
}
if (writePosition++ == currentSampleRate) {
writePosition = 0;
}
}
}
//==============================================================================
bool Plugex_18_delayAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_18_delayAudioProcessor::createEditor()
{
return new Plugex_18_delayAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_18_delayAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_18_delayAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_18_delayAudioProcessor();
}
| 9,733
|
C++
|
.cpp
| 227
| 36.030837
| 115
| 0.645325
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,624
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_14_Rectifier/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_14_rectifierAudioProcessorEditor::Plugex_14_rectifierAudioProcessorEditor (Plugex_14_rectifierAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("red");
title.setText("Plugex - 14 - Wave Rectifier", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
percentLabel.setText("Percentage", NotificationType::dontSendNotification);
percentLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&percentLabel);
percentKnob.setLookAndFeel(&plugexLookAndFeel);
percentKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
percentKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&percentKnob);
percentAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "percent", percentKnob));
cutoffLabel.setText("Cutoff", NotificationType::dontSendNotification);
cutoffLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&cutoffLabel);
cutoffKnob.setLookAndFeel(&plugexLookAndFeel);
cutoffKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
cutoffKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&cutoffKnob);
cutoffAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "cutoff", cutoffKnob));
}
Plugex_14_rectifierAudioProcessorEditor::~Plugex_14_rectifierAudioProcessorEditor()
{
percentKnob.setLookAndFeel(nullptr);
cutoffKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_14_rectifierAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_14_rectifierAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto percentArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
percentLabel.setBounds(percentArea.removeFromTop(20));
percentKnob.setBounds(percentArea);
auto cutoffArea = area2.withSizeKeepingCentre(80, 100);
cutoffLabel.setBounds(cutoffArea.removeFromTop(20));
cutoffKnob.setBounds(cutoffArea);
area.removeFromTop(12);
}
| 3,576
|
C++
|
.cpp
| 69
| 47.608696
| 155
| 0.715148
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,626
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_03_AmplitudeLFO/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_03_amplitudeLfoAudioProcessorEditor::Plugex_03_amplitudeLfoAudioProcessorEditor (Plugex_03_amplitudeLfoAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("blue");
title.setText("Plugex - 03 - Oscillating Amplitude", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Mod Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
depthLabel.setText("depth", NotificationType::dontSendNotification);
depthLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&depthLabel);
depthKnob.setLookAndFeel(&plugexLookAndFeel);
depthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
depthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&depthKnob);
depthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "depth", depthKnob));
}
Plugex_03_amplitudeLfoAudioProcessorEditor::~Plugex_03_amplitudeLfoAudioProcessorEditor()
{
}
//==============================================================================
void Plugex_03_amplitudeLfoAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_03_amplitudeLfoAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto freqArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
auto depthArea = area2.withSizeKeepingCentre(80, 100);
depthLabel.setBounds(depthArea.removeFromTop(20));
depthKnob.setBounds(depthArea);
area.removeFromTop(12);
}
| 3,207
|
C++
|
.cpp
| 63
| 46.809524
| 164
| 0.709243
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,627
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_03_AmplitudeLFO/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String depthSliderValueToText(float value) {
return String(value, 2) + String(" x");
}
static float depthSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(0.001f, 20.0f, 0.001f, 0.3f),
1.0f, freqSliderValueToText, freqSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("depth"), String("Depth"), String(),
NormalisableRange<float>(0.0f, 1.0f),
0.0f, depthSliderValueToText, depthSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_03_amplitudeLfoAudioProcessor::Plugex_03_amplitudeLfoAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
depthParameter = parameters.getRawParameterValue("depth");
}
Plugex_03_amplitudeLfoAudioProcessor::~Plugex_03_amplitudeLfoAudioProcessor()
{
}
//==============================================================================
const String Plugex_03_amplitudeLfoAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_03_amplitudeLfoAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_03_amplitudeLfoAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_03_amplitudeLfoAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_03_amplitudeLfoAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_03_amplitudeLfoAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_03_amplitudeLfoAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_03_amplitudeLfoAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_03_amplitudeLfoAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_03_amplitudeLfoAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_03_amplitudeLfoAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
depthSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
depthSmoothed.setCurrentAndTargetValue(*depthParameter);
lfoPhase = 0.0f;
lfoInc = *freqParameter / sampleRate;
}
void Plugex_03_amplitudeLfoAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_03_amplitudeLfoAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_03_amplitudeLfoAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
depthSmoothed.setTargetValue(*depthParameter);
for (int i = 0; i < buffer.getNumSamples(); i++) {
lfoInc = freqSmoothed.getNextValue() / currentSampleRate;
lfoPhase += lfoInc;
if (lfoPhase >= 1.0f) {
lfoPhase -= 1.0f;
}
float lfoValue = 1.0f - (sinf(M_PI * 2.0f * lfoPhase) * 0.5 + 0.5) * depthSmoothed.getNextValue();
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer (channel);
channelData[i] *= lfoValue;
}
}
}
//==============================================================================
bool Plugex_03_amplitudeLfoAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_03_amplitudeLfoAudioProcessor::createEditor()
{
return new Plugex_03_amplitudeLfoAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_03_amplitudeLfoAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_03_amplitudeLfoAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_03_amplitudeLfoAudioProcessor();
}
| 8,022
|
C++
|
.cpp
| 196
| 34.928571
| 111
| 0.649652
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,628
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_41_Resampler/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_41_resamplerAudioProcessorEditor::Plugex_41_resamplerAudioProcessorEditor (Plugex_41_resamplerAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("pink");
title.setText("Plugex - 41 - Resampler", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
srscaleLabel.setText("SR Scale", NotificationType::dontSendNotification);
srscaleLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&srscaleLabel);
srscaleKnob.setLookAndFeel(&plugexLookAndFeel);
srscaleKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
srscaleKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&srscaleKnob);
srscaleAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "srscale", srscaleKnob));
bitdepthLabel.setText("Bit Depth", NotificationType::dontSendNotification);
bitdepthLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&bitdepthLabel);
bitdepthKnob.setLookAndFeel(&plugexLookAndFeel);
bitdepthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
bitdepthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&bitdepthKnob);
bitdepthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "bitdepth", bitdepthKnob));
}
Plugex_41_resamplerAudioProcessorEditor::~Plugex_41_resamplerAudioProcessorEditor()
{
srscaleKnob.setLookAndFeel(nullptr);
bitdepthKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_41_resamplerAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_41_resamplerAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto srscaleArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
srscaleLabel.setBounds(srscaleArea.removeFromTop(20));
srscaleKnob.setBounds(srscaleArea);
auto bitdepthArea = area2.withSizeKeepingCentre(80, 100);
bitdepthLabel.setBounds(bitdepthArea.removeFromTop(20));
bitdepthKnob.setBounds(bitdepthArea);
area.removeFromTop(12);
}
| 3,605
|
C++
|
.cpp
| 69
| 48.028986
| 155
| 0.717218
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,630
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_22_Harmonizer/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_22_harmonizerAudioProcessorEditor::Plugex_22_harmonizerAudioProcessorEditor (Plugex_22_harmonizerAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("orange");
title.setText("Plugex - 22 - Harmonizer", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
transpoLabel.setText("Tranposition", NotificationType::dontSendNotification);
transpoLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&transpoLabel);
transpoKnob.setLookAndFeel(&plugexLookAndFeel);
transpoKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
transpoKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&transpoKnob);
transpoAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "transpo", transpoKnob));
feedbackLabel.setText("Feedback", NotificationType::dontSendNotification);
feedbackLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&feedbackLabel);
feedbackKnob.setLookAndFeel(&plugexLookAndFeel);
feedbackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
feedbackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&feedbackKnob);
feedbackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "feedback", feedbackKnob));
winsizeLabel.setText("winsize", NotificationType::dontSendNotification);
winsizeLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&winsizeLabel);
winsizeKnob.setLookAndFeel(&plugexLookAndFeel);
winsizeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
winsizeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&winsizeKnob);
winsizeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "winsize", winsizeKnob));
balanceLabel.setText("Balance", NotificationType::dontSendNotification);
balanceLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&balanceLabel);
balanceKnob.setLookAndFeel(&plugexLookAndFeel);
balanceKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
balanceKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&balanceKnob);
balanceAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "balance", balanceKnob));
}
Plugex_22_harmonizerAudioProcessorEditor::~Plugex_22_harmonizerAudioProcessorEditor()
{
transpoKnob.setLookAndFeel(nullptr);
feedbackKnob.setLookAndFeel(nullptr);
winsizeKnob.setLookAndFeel(nullptr);
balanceKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_22_harmonizerAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_22_harmonizerAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto transpoArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
transpoLabel.setBounds(transpoArea.removeFromTop(20));
transpoKnob.setBounds(transpoArea);
auto feedbackArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
feedbackLabel.setBounds(feedbackArea.removeFromTop(20));
feedbackKnob.setBounds(feedbackArea);
auto winsizeArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100);
winsizeLabel.setBounds(winsizeArea.removeFromTop(20));
winsizeKnob.setBounds(winsizeArea);
auto balanceArea = area2.withSizeKeepingCentre(80, 100);
balanceLabel.setBounds(balanceArea.removeFromTop(20));
balanceKnob.setBounds(balanceArea);
area.removeFromTop(12);
}
| 5,162
|
C++
|
.cpp
| 93
| 51
| 158
| 0.747665
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,631
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_22_Harmonizer/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String transpoSliderValueToText(float value) {
return String(value, 2) + String(" semi");
}
static float transpoSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String feedbackSliderValueToText(float value) {
return String(value, 2) + String(" %");
}
static float feedbackSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String winsizeSliderValueToText(float value) {
return String(value, 2) + String(" ms");
}
static float winsizeSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("transpo"), String("Transpo"), String(),
NormalisableRange<float>(-24.0f, 24.0f, 0.01f, 1.0f),
-7.0f, transpoSliderValueToText, transpoSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("feedback"), String("Feedback"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
0.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("winsize"), String("Winsize"), String(),
NormalisableRange<float>(10.0f, 200.0f, 0.01f, 1.0f),
100.0f, winsizeSliderValueToText, winsizeSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("balance"), String("Balance"), String(),
NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f),
50.0f, feedbackSliderValueToText, feedbackSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_22_harmonizerAudioProcessor::Plugex_22_harmonizerAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
transpoParameter = parameters.getRawParameterValue("transpo");
feedbackParameter = parameters.getRawParameterValue("feedback");
winsizeParameter = parameters.getRawParameterValue("winsize");
balanceParameter = parameters.getRawParameterValue("balance");
}
Plugex_22_harmonizerAudioProcessor::~Plugex_22_harmonizerAudioProcessor()
{
}
//==============================================================================
const String Plugex_22_harmonizerAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_22_harmonizerAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_22_harmonizerAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_22_harmonizerAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_22_harmonizerAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_22_harmonizerAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_22_harmonizerAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_22_harmonizerAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_22_harmonizerAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_22_harmonizerAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_22_harmonizerAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
runningPhase = 0.0f;
transpoSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
transpoSmoothed.setCurrentAndTargetValue(*transpoParameter);
feedbackSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
feedbackSmoothed.setCurrentAndTargetValue(*feedbackParameter);
winsizeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
winsizeSmoothed.setCurrentAndTargetValue(*winsizeParameter);
balanceSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
balanceSmoothed.setCurrentAndTargetValue(*balanceParameter);
for (int channel = 0; channel < 2; channel++) {
delayLine[channel].setup(0.25f, currentSampleRate);
dcFilterLastInput[channel] = dcFilterLastOutput[channel] = 0.0f;
}
}
void Plugex_22_harmonizerAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_22_harmonizerAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_22_harmonizerAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
transpoSmoothed.setTargetValue(*transpoParameter);
feedbackSmoothed.setTargetValue(*feedbackParameter);
winsizeSmoothed.setTargetValue(*winsizeParameter);
balanceSmoothed.setTargetValue(*balanceParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float currentTranspo = transpoSmoothed.getNextValue();
float currentFeedback = feedbackSmoothed.getNextValue() * 0.01;
float currentWinsize = winsizeSmoothed.getNextValue() * 0.001;
float currentBalance = balanceSmoothed.getNextValue() * 0.01;
float ratio = powf(2.0f, currentTranspo / 12.0f);
float rate = (ratio - 1.0f) / currentWinsize;
float inc = -rate / currentSampleRate;
float firstOverlapAmp = sinf(runningPhase * M_PI);
float secondOverlapAmp = sinf(fmod(runningPhase + 0.5f, 1.0f) * M_PI);
float firstOverlapDelay = runningPhase * currentWinsize;
float secondOverlapDelay = fmod(runningPhase + 0.5f, 1.0f) * currentWinsize;
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float sampleRead = delayLine[channel].read(firstOverlapDelay) * firstOverlapAmp;
sampleRead += delayLine[channel].read(secondOverlapDelay) * secondOverlapAmp;
auto* channelData = buffer.getWritePointer (channel);
dcFilterLastOutput[channel] = sampleRead - dcFilterLastInput[channel] + 0.995 * dcFilterLastOutput[channel];
dcFilterLastInput[channel] = sampleRead;
delayLine[channel].write(channelData[i] + dcFilterLastOutput[channel] * currentFeedback);
channelData[i] = channelData[i] + (sampleRead - channelData[i]) * currentBalance;
}
runningPhase += inc;
if (runningPhase < 0) {
runningPhase += 1.0f;
} else if (runningPhase >= 1.0f) {
runningPhase -= 1.0f;
}
}
}
//==============================================================================
bool Plugex_22_harmonizerAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_22_harmonizerAudioProcessor::createEditor()
{
return new Plugex_22_harmonizerAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_22_harmonizerAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_22_harmonizerAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_22_harmonizerAudioProcessor();
}
| 10,758
|
C++
|
.cpp
| 238
| 38.168067
| 120
| 0.657373
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,632
|
BandLimitedOsc.cpp
|
belangeo_plugex/common/BandLimitedOsc.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2020
*
*******************************************************************************/
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include "BandLimitedOsc.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
BandLimitedOsc::BandLimitedOsc() {
m_wavetype = 2;
m_freq = 1.f;
m_sharp = 0.f;
srand((unsigned int)time(0));
m_sah_last_value = 0.f;
m_sah_current_value = (rand() / (float)RAND_MAX) * 2.f - 1.f;
}
void BandLimitedOsc::setup(float sampleRate) {
m_sampleRate = sampleRate;
m_oneOverSr = 1.f / m_sampleRate;
m_twopi = 2.f * M_PI;
m_oneOverPiOverTwo = 1.f / (M_PI / 2.f);
m_srOverFour = m_sampleRate / 4.f;
m_srOverEight = m_sampleRate / 8.f;
m_pointer_pos = m_sah_pointer_pos = 0.f;
}
BandLimitedOsc::~BandLimitedOsc() {}
void BandLimitedOsc::reset() {
m_pointer_pos = m_sah_pointer_pos = 0.f;
}
float BandLimitedOsc::_clip(float x) {
if (x < 0.f) {
x += 1.f;
} else if (x >= 1.f) {
x -= 1.f;
}
return x;
}
void BandLimitedOsc::setWavetype(int type) {
if (type != m_wavetype) {
type = type < 0 ? 0 : type > 7 ? 7 : type;
m_wavetype = type;
}
}
void BandLimitedOsc::setFreq(float freq) {
m_freq = freq < 0.00001f ? 0.00001f : freq > m_srOverFour ? m_srOverFour : freq;
}
void BandLimitedOsc::setSharp(float sharp) {
m_sharp = sharp < 0.f ? 0.f : sharp > 1.f ? 1.f : sharp;
}
float BandLimitedOsc::process() {
float v1 = 0.f, v2 = 0.f, pointer = 0.f, numh = 0.f, pos = 0.f;
float inc2 = 0.f, fade = 0.f, value = 0.f, maxHarms = 0.f;
switch (m_wavetype) {
// Sine
case 0:
value = sinf(m_twopi * m_pointer_pos);
break;
// Triangle
case 1:
maxHarms = m_srOverFour / m_freq;
if ((m_sharp * 36.f) > maxHarms)
numh = maxHarms / 36.f;
else
numh = m_sharp;
v1 = tanf(sinf(m_twopi * m_pointer_pos)) * m_oneOverPiOverTwo;
pointer = m_pointer_pos + 0.25f;
if (pointer >= 1.f)
pointer -= 1.f;
v2 = 4.f * (0.5f - fabsf(pointer - 0.5f)) - 1.f;
value = v1 + (v2 - v1) * numh;
break;
// Square
case 2:
maxHarms = m_srOverEight / m_freq;
numh = m_sharp * 46.f + 4.f;
if (numh > maxHarms)
numh = maxHarms;
value = atanf(numh * sinf(m_twopi * m_pointer_pos)) * m_oneOverPiOverTwo;
break;
// Saw
case 3:
maxHarms = m_srOverFour / m_freq;
numh = m_sharp * 46.f + 4.f;
if (numh > maxHarms)
numh = maxHarms;
pos = m_pointer_pos + 0.5f;
if (pos >= 1.f)
pos -= 1.f;
pos = pos * 2.f - 1.f;
value = -(pos - tanhf(numh * pos) / tanhf(numh));
break;
// Ramp
case 4:
maxHarms = m_srOverFour / m_freq;
numh = m_sharp * 46.f + 4.f;
if (numh > maxHarms)
numh = maxHarms;
pos = m_pointer_pos + 0.f;
if (pos >= 1.f)
pos -= 1.f;
pos = pos * 2.f - 1.f;
value = pos - tanhf(numh * pos) / tanhf(numh);
break;
// Pulse
case 5:
maxHarms = m_srOverEight / m_freq;
numh = m_sharp * 46.f + 4.f;
if (numh > maxHarms)
numh = maxHarms;
if (fmodf(numh, 2.f) == 0.f)
numh += 1.f;
value = tanf(powf(fabsf(sinf(m_twopi * m_pointer_pos)), numh));
value *= m_oneOverPiOverTwo;
break;
// Bi-Pulse
case 6:
maxHarms = (int)(m_srOverEight / m_freq);
numh = floorf(m_sharp * 46.f + 4.f);
if (numh > maxHarms)
numh = maxHarms;
if (fmodf(numh, 2.f) == 0.f)
numh += 1.f;
value = tanf(powf(sinf(m_twopi * m_pointer_pos), numh));
value *= m_oneOverPiOverTwo;
break;
// SAH
case 7:
numh = 1.f - m_sharp;
inc2 = 1.f / (1.f / (m_freq * m_oneOverSr) * numh);
if (m_pointer_pos >= 1.f) {
m_pointer_pos -= 1.f;
m_sah_pointer_pos = 0.f;
m_sah_last_value = m_sah_current_value;
m_sah_current_value = (rand() / (float)RAND_MAX) * 2.f - 1.f;
}
if (m_sah_pointer_pos < 1.f) {
fade = 0.5f * sinf(M_PI * (m_sah_pointer_pos + 0.5f)) + 0.5f;
value = m_sah_current_value + (m_sah_last_value - m_sah_current_value) * fade;
m_sah_pointer_pos += inc2;
}
else {
value = m_sah_current_value;
}
m_pointer_pos += m_freq * m_oneOverSr;
break;
default:
value = 0.f;
break;
}
if (m_wavetype < 7) {
m_pointer_pos += m_freq * m_oneOverSr;
m_pointer_pos = _clip(m_pointer_pos);
}
return value;
}
| 5,599
|
C++
|
.cpp
| 164
| 24.469512
| 95
| 0.474288
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,633
|
FFTEngine.cpp
|
belangeo_plugex/common/FFTEngine.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "FFTEngine.h"
FFTEngine::FFTEngine() {}
FFTEngine::~FFTEngine() {}
void FFTEngine::reset() {
fifoIndex = 0;
for (int overlap = 0; overlap < fftMaxOverlaps; overlap++) {
zeromem(fftData[overlap], sizeof(fftData[overlap]));
zeromem(fifo[overlap], sizeof(fifo[overlap]));
}
forwardFFT.reset( new dsp::FFT(fftOrder));
window.setup(fftSize, (Windowing::WindowType)fftWintype);
}
void FFTEngine::setOrder(int order) {
if (order == fftOrder)
return;
fftOrder = order <= fftMaxOrder ? order : fftMaxOrder;
fftSize = 1 << fftOrder;
fftHopSize = fftSize / fftOverlaps;
reset();
}
void FFTEngine::setOverlaps(int overlaps) {
if (overlaps == fftOverlaps)
return;
fftOverlaps = overlaps <= fftMaxOverlaps ? overlaps : fftMaxOverlaps;
fftHopSize = fftSize / fftOverlaps;
reset();
}
void FFTEngine::setWintype(int type) {
fftWintype = type;
window.setup(fftSize, (Windowing::WindowType)fftWintype);
}
int FFTEngine::getSize() {
return fftSize;
}
void FFTEngine::setup(int order, int overlaps, int wintype) {
if (order == fftOrder && overlaps == fftOverlaps && wintype == fftWintype)
return;
fftOrder = order <= fftMaxOrder ? order : fftMaxOrder;
fftSize = 1 << fftOrder;
fftOverlaps = overlaps <= fftMaxOverlaps ? overlaps : fftMaxOverlaps;
fftHopSize = fftSize / fftOverlaps;
fftWintype = wintype;
reset();
}
void FFTEngine::computeFrame(int overlap) {
zeromem (fftData[overlap], sizeof (fftData[overlap]));
memcpy (fftData[overlap], fifo[overlap], sizeof (fifo[overlap]));
window.multiplyWithWindowingTable (fftData[overlap], fftSize);
forwardFFT->performRealOnlyForwardTransform (fftData[overlap], true);
// Registered callback to process the FFT frame.
listeners.call([&] (Listener& l) { l.fftEngineFrameReady(this, fftData[overlap], fftSize); });
forwardFFT->performRealOnlyInverseTransform (fftData[overlap]);
window.multiplyWithWindowingTable (fftData[overlap], fftSize);
}
float FFTEngine::process(float input) {
if (fifoIndex % fftHopSize == 0) {
computeFrame(fifoIndex / fftHopSize);
}
for (int overlap = 0; overlap < fftOverlaps; overlap++) {
int fifoIndexOverlap = (fifoIndex - fftHopSize * overlap);
fifoIndexOverlap = fifoIndexOverlap < 0 ? fifoIndexOverlap + fftSize : fifoIndexOverlap;
fifo[overlap][fifoIndexOverlap] = input;
}
float outputSignal = 0.0f;
for (int overlap = 0; overlap < fftOverlaps; overlap++) {
int fifoIndexOverlap = (fifoIndex - fftHopSize * overlap);
fifoIndexOverlap = fifoIndexOverlap < 0 ? fifoIndexOverlap + fftSize : fifoIndexOverlap;
outputSignal += fftData[overlap][fifoIndexOverlap];
}
outputSignal /= fftOverlaps;
fifoIndex++;
if (fifoIndex == fftSize) {
fifoIndex = 0;
}
return outputSignal;
}
| 3,367
|
C++
|
.cpp
| 86
| 34.534884
| 98
| 0.666667
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,634
|
Biquad.cpp
|
belangeo_plugex/common/Biquad.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "Biquad.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
Biquad::Biquad() {
m_sampleRate = 44100.0;
a0 = a1 = a2 = b0 = b1 = b2 = 0.0f;
}
Biquad::~Biquad() {}
void Biquad::setup(double sampleRate) {
m_sampleRate = sampleRate;
x1 = x2 = y1 = y2 = 0.0f;
setParameters(1000.0f, 1.0f, 0);
}
void Biquad::setFreq(float freq) {
if (freq != m_freq) {
m_freq = freq < 0.1f ? 0.1 : freq > m_sampleRate / 2.0f ? m_sampleRate / 2.0f : freq;
computeVariables();
}
}
void Biquad::setQ(float q) {
if (q != m_q) {
m_q = q < 0.5f ? 0.5f : q > 100.0f ? 100.0f : q;
computeVariables();
}
}
void Biquad::setType(int type) {
if (type != m_type) {
m_type = type < 0 ? 0 : type > 4 ? 4 : type;
computeCoefficients();
}
}
void Biquad::setParameters(float freq, float q, int type) {
if (freq != m_freq || q != m_q || type != m_type) {
m_freq = freq < 0.1f ? 0.1 : freq > m_sampleRate / 2.0f ? m_sampleRate / 2.0f : freq;
m_q = q < 0.5f ? 0.5f : q > 100.0f ? 100.0f : q;
m_type = type < 0 ? 0 : type > 4 ? 4 : type;
computeVariables();
}
}
void Biquad::computeVariables() {
w0 = m_freq * 2.0f * M_PI / m_sampleRate;
c = cosf(w0);
alpha = sinf(w0) / (2.0f * m_q);
computeCoefficients();
}
void Biquad::computeCoefficients() {
switch (m_type) {
case 0: // lowpass
b0 = b2 = (1.0f - c) / 2.0f;
b1 = 1.0f - c;
a0 = 1.0f / (1.0f + alpha);
a1 = -2.0f * c;
a2 = 1.0f - alpha;
break;
case 1: // highpass
b0 = (1.0f + c) / 2.0f;
b1 = -(1.0f + c);
b2 = b0;
a0 = 1.0f / (1.0f + alpha);
a1 = -2.0f * c;
a2 = 1.0f - alpha;
break;
case 2: // bandpass
b0 = alpha;
b1 = 0.0f;
b2 = -alpha;
a0 = 1.0f / (1.0f + alpha);
a1 = -2.0f * c;
a2 = 1.0f - alpha;
break;
case 3: // bandstop
b0 = 1.0f;
b1 = a1 = -2.0f * c;
b2 = 1.0f;
a0 = 1.0f / (1.0f + alpha);
a2 = 1.0f - alpha;
break;
case 4: // allpass
b0 = a2 = 1.0f - alpha;
b1 = a1 = -2.0f * c;
b2 = 1.0f + alpha;
a0 = 1.0f / (1.0f + alpha);
break;
}
}
float Biquad::process(float input) {
float out = ( b0 * input + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2 ) * a0;
x2 = x1; x1 = input; y2 = y1; y1 = out;
return out;
}
| 3,105
|
C++
|
.cpp
| 102
| 23.45098
| 93
| 0.461307
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,635
|
SinOsc.cpp
|
belangeo_plugex/common/SinOsc.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "SinOsc.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
SinOsc::SinOsc() {}
SinOsc::~SinOsc() {}
void SinOsc::setup(double sampleRate) {
m_freq = m_phase = 0.0f;
m_increment = m_runningPhase = 0.0f;
m_sampleRate = sampleRate;
}
void SinOsc::setFreq(float freq) {
if (freq != m_freq) {
m_freq = freq;
m_increment = m_freq / m_sampleRate;
}
}
void SinOsc::setPhase(float phase) {
m_phase = phase;
}
float SinOsc::process() {
float value = sinf(m_runningPhase * M_PI * 2.0f + m_phase);
m_runningPhase += m_increment;
if (m_runningPhase >= 1.0f) {
m_runningPhase -= 1.0f;
}
return value;
}
| 1,143
|
C++
|
.cpp
| 39
| 26.179487
| 80
| 0.582569
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,636
|
Granulator.cpp
|
belangeo_plugex/common/Granulator.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2020
*
*******************************************************************************/
#include <cmath>
#include "Granulator.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
Granulator::Granulator() {
maxSize = recordingSize = 0;
initialized = false;
}
Granulator::~Granulator() {}
void Granulator::setup(double sampleRate, double memorySize) {
m_sampleRate = sampleRate;
maxSize = recordingSize = static_cast<long> (m_sampleRate * memorySize);
isRecording = false;
recordingIndex = 0;
oneOverSr = 1.0 / sampleRate;
timer = 1.0;
deviationFactor = 1.0;
numberOfActiveGrains = 0;
density = 50.f;
pitch = 1.f;
position = 0.f;
duration = 0.1f;
deviation = 0.f;
gainFactor = sqrtf(sqrtf(density));
data.reset( new float[maxSize + 1] );
std::fill(data.get(), data.get() + maxSize + 1, 0.f);
srand(static_cast<unsigned int>(time(NULL)));
gpos.resize(maxNumberOfGrains, 0.f);
glen.resize(maxNumberOfGrains, 0.f);
ginc.resize(maxNumberOfGrains, 0.f);
gphs.resize(maxNumberOfGrains, 0.f);
flags.resize(maxNumberOfGrains, 0);
initialized = true;
}
void Granulator::setRecording(bool shouldBeRecording) {
isRecording = shouldBeRecording;
recordingIndex = 0;
recordedSize = 0;
}
bool Granulator::getIsRecording() {
return isRecording;
}
void Granulator::setDensity(float newDensity) {
density = newDensity < 1.f ? 1.f : newDensity;
gainFactor = sqrtf(sqrtf(density));
}
void Granulator::setPitch(float newPitch) {
pitch = newPitch;
}
void Granulator::setPosition(float newPosition) {
position = newPosition;
}
void Granulator::setDuration(float newDuration) {
duration = newDuration;
}
void Granulator::setDeviation(float newDeviation) {
deviation = newDeviation;
}
void Granulator::setRecordingSize(double newRecordingSize) {
recordingSize = static_cast<long> (m_sampleRate * newRecordingSize);
if (recordingSize > maxSize)
recordingSize = maxSize;
}
float Granulator::process(float input) {
if (! initialized)
return 0.f;
if (isRecording && recordingIndex < recordingSize) {
data[recordingIndex++] = input;
if (recordingIndex == recordingSize) {
isRecording = false;
}
recordedSize = recordingIndex - 1;
}
bool needNewGrain = false;
double timeIncrement = density * oneOverSr * deviationFactor;
timer += timeIncrement;
if (timer >= 1.0) {
timer -= 1.0;
needNewGrain = true;
}
float out = 0.f;
if (needNewGrain) {
for (int j = 0; j < maxNumberOfGrains; j++) {
if (flags[j] == 0) {
flags[j] = 1;
if (j >= numberOfActiveGrains)
numberOfActiveGrains = j + 1;
gpos[j] = position * recordedSize;
glen[j] = duration * m_sampleRate * pitch;
if ((gpos[j] + glen[j]) >= recordedSize || (gpos[j] + glen[j]) < 0)
flags[j] = false;
gphs[j] = 0.f;
ginc[j] = 1.f / (duration * m_sampleRate);
deviationFactor = (rand() / (float)RAND_MAX * 2.0 - 1.0) * deviation + 1.0;
break;
}
}
}
for (int j = 0; j < numberOfActiveGrains; j++) {
if (flags[j]) {
float amp = cosf(M_PI * 2.f * gphs[j]) * -0.5f + 0.5f;
float index = gphs[j] * glen[j] + gpos[j];
int ipart = (int)index;
float val = (data[ipart] + (data[ipart+1] - data[ipart]) * (index - ipart)) * amp;
out += val;
gphs[j] += ginc[j];
if (gphs[j] >= 1.0)
flags[j] = 0;
}
}
return out / gainFactor;
}
| 4,137
|
C++
|
.cpp
| 123
| 27.308943
| 94
| 0.590555
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,637
|
MultiSlider.cpp
|
belangeo_plugex/common/MultiSlider.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "MultiSlider.h"
MultiSlider::MultiSlider() {}
MultiSlider::~MultiSlider() {
setLookAndFeel(nullptr);
}
void MultiSlider::setup(int numberOfPoints) {
lastPosition.setXY(0, 0);
bars.resize(numberOfPoints);
}
void MultiSlider::paint(Graphics& g) {
int width = getWidth();
int height = getHeight();
PlugexLookAndFeel *lookAndFeel;
lookAndFeel = static_cast<PlugexLookAndFeel *> (&getLookAndFeel());
g.fillAll (lookAndFeel->findColour (ResizableWindow::backgroundColourId));
g.setColour(lookAndFeel->getLightTheme());
g.drawRect(0, 0, width, height);
g.setColour(lookAndFeel->getLightTheme().withAlpha(0.5f));
for (int i = 0; i < width; i++) {
g.drawVerticalLine(i, height - height * bars[i], height);
}
}
void MultiSlider::resized() {
// Maybe we should use bars.resize() for the case where the size of the multislider change.
// But that implies that the processor is aware of this change in size...
}
void MultiSlider::setPoints(const Array<float> &points) {
for (int i = 0; i < points.size(); i++) {
bars.set(i, points[i]);
}
repaint();
listeners.call([&] (Listener& l) { l.multiSliderChanged(this, bars); });
}
void MultiSlider::mouseDown(const MouseEvent &event) {
int height = getHeight() - 1;
lastPosition.setXY(event.x, event.y);
bars.set(lastPosition.x, (height - event.y) / (float)height);
listeners.call([&] (Listener& l) { l.multiSliderChanged(this, bars); });
repaint();
}
void MultiSlider::mouseDrag(const MouseEvent &event) {
int width = getWidth();
int height = getHeight() - 1;
int lastX = lastPosition.x < 0 ? 0 : lastPosition.x >= width ? width - 1 : lastPosition.x;
int lastY = lastPosition.y < 0 ? 0 : lastPosition.y > height ? height : lastPosition.y;
int newX = event.x < 0 ? 0 : event.x >= width ? width - 1 : event.x;
int newY = event.y < 0 ? 0 : event.y > height ? height : event.y;
float y1 = (float)lastY;
float y2 = (float)newY;
float diff = y2 - y1;
int steps = jmax(lastX, newX) - jmin(lastX, newX);
int direction = lastX < newX ? 1 : -1;
for (int i = 0; i < steps; i++) {
bars.set(lastX+i*direction, (height - (y1 + diff)) / (float)height);
}
lastPosition.setXY(newX, newY);
listeners.call([&] (Listener& l) { l.multiSliderChanged(this, bars); });
repaint();
}
| 2,840
|
C++
|
.cpp
| 69
| 36.942029
| 95
| 0.627966
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,638
|
Windowing.cpp
|
belangeo_plugex/common/Windowing.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "Windowing.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
Windowing::Windowing() {}
Windowing::~Windowing() {}
void Windowing::setup(int size, WindowType type) {
int i;
float arg;
windowTable.resize(size);
float *window = windowTable.getRawDataPointer();
switch (type) {
case rectangular:
for (i = 0; i < size; i++) {
window[i] = 1.0f;
}
break;
case triangular:
arg = 2.0f / (size - 1);
for (i = 0; i < (size - 1) / 2; i++) {
window[i] = i * arg;
}
for ( ; i < size; i++) {
window[i] = 2.0f - i * arg;
}
break;
case hanning:
arg = 2.0f * M_PI / (size - 1);
for (i = 0; i < size; i++) {
window[i] = 0.5 - 0.5 * cosf(arg * i);
}
break;
case hamming:
arg = 2.0f * M_PI / (size - 1);
for (i = 0; i < size; i++) {
window[i] = 0.54 - 0.46 * cosf(arg * i);
}
break;
case blackman:
arg = 2.0f * M_PI / (size - 1);
for (i = 0; i < size; i++) {
window[i] = 0.42323f - 0.49755f * cosf(arg * i) + 0.07922f * cosf(2.0f * arg * i);
}
break;
case blackmanHarris4:
arg = 2.0f * M_PI / (size - 1);
for (i = 0; i < size; i++) {
window[i] = 0.35875f - 0.48829f * cosf(arg * i) + 0.14128f * cosf(2.0f * arg * i) - \
0.01168f * cosf(3.0f * arg * i);
}
break;
case blackmanHarris7:
arg = 2.0f * M_PI / (size - 1);
for (i = 0; i < size; i++) {
window[i] = 0.2712203606f - 0.4334446123f * cosf(arg * i) + \
0.21800412f * cosf(2.0f * arg * i) - 0.0657853433f * cosf(3.0f * arg * i) + \
0.0107618673f * cosf(4.0f * arg * i) - 0.0007700127f * cosf(5.0f * arg * i) + \
0.00001368088f * cosf(6.0f * arg * i);
}
break;
case flatTop:
/* Tuckey (alpha = 0.66) */
arg = 0.66f;
for (i = 0; i < (int)(arg * size / 2.0f); i++) {
window[i] = 0.5f * (1.0f + cosf(M_PI * (2.0f * i / (arg * size) - 1)));
}
for ( ; i < (int)(size * (1.0f - arg / 2)); i++) {
window[i] = 1.0f;
}
for ( ; i < size; i++) {
window[i] = 0.5f * (1.0f + cosf(M_PI * (2.0f * i / (arg * size) - 2.0f / arg + 1.0f)));
}
break;
case halfSine:
arg = M_PI / (size - 1);
for (i = 0; i < size; i++) {
window[i] = sinf(arg * i);
}
break;
default:
jassertfalse;
break;
}
}
void Windowing::multiplyWithWindowingTable (float *samples, int size) noexcept {
FloatVectorOperations::multiply (samples, windowTable.getRawDataPointer(), jmin (size, windowTable.size()));
}
const char* Windowing::getWindowingMethodName (WindowType type) noexcept {
switch (type) {
case rectangular: return "Rectangular";
case triangular: return "Triangular";
case hanning: return "Hanning";
case hamming: return "Hamming";
case blackman: return "Blackman";
case blackmanHarris4: return "Blackman-Harris 4 terms";
case blackmanHarris7: return "Blackman-Harris 7 terms";
case flatTop: return "Flat Top";
case halfSine: return "Half Sine";
default: jassertfalse; return "";
}
}
| 4,263
|
C++
|
.cpp
| 112
| 27.741071
| 112
| 0.449468
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,639
|
OnePoleLowpass.cpp
|
belangeo_plugex/common/OnePoleLowpass.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <cmath>
#include "OnePoleLowpass.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
OnePoleLowpass::OnePoleLowpass() {
m_sampleRate = 44100.0;
m_freq = m_sampleRate / 2.0f;
m_coeff = 0.0f;
}
OnePoleLowpass::~OnePoleLowpass() {}
void OnePoleLowpass::setup(double sampleRate) {
m_sampleRate = sampleRate;
m_y1 = 0.0f;
}
void OnePoleLowpass::setFreq(float freq) {
if (freq != m_freq) {
m_freq = freq;
m_coeff = expf(-2.0f * M_PI * m_freq / m_sampleRate);
}
}
float OnePoleLowpass::process(float input) {
m_y1 = input + (m_y1 - input) * m_coeff;
return m_y1;
}
| 1,077
|
C++
|
.cpp
| 35
| 27.885714
| 80
| 0.59378
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,640
|
DelayLine.cpp
|
belangeo_plugex/common/DelayLine.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include <algorithm>
#include "DelayLine.h"
DelayLine::DelayLine() {}
DelayLine::~DelayLine() {}
void DelayLine::setup(float maxDelayTime, double sampleRate) {
m_writePosition = 0;
m_maxSize = static_cast<int> (maxDelayTime * sampleRate + 0.5);
m_sampleRate = sampleRate;
data.reset( new float[m_maxSize + 1] );
std::fill(data.get(), data.get() + m_maxSize + 1, 0.f);
}
float DelayLine::read(float delayTime) {
float delayTimeInSamples = delayTime * m_sampleRate;
float readPosition = m_writePosition - delayTimeInSamples;
if (readPosition < 0) {
readPosition += m_maxSize;
} else if (readPosition >= m_maxSize) {
readPosition -= m_maxSize;
}
int readPosIntegerPart = static_cast<int>(readPosition);
float readPosFloatPart = readPosition - readPosIntegerPart;
float previous = data[readPosIntegerPart];
float next = data[readPosIntegerPart + 1];
return previous + (next - previous) * readPosFloatPart;
}
void DelayLine::write(float input) {
data[m_writePosition] = input;
if (m_writePosition == 0) {
data[m_maxSize] = input;
}
m_writePosition++;
if (m_writePosition == m_maxSize) {
m_writePosition = 0;
}
}
| 1,656
|
C++
|
.cpp
| 45
| 32.933333
| 80
| 0.629143
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,641
|
PluginEditor.cpp
|
belangeo_plugex/Plugex_10_ButterworthBR/Source/PluginEditor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
Plugex_10_butterworthBrAudioProcessorEditor::Plugex_10_butterworthBrAudioProcessorEditor (Plugex_10_butterworthBrAudioProcessor& p, AudioProcessorValueTreeState& vts)
: AudioProcessorEditor (&p), processor (p), valueTreeState (vts)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 200);
setLookAndFeel(&plugexLookAndFeel);
plugexLookAndFeel.setTheme("green");
title.setText("Plugex - 10 - Butterworth Bandstop", NotificationType::dontSendNotification);
title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4));
title.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&title);
freqLabel.setText("Freq", NotificationType::dontSendNotification);
freqLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&freqLabel);
freqKnob.setLookAndFeel(&plugexLookAndFeel);
freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&freqKnob);
freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob));
qLabel.setText("Resonance", NotificationType::dontSendNotification);
qLabel.setJustificationType(Justification::horizontallyCentred);
addAndMakeVisible(&qLabel);
qKnob.setLookAndFeel(&plugexLookAndFeel);
qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
addAndMakeVisible(&qKnob);
qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob));
}
Plugex_10_butterworthBrAudioProcessorEditor::~Plugex_10_butterworthBrAudioProcessorEditor()
{
freqKnob.setLookAndFeel(nullptr);
qKnob.setLookAndFeel(nullptr);
setLookAndFeel(nullptr);
}
//==============================================================================
void Plugex_10_butterworthBrAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void Plugex_10_butterworthBrAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced(12, 12);
float width = area.getWidth();
title.setBounds(area.removeFromTop(36));
area.removeFromTop(12);
auto area2 = area.removeFromTop(100);
auto freqArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100);
freqLabel.setBounds(freqArea.removeFromTop(20));
freqKnob.setBounds(freqArea);
auto qArea = area2.withSizeKeepingCentre(80, 100);
qLabel.setBounds(qArea.removeFromTop(20));
qKnob.setBounds(qArea);
area.removeFromTop(12);
}
| 3,482
|
C++
|
.cpp
| 69
| 46.231884
| 167
| 0.706942
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,534,642
|
PluginProcessor.cpp
|
belangeo_plugex/Plugex_10_ButterworthBR/Source/PluginProcessor.cpp
|
/*******************************************************************************
* Plugex - PLUGin EXamples
*
* Plugex est une série de plugiciels auto-documentés permettant une étude
* autonome du développement de plugiciels avec JUCE ainsi que des bases du
* traitement de signal audio avec le langage C++.
*
* © Olivier Bélanger 2019
*
*******************************************************************************/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#ifndef M_PI
#define M_PI (3.14159265358979323846264338327950288)
#endif
static String freqSliderValueToText(float value) {
return String(value, 2) + String(" Hz");
}
static float freqSliderTextToValue(const String& text) {
return text.getFloatValue();
}
static String qSliderValueToText(float value) {
return String(value, 2) + String(" Q");
}
static float qSliderTextToValue(const String& text) {
return text.getFloatValue();
}
AudioProcessorValueTreeState::ParameterLayout createParameterLayout() {
using Parameter = AudioProcessorValueTreeState::Parameter;
std::vector<std::unique_ptr<Parameter>> parameters;
parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(),
NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f),
1000.0f, freqSliderValueToText, freqSliderTextToValue));
parameters.push_back(std::make_unique<Parameter>(String("q"), String("Q"), String(),
NormalisableRange<float>(1.0f, 50.0f, 0.01f, 0.5f),
1.0f, qSliderValueToText, qSliderTextToValue));
return { parameters.begin(), parameters.end() };
}
//==============================================================================
Plugex_10_butterworthBrAudioProcessor::Plugex_10_butterworthBrAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout())
{
freqParameter = parameters.getRawParameterValue("freq");
qParameter = parameters.getRawParameterValue("q");
}
Plugex_10_butterworthBrAudioProcessor::~Plugex_10_butterworthBrAudioProcessor()
{
}
//==============================================================================
const String Plugex_10_butterworthBrAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool Plugex_10_butterworthBrAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool Plugex_10_butterworthBrAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool Plugex_10_butterworthBrAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double Plugex_10_butterworthBrAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int Plugex_10_butterworthBrAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
// so this should be at least 1, even if you're not really implementing programs.
}
int Plugex_10_butterworthBrAudioProcessor::getCurrentProgram()
{
return 0;
}
void Plugex_10_butterworthBrAudioProcessor::setCurrentProgram (int index)
{
}
const String Plugex_10_butterworthBrAudioProcessor::getProgramName (int index)
{
return {};
}
void Plugex_10_butterworthBrAudioProcessor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Plugex_10_butterworthBrAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
currentSampleRate = sampleRate;
memset(lastInputSample1, 0, sizeof(float) * 2);
memset(lastInputSample2, 0, sizeof(float) * 2);
memset(lastFilteredSample1, 0, sizeof(float) * 2);
memset(lastFilteredSample2, 0, sizeof(float) * 2);
freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
freqSmoothed.setCurrentAndTargetValue(*freqParameter);
qSmoothed.reset(sampleRate, samplesPerBlock/sampleRate);
qSmoothed.setCurrentAndTargetValue(*qParameter);
}
void Plugex_10_butterworthBrAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool Plugex_10_butterworthBrAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused (layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
#endif
void Plugex_10_butterworthBrAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
freqSmoothed.setTargetValue(*freqParameter);
qSmoothed.setTargetValue(*qParameter);
for (int i = 0; i < buffer.getNumSamples(); i++)
{
float cf = freqSmoothed.getNextValue();
float bw = cf / qSmoothed.getNextValue();
float piOnSr = M_PI / currentSampleRate;
float c = tanf(piOnSr * bw);
float d = 2.0f * cosf(2.0f * piOnSr * cf);
float a0 = 1.0f / (1.0f + c);
float a1 = -a0 * d;
float a2 = a0;
float b1 = a1;
float b2 = a0 * (1.0f - c);
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer (channel);
float filtered = a0 * channelData[i] + a1 * lastInputSample1[channel] + a2 * lastInputSample2[channel] -
b1 * lastFilteredSample1[channel] - b2 * lastFilteredSample2[channel];
lastInputSample2[channel] = lastInputSample1[channel];
lastInputSample1[channel] = channelData[i];
lastFilteredSample2[channel] = lastFilteredSample1[channel];
channelData[i] = lastFilteredSample1[channel] = filtered;
}
}
}
//==============================================================================
bool Plugex_10_butterworthBrAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Plugex_10_butterworthBrAudioProcessor::createEditor()
{
return new Plugex_10_butterworthBrAudioProcessorEditor (*this, parameters);
}
//==============================================================================
void Plugex_10_butterworthBrAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
void Plugex_10_butterworthBrAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new Plugex_10_butterworthBrAudioProcessor();
}
| 8,738
|
C++
|
.cpp
| 209
| 35.473684
| 117
| 0.646662
|
belangeo/plugex
| 35
| 3
| 1
|
LGPL-3.0
|
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.