Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PADnoteParameters.h 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. PADnoteParameters.h - Parameters for PADnote (PADsynth)
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #ifndef PAD_NOTE_PARAMETERS_H
  18. #define PAD_NOTE_PARAMETERS_H
  19. #include "../Misc/XMLwrapper.h"
  20. #include "../DSP/FFTwrapper.h"
  21. #include "../globals.h"
  22. #include "../Synth/OscilGen.h"
  23. #include "../Synth/Resonance.h"
  24. #include "../Misc/Util.h"
  25. #include "EnvelopeParams.h"
  26. #include "LFOParams.h"
  27. #include "FilterParams.h"
  28. #include "Presets.h"
  29. #include <string>
  30. #include <pthread.h>
  31. class PADnoteParameters:public Presets
  32. {
  33. public:
  34. PADnoteParameters(FFTwrapper *fft_, pthread_mutex_t *mutex_);
  35. ~PADnoteParameters();
  36. void defaults();
  37. void add2XML(XMLwrapper *xml);
  38. void getfromXML(XMLwrapper *xml);
  39. //returns a value between 0.0f-1.0f that represents the estimation perceived bandwidth
  40. float getprofile(float *smp, int size);
  41. //parameters
  42. //the mode: 0 - bandwidth, 1 - discrete (bandwidth=0), 2 - continous
  43. //the harmonic profile is used only on mode 0
  44. unsigned char Pmode;
  45. //Harmonic profile (the frequency distribution of a single harmonic)
  46. struct {
  47. struct { //base function
  48. unsigned char type;
  49. unsigned char par1;
  50. } base;
  51. unsigned char freqmult; //frequency multiplier of the distribution
  52. struct { //the modulator of the distribution
  53. unsigned char par1;
  54. unsigned char freq;
  55. } modulator;
  56. unsigned char width; //the width of the resulting function after the modulation
  57. struct { //the amplitude multiplier of the harmonic profile
  58. unsigned char mode;
  59. unsigned char type;
  60. unsigned char par1;
  61. unsigned char par2;
  62. } amp;
  63. bool autoscale; //if the scale of the harmonic profile is computed automaticaly
  64. unsigned char onehalf; //what part of the base function is used to make the distribution
  65. } Php;
  66. unsigned int Pbandwidth; //the values are from 0 to 1000
  67. unsigned char Pbwscale; //how the bandwidth is increased according to the harmonic's frequency
  68. struct { //where are positioned the harmonics (on integer multimplier or different places)
  69. unsigned char type;
  70. unsigned char par1, par2, par3; //0..255
  71. } Phrpos;
  72. struct { //quality of the samples (how many samples, the length of them,etc.)
  73. unsigned char samplesize;
  74. unsigned char basenote, oct, smpoct;
  75. } Pquality;
  76. //frequency parameters
  77. //If the base frequency is fixed to 440 Hz
  78. unsigned char Pfixedfreq;
  79. /* Equal temperate (this is used only if the Pfixedfreq is enabled)
  80. If this parameter is 0, the frequency is fixed (to 440 Hz);
  81. if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
  82. unsigned char PfixedfreqET;
  83. unsigned short int PDetune; //fine detune
  84. unsigned short int PCoarseDetune; //coarse detune+octave
  85. unsigned char PDetuneType; //detune type
  86. EnvelopeParams *FreqEnvelope; //Frequency Envelope
  87. LFOParams *FreqLfo; //Frequency LFO
  88. //Amplitude parameters
  89. unsigned char PStereo;
  90. /* Panning - 0 - random
  91. 1 - left
  92. 64 - center
  93. 127 - right */
  94. unsigned char PPanning;
  95. unsigned char PVolume;
  96. unsigned char PAmpVelocityScaleFunction;
  97. EnvelopeParams *AmpEnvelope;
  98. LFOParams *AmpLfo;
  99. unsigned char PPunchStrength, PPunchTime, PPunchStretch,
  100. PPunchVelocitySensing;
  101. //Filter Parameters
  102. FilterParams *GlobalFilter;
  103. // filter velocity sensing
  104. unsigned char PFilterVelocityScale;
  105. // filter velocity sensing
  106. unsigned char PFilterVelocityScaleFunction;
  107. EnvelopeParams *FilterEnvelope;
  108. LFOParams *FilterLfo;
  109. float setPbandwidth(int Pbandwidth); //returns the BandWidth in cents
  110. float getNhr(int n); //gets the n-th overtone position relatively to N harmonic
  111. void applyparameters(bool lockmutex);
  112. void export2wav(std::string basefilename);
  113. OscilGen *oscilgen;
  114. Resonance *resonance;
  115. struct {
  116. int size;
  117. float basefreq;
  118. float *smp;
  119. } sample[PAD_MAX_SAMPLES], newsample;
  120. private:
  121. void generatespectrum_bandwidthMode(float *spectrum,
  122. int size,
  123. float basefreq,
  124. float *profile,
  125. int profilesize,
  126. float bwadjust);
  127. void generatespectrum_otherModes(float *spectrum,
  128. int size,
  129. float basefreq);
  130. void deletesamples();
  131. void deletesample(int n);
  132. FFTwrapper *fft;
  133. pthread_mutex_t *mutex;
  134. };
  135. #endif