diff --git a/H/remote.h b/H/remote.h index 99940dbb39a..6869b7bdc72 100644 --- a/H/remote.h +++ b/H/remote.h @@ -27,6 +27,11 @@ #ifdef HAVE_SOCKETS #ifdef WIN32 #include + #ifndef SHUT_RDWR + #define SHUT_RD 0x00 + #define SHUT_WR 0x01 + #define SHUT_RDWR 0x02 + #endif #else #include #ifdef __HAIKU__ diff --git a/Opcodes/CMakeLists.txt b/Opcodes/CMakeLists.txt index c8f9321e7e0..d2fdeab2ae8 100644 --- a/Opcodes/CMakeLists.txt +++ b/Opcodes/CMakeLists.txt @@ -65,6 +65,7 @@ make_plugin(doppler doppler.cpp) make_plugin(fractalnoise tl/fractalnoise.cpp) make_plugin(fareygen fareygen.c) +make_plugin(padsynth padsynth_gen.cpp) make_plugin(cellular cellular.c) diff --git a/Opcodes/padsynth_gen.cpp b/Opcodes/padsynth_gen.cpp new file mode 100644 index 00000000000..175901950a2 --- /dev/null +++ b/Opcodes/padsynth_gen.cpp @@ -0,0 +1,140 @@ +/* + fareygen.c: + + Copyright (C) 2010 Georg Boenn + + This file is part of Csound. + + The Csound Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + Csound 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with Csound; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA +*/ +extern "C" { +#include "csdl.h" +} +#include +#include +#include + +static MYFLT profile(MYFLT fi, MYFLT bwi) +{ + MYFLT x = fi / bwi; + x *= x; + // Avoids computing the e^(-x^2) where it's results are very close to zero. + if (x > 14.71280603) { + return 0.0; + } + return std::exp(-x) / bwi; +}; + +extern "C" { + + /** + * This function computes a Csound "sound sample" function table + * using Nasca's "padsynth" algorithm implemented in C++. + */ + static int padsynth_gen (FGDATA *ff, FUNC *ftp) + { + CSOUND *csound = ff->csound; + MYFLT p1_function_table_number = ff->fno; + csound->Message(csound, "p1_function_table_number: %9.4f\n", p1_function_table_number); + MYFLT p2_score_time = ff->e.p[2]; + csound->Message(csound, "p2_score_time: %9.4f\n", p2_score_time); + int N = ff->flen; + csound->Message(csound, "N: %9.4f\n", N); + const char *p4_gen_id = ((STRINGDAT *)(&ff->e.p[4]))->data; + csound->Message(csound, "p4_gen_id: %s\n", p4_gen_id); + MYFLT p5_fundamental_frequency = ff->e.p[5]; + csound->Message(csound, "p5_fundamental_frequency: %9.4f\n", p5_fundamental_frequency); + MYFLT p6_partial_bandwith = ff->e.p[6]; + csound->Message(csound, "p6_partial_bandwith: %9.4f\n", p6_partial_bandwith); + MYFLT p7_partial_bandwidth_scale_factor = ff->e.p[7]; + csound->Message(csound, "p7_partial_bandwidth_scale_factor: %9.4f\n", p7_partial_bandwidth_scale_factor); + MYFLT p8_harmonic_stretch = ff->e.p[8]; + csound->Message(csound, "p8_harmonic_stretch: %9.4f\n", p8_harmonic_stretch); + MYFLT samplerate = csound->GetSr(csound); + csound->Message(csound, "samplerate: %9.4f\n", samplerate); + // The amplitudes of each partial are in pfield 9 and higher. + // N.B.: The partials are indexed starting from 1. + int partialN = ff->e.pcnt - 8; + std::vector A(partialN + 1); + for (int partialI = 1; partialI <= partialN; ++partialI) { + A[partialI] = ff->e.p[9 + partialI - 1]; + csound->Message(csound, "Partial[%3d]: %9.4f\n", partialI, A[partialI]); + } + for (int i = 0; i < N; ++i) { + ftp->ftable[i] = FL(0.0); + } + // The algorithm computes a spectrum based on the partials and their bandwidths. + // The inverse FFT of this spectrum is then taken to obtain a sound sample -- + // not the IFFT of the partials! + // N.B.: An in-place IFFT of N/2 complex to N real samples is used. + // ftable[1] contains the real part of the Nyquist frequency; we make it 0. + std::complex *spectrum = (std::complex *)ftp->ftable; + int complexN = int(N / 2.0); + for (int partialI = 1; partialI <= partialN; ++partialI) { + MYFLT bw_Hz;//bandwidth of the current harmonic measured in Hz + MYFLT bwi; + MYFLT fi; + MYFLT rF = p5_fundamental_frequency * p8_harmonic_stretch * partialI; + // bw_Hz=(pow(2.0,bw/1200.0)-1.0)*f*pow(relF(nh),bwscale); + bw_Hz = (std::pow(2.0, p6_partial_bandwith / 1200.0) - 1.0) * p5_fundamental_frequency * std::pow(p8_harmonic_stretch * partialI, p7_partial_bandwidth_scale_factor); + // bwi=bw_Hz/(2.0*samplerate); + bwi = bw_Hz / (2.0 * samplerate); + // fi=rF/samplerate; + fi = rF / samplerate; + for (int complexI = 0; complexI < complexN; ++complexI) { + // Here you can optimize, by avoiding to compute the profile for the full frequency (usually it's zero or very close to zero). + // hprofile=profile((i/(REALTYPE)N)-fi,bwi); + MYFLT hprofile = profile((complexI / (MYFLT) N) - fi, bwi); + // freq_amp[i]+=hprofile*A[nh]; + MYFLT real = hprofile * A[partialI]; + spectrum[complexI] += real; + }; + }; + std::default_random_engine generator; + std::uniform_real_distribution distribution(0.0, 6.28318530718); + for (int complexI = 0; complexI < complexN; ++complexI) { + MYFLT phase = distribution(generator); + MYFLT real = spectrum[complexI].real(); + spectrum[complexI].real(real * std::cos(phase)); + spectrum[complexI].imag(real * std::sin(phase)); + }; + spectrum[0].imag(0); + csound->InverseComplexFFT(csound, ftp->ftable, complexN); + // Normalize, + MYFLT maximum = FL(0.0); + for (int i = 0; i < N; ++i) { + if (std::fabs(ftp->ftable[i]) > maximum) { + maximum = std::fabs(ftp->ftable[i]); + csound->Message(csound, "maximum at %d: %f\n", i, maximum); + } + } + if (maximum < 1e-5) { + maximum = 1e-5; + } + for (int i = 0; i < N; ++i) { + ftp->ftable[i] /= maximum * 1.4142; + } + return OK; + } + + static NGFENS padsynth_gens[] = { + { "padsynth", padsynth_gen }, + { NULL, NULL } + }; + + FLINKAGE_BUILTIN(padsynth_gens) + +}; diff --git a/Opcodes/padsynth_gen.csd b/Opcodes/padsynth_gen.csd new file mode 100644 index 00000000000..b29afa33855 --- /dev/null +++ b/Opcodes/padsynth_gen.csd @@ -0,0 +1,54 @@ + + + +sr=44100 +ksmps=1 +nchnls=2 +0dbfs=1000 + + gispec_len init 2^18 + + ; p1 p2 p3 p4 p5 p6 p7 p8 p9 + gi_padsynth_1 ftgen 0, 0, gispec_len, "padsynth", 440, 56.96943, 1, 1, 0.7600046992, 0.6199994683, 0.9399998784, 0.4400023818, 0.0600003302, 0.8499968648, 0.0899999291, 0.8199964762, 0.3199984133, 0.9400014281, 0.3000001907, 0.120003365, 0.1799997687, 0.5200006366, 0.9300042987 + + instr 1 ;PadSynth + istereo_phase = 0 + iphase random 0, 1 + iattack = 0.08 + idecay = 0.1 + isustain = 0.25 + irelease = 0.2 + kenv madsr iattack, idecay, isustain, irelease + ifreq cpsmidinn p4 + iamp ampdb p5 + ibasefreq = 440 ; can be lower or higher frequency; close to played frequency is said to be best + ibw_cents = 56.96943 ; width of the peaks, 100 is whole note + +if istereo_phase==0 then + asig oscili iamp, ifreq*(sr/gispec_len/ibasefreq), gi_padsynth_1, iphase + asig = asig*kenv + aleft, aright pan2 asig, 0.5 + outs aleft, aright +else + asig1 oscili iamp, ifreq*(sr/gispec_len/ibasefreq), gi_padsynth_1, iphase + asig2 oscili iamp, ifreq*(sr/gispec_len/ibasefreq), gi_padsynth_1, iphase+0.5 + outs asig1*kenv, asig2*kenv +endif + + endin + + + + + + + + + +i1 0 2 60.00 60 +i1 + 2 72.00 60 +i1 + 2 84.00 60 + +e + + diff --git a/installer/windows/csound6.iss b/installer/windows/csound6.iss index faf493c9c3a..2f5cffa2f44 100644 --- a/installer/windows/csound6.iss +++ b/installer/windows/csound6.iss @@ -58,10 +58,12 @@ #define MyLibLoSourceDir "D:\msys\local\src\liblo-0.26\" ; If you are not Michael Gogins, change this to your STK dll directory. #define MyLibStkSourceDir "D:\msys\local\src\stk-4.5.0\" +; If you are not Michael Gogins, change this to your CsoundQt repository directory. +#define MyCsoundQtDir "D:\CsoundQt\" ; If you are not Michael Gogins, change this to your CsoundQt bin directory. -#define MyCsoundQtBinDir "C:\Users\mike\qutecsound-code\bin\" +#define MyCsoundQtBinDir "C:\Users\restore\build-qcs-Desktop_Qt_5_4_0_MSVC2013_32bit-Release\bin\" ; If you are not Michael Gogins, change this to your Qt SDK DLL directory. -#define MyQtSdkBinDir "D:\Qt5.3.0\5.3\mingw482_32\bin\" +#define MyQtSdkBinDir "D:\Qt5.4.0\5.4\msvc2013\bin\" ; If you are not Michael Gogins, change this to your unzipped cabbage-master directory. #define MyCabbageDir "D:\cabbage-master\" @@ -147,10 +149,10 @@ Source: "*.md"; DestDir: "{app}"; Flags: ignoreversion; Components: core; Source: "{#MyMinGwLibDir}*.dll"; DestDir: "{#APP_BIN}"; Components: core; ; No idea why this other name is needed. Source: "{#MyMSysBinDir}libiconv-2.dll"; DestDir: "{#APP_BIN}"; DestName: "iconv.dll"; Components: core; -Source: "{#MyQtSdkBinDir}icuin52.dll"; DestDir: "{#APP_BIN}"; Components: core; -Source: "{#MyQtSdkBinDir}icuuc52.dll"; DestDir: "{#APP_BIN}"; Components: core; -Source: "{#MyQtSdkBinDir}icudt52.dll"; DestDir: "{#APP_BIN}"; Components: core; -Source: "{#MyMinGwLibDir}libgomp-1.dll"; DestDir: "{#APP_BIN}"; Components: core; +Source: "{#MyQtSdkBinDir}icuin53.dll"; DestDir: "{#APP_BIN}"; Components: core; +Source: "{#MyQtSdkBinDir}icuuc53.dll"; DestDir: "{#APP_BIN}"; Components: core; +Source: "{#MyQtSdkBinDir}icudt53.dll"; DestDir: "{#APP_BIN}"; Components: core; +;Source: "{#MyMinGwLibDir}libgomp-1.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "{#MyMSysUsrLocalDir}bin/*.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "csound64.dll"; DestDir: "{#APP_BIN}"; Flags: ignoreversion; Components: core; Source: "csnd6.dll"; DestDir: "{#APP_BIN}"; Flags: ignoreversion; Components: core; @@ -192,6 +194,7 @@ Source: "ipmidi.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Compone Source: "linear_algebra.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; Source: "mixer.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; Source: "osc.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; +Source: "padsynth.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; Source: "platerev.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; Source: "pmidi.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; Source: "py.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: python; @@ -210,7 +213,7 @@ Source: "vst4cs.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Compone Source: "widgets.dll"; DestDir: "{#APP_PLUGINS64}"; Flags: ignoreversion; Components: core; Source: "{#MyCsoundQtBinDir}CsoundQt-d-cs6.exe"; DestDir: "{#APP_BIN}"; Components: core; -Source: "{#MyCsoundQtBinDir}..\src\Examples\*.*"; DestDir: "{#APP_BIN}\Examples"; Flags: ignoreversion recursesubdirs; Components: core +Source: "{#MyCsoundQtDir}Examples\*.*"; DestDir: "{#APP_BIN}\Examples"; Flags: ignoreversion recursesubdirs; Components: core Source: "{#MyQtSdkBinDir}Qt5Core.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "{#MyQtSdkBinDir}Qt5Gui.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "{#MyQtSdkBinDir}Qt5Network.dll"; DestDir: "{#APP_BIN}"; Components: core; @@ -220,10 +223,14 @@ Source: "{#MyQtSdkBinDir}Qt5Quick.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "{#MyQtSdkBinDir}Qt5QuickWidgets.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "{#MyQtSdkBinDir}Qt5Widgets.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: "{#MyQtSdkBinDir}Qt5Xml.dll"; DestDir: "{#APP_BIN}"; Components: core; -Source: "{#MyQtSdkBinDir}..\plugins\accessible\qtaccessiblewidgets.dll"; DestDir: "{#APP_BIN}\plugins\accessible"; Components: core; +Source: "{#MyQtSdkBinDir}Qt5WebEngine.dll"; DestDir: "{#APP_BIN}"; Components: core; +Source: "{#MyQtSdkBinDir}Qt5WebEngineCore.dll"; DestDir: "{#APP_BIN}"; Components: core; +Source: "{#MyQtSdkBinDir}Qt5WebEngineWidgets.dll"; DestDir: "{#APP_BIN}"; Components: core; +;Source: "{#MyQtSdkBinDir}..\plugins\accessible\qtaccessiblewidgets.dll"; DestDir: "{#APP_BIN}\plugins\accessible"; Components: core; Source: "{#MyQtSdkBinDir}..\plugins\imageformats\*.dll"; DestDir: "{#APP_BIN}\plugins\imageformats"; Components: core; Source: "{#MyQtSdkBinDir}..\plugins\platforms\qwindows.dll"; DestDir: "{#APP_BIN}\platforms"; Components: core; Source: "{#MyQtSdkBinDir}..\plugins\printsupport\windowsprintersupport.dll"; DestDir: "{#APP_BIN}\plugins\printsupport"; Components: core; +Source: "D:\msys\local\opt\pthreads-w32-2-9-1-release\Pre-built.2\dll\x86\pthreadVC2.dll"; DestDir: "{#APP_BIN}"; Components: core; Source: {#MyLibSndfileSourceDir}\bin\*.*; DestDir: "{#APP_BIN}"; Flags: ignoreversion; Components: core; Source: {#MyLibSndfileSourceDir}\include\*.*; DestDir: "{#APP_INCLUDE}\sndfile"; Flags: ignoreversion; Components: core; @@ -257,7 +264,7 @@ Source: include/*.h*; DestDir: "{#APP_INCLUDE}\csound"; Flags: ignoreversion; C Source: interfaces/*.h*; DestDir: "{#APP_INCLUDE}\csound"; Flags: ignoreversion; Components: core Source: frontends/CsoundAC/*.hpp; DestDir: "{#APP_INCLUDE}\csoundac"; Flags: ignoreversion; Components: core -;Source: {#MyManualSourceDir}html\*.*; DestDir: "{#APP_MANUAL}"; Flags: ignoreversion recursesubdirs; Components: core +Source: {#MyManualSourceDir}html\*.*; DestDir: "{#APP_MANUAL}"; Flags: ignoreversion recursesubdirs; Components: core Source: "doc\doxygen\csound\html\*.*"; DestDir: "{#APP_APIREF}/csound"; Flags: ignoreversion recursesubdirs; Components: core Source: "doc\doxygen\csoundac\html\*.*"; DestDir: "{#APP_APIREF}/csoundac"; Flags: ignoreversion recursesubdirs; Components: core