4 |
5 | USB/HID I/O routines
6 | */
7 | /*
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | */
22 | #ifndef USB_HID_H
23 | #define USB_HID_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | typedef struct USBHID_struct *USBHID;
30 |
31 | #define INVALID_USBHID_VALUE (0)
32 |
33 |
34 | #define SELECT_VENDOR_ID_FLAG (0x01)
35 | #define SELECT_PRODUCT_ID_FLAG (0x02)
36 | #define SELECT_VERSION_NUMBER_FLAG (0x04)
37 |
38 |
39 | /*
40 | Open the indexth USBHID device which match the delection criteria. The
41 | selection criteria may be any combination of vendor id, product id and
42 | version number as specified by the flags parameter.
43 |
44 | Returns an open handle on success, or INVALID_USBHIDHANDLE if an error
45 | occurred.
46 | */
47 | USBHID OpenUSBHID( int index, int vendorId, int productId, int versionNumber, int flags );
48 |
49 |
50 | /*
51 | Close a USB HID handle previously opened with OpenUSBHID()
52 | */
53 | void CloseUSBHID( USBHID handle );
54 |
55 |
56 | /*
57 | Read count bytes from the USB HID into dest. Returns the number of bytes
58 | read. This routine reads from the Kernel HID ring buffer, if it is no called
59 | frequently enough the data returned may lag behind the latest HID reports
60 | from the device.
61 |
62 | HidD_GetInputReport will read the most recent report, but is only
63 | implemented on Windows XP.
64 | */
65 | int ReadUSBHID( USBHID handle, void *dest, int count );
66 |
67 |
68 | int SetUSBHIDFeature( USBHID handle, char *report, int count );
69 |
70 | int GetUSBHIDFeature( USBHID handle, char *report, int count );
71 |
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
76 |
77 | #endif /* USB_HID_H */
78 |
--------------------------------------------------------------------------------
/6.x/src/CUDA/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | option(BUILD_CUDA_OPCODES "Build the CUDA GPU opcodes" OFF)
2 |
3 | function(make_cuda_plugin libname srcs)
4 | SET(LIB_TYPE_DYNAMIC) #set the lib type
5 | CUDA_ADD_LIBRARY(${libname} ${LIB_TYPE} ${srcs})
6 |
7 | set(i 2)
8 | while( ${i} LESS ${ARGC} )
9 | target_link_libraries(${libname} ${ARGV${i}})
10 | math(EXPR i "${i}+1")
11 | endwhile()
12 |
13 | target_include_directories(${libname} PRIVATE ${CSOUND_INCLUDE_DIRS})
14 |
15 | # set_target_properties(${libname} PROPERTIES
16 | # RUNTIME_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR}
17 | # LIBRARY_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR}
18 | # ARCHIVE_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR})
19 |
20 | install(TARGETS ${libname} LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}" )
21 | endfunction()
22 |
23 | if(BUILD_CUDA_OPCODES)
24 | find_package(CUDA REQUIRED)
25 | check_deps(BUILD_CUDA_OPCODES CUDA_FOUND)
26 | message(STATUS "Building the CUDA opcodes")
27 |
28 | include_directories(${CMAKE_HOME_DIRECTORY}/include)
29 | include_directories(/usr/local/include)
30 | LIST(APPEND CUDA_NVCC_FLAGS "-use_fast_math")
31 |
32 | if(APPLE)
33 | if(CMAKE_OSX_DEPLOYMENT_TARGET MATCHES 10.6)
34 | LIST(APPEND CUDA_NVCC_FLAGS "-arch=sm_11")
35 | make_cuda_plugin(cudaop1 adsyn11.cu)
36 | make_cuda_plugin(cudaop2 pvsopsf.cu)
37 | make_cuda_plugin(cudaop3 slidingm.cu)
38 | make_cuda_plugin(cudaop4 convf.cu)
39 | make_cuda_plugin(cudaop5 pconv11.cu)
40 | else()
41 | LIST(APPEND CUDA_NVCC_FLAGS "-ccbin /usr/bin/clang -arch=sm_30 -Xcompiler -stdlib=libstdc++")
42 | make_cuda_plugin(cudaop1 adsyn.cu)
43 | make_cuda_plugin(cudaop2 pvsops.cu)
44 | make_cuda_plugin(cudaop3 slidingm.cu)
45 | make_cuda_plugin(cudaop4 conv.cu)
46 | make_cuda_plugin(cudaop5 pconv.cu)
47 | endif()
48 | else()
49 | if(CUDA_VERSION VERSION_LESS 9.0)
50 | LIST(APPEND CUDA_NVCC_FLAGS "-arch=sm_20")
51 | else()
52 | LIST(APPEND CUDA_NVCC_FLAGS "-arch=sm_75")
53 | endif()
54 |
55 | make_cuda_plugin(cudaop1 adsyn.cu)
56 | make_cuda_plugin(cudaop2 pvsops.cu)
57 | # make_cuda_plugin(cudaop3 slidingm.cu)
58 | make_cuda_plugin(cudaop4 conv.cu)
59 | make_cuda_plugin(cudaop5 pconv.cu)
60 | endif()
61 |
62 | CUDA_ADD_CUFFT_TO_TARGET(cudaop2)
63 | CUDA_ADD_CUFFT_TO_TARGET(cudaop5)
64 |
65 | SET(CUDA_VERBOSE_BUILD ON CACHE BOOL "nvcc verbose" FORCE)
66 | else()
67 | message(STATUS "Not building the CUDA opcodes")
68 | endif()
69 |
--------------------------------------------------------------------------------
/6.x/src/jackops/jacko_test.csd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TEST JACKO OPCODES
5 | Michael Gogins
6 |
7 | This csd tests the Jacko opcodes.
8 |
9 | There is a segmentation fault at the end of the performance. This does happen
10 | in the Jacko plugin, but it does not affect the performance.
11 |
12 | Csound not only writes a soundfile using -o, but also sends realtime audio and
13 | MIDI to other Jack clients using Jack connections.
14 |
15 | Before running this piece, in a terminal execute:
16 |
17 | zynaddsubfx --input JACK --output JACK --auto-connect --sample-rate 48000 --buffer-size 128
18 |
19 |
20 |
21 |
22 |
23 |
24 | ; Sampling rate must be the same as Jack's.
25 | sr=48000
26 | ; ksmps must be the same as Jack's frames/period.
27 | ksmps=128
28 | nchnls=2
29 | 0dbfs=40000
30 |
31 | ga_audio_out init 0
32 |
33 | ; Initialize the Jack connections.
34 | JackoInit "default", "csound6"
35 | prints "Initial ports and connections:\n"
36 | JackoInfo
37 | JackoAudioInConnect "system:capture_1", "audio_in_left"
38 | JackoAudioInConnect "system:capture_2", "audio_in_right"
39 | JackoAudioOutConnect "audio_out_left", "system:playback_1"
40 | JackoAudioOutConnect "audio_out_right", "system:playback_2"
41 | JackoMidiInConnect "system:midi_capture_1", "midiin"
42 | JackoMidiOutConnect "midiout", "zynaddsubfx:midi_input"
43 | prints "Final ports and connections:\n"
44 | JackoInfo
45 |
46 | instr 1
47 | print p1, p2, p3, p4, p5
48 | i_frequency = cpsmidinn(p4)
49 | i_amplitude = ampdb(p5)
50 | print i_frequency, i_amplitude
51 | a_out oscil i_amplitude, i_frequency
52 | ga_audio_out += a_out;
53 | endin
54 |
55 | ; Sends notes to an external MIDI synthesizer.
56 | instr 801
57 | print p1, p2, p3, p4, p5
58 | JackoNoteOut "midiout", 0, p4, p5
59 | prints "Sent note to midiout.\n"
60 | endin
61 |
62 | instr 900
63 | print p1, p2, p3
64 | outs ga_audio_out, ga_audio_out
65 | ; Input test is only to see if connection is created.
66 | audio_in_left_ init 0
67 | audio_in_right_ init 0
68 | audio_in_left_ JackoAudioIn "audio_in_left"
69 | audio_in_right_ JackoAudioIn "audio_in_right"
70 | JackoAudioOut "audio_out_left", ga_audio_out
71 | JackoAudioOut "audio_out_right", ga_audio_out
72 | ga_audio_out = 0
73 | endin
74 |
75 | instr 1000
76 | print p1, p2, p3
77 | ; Uncomment the following two lines to test if Jacko hangs Csound.
78 | event "e", 0, 0, 0.1
79 | prints "Ending Csound performance with 'e' event\n"
80 | endin
81 |
82 |
83 |
84 | f 0 60
85 | i1 5 3 63 10
86 | i801 10 3 69 100
87 | i1 15 3 72 10
88 | i900 0 -1
89 | i1000 20 1
90 | e
91 |
92 |
93 |
--------------------------------------------------------------------------------
/7.x/README.md:
--------------------------------------------------------------------------------
1 | Plugins for Csound 7.x
2 | =======
3 |
4 | Currently, the plugins available in this tree are
5 |
6 | - py (requires a Python 3.x installation with dev libs)
7 | **Many opcodes to call Python code**
8 |
9 |
10 | Install location
11 | --------------
12 | The CMake scripts in this repository use the default CS_USER_PLUGIN
13 | location on MacOS and Windows as defined in the Csound build, or a
14 | library instalation directory (customisable) on LINUX. These are:
15 |
16 | - LINUX: depends on both `CMAKE_INSTALL_PREFIX` and `USE_LIB64`. It is then installed in:
17 | * if `USE_LIB64=1` then to
18 | * for doubles: `${CSOUND_INSTALL_PREFIX}/lib64/csound/plugins64-${APIVERSION}`
19 | * for floats: `${CSOUND_INSTALL_PREFIX}/lib64/csound/plugins-${APIVERSION}` (floats)`
20 | * if `USE_LIB64=0` then to
21 | * for doubles: `${CSOUND_INSTALL_PREFIX}/lib/csound/plugins64-${APIVERSION}`
22 | * for floats: `${CSOUND_INSTALL_PREFIX}/lib/csound/plugins-${APIVERSION}`
23 |
24 | - MACOS:
25 | * For doubles: `$HOME/Library/csound/${APIVERSION}/plugins64`
26 | * For floats: `$HOME/Library/csound/${APIVERSION}/plugins`
27 | - Windows:
28 | * For doubles: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins64`
29 | * For floats: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins`
30 |
31 |
32 | Build Instructions for Linux and MacOS
33 | ---
34 |
35 | The build requires Csound to be installed, as well as CMake. With this
36 | in place, you can do :
37 |
38 | ```
39 | $ git clone https://github.com/csound/plugins.git
40 | $ cd plugins
41 | $ mkdir build
42 | $ cd build
43 | $ cmake ../
44 | $ make
45 | ```
46 |
47 | By default, all the plugins are built. If one wants to exclude a
48 | plugin from the build process, one can pass an option to the cmake command.
49 | For example, to exclude the XXX plugin, the `cmake` command would be:
50 |
51 | ```
52 | $ cmake -DXXX_OPCODES=OFF ../
53 | ```
54 |
55 |
56 | To install the opcodes you have built
57 |
58 | ```
59 | $ make install
60 | ```
61 |
62 | Depending on your permissions, you might need to prepend `sudo` to
63 | these commands. After the first build the plugins can be updated with
64 |
65 | ```
66 | $ git pull
67 | $ make
68 | $ make install
69 | ```
70 |
71 | using `sudo` in the last step if raised permissions are needed. On
72 | Linux, the installation location can be set with the relevant CMake
73 | variables as indicated above.
74 |
75 | Csound Location
76 | ------------
77 | CMake will normally find the installed Csound headers (and library)
78 | automatically. However, if your Csound headers and library are not
79 | placed in the usual locations, you can use the following CMake option variables
80 | to tell CMake where they are:
81 |
82 | ```
83 | CSOUND_INCLUDE_DIR_HINT
84 | ```
85 | and
86 |
87 | ```
88 | CSOUND_LIBRARY_DIR_HINT
89 |
--------------------------------------------------------------------------------
/6.x/src/fluidOpcodes/fluidOpcodes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | fluidOpcodes
4 |
5 |
6 |
7 | fluidOpcodes
8 | fluidEngine - creates a fluid engine
9 | fluidLoad - loads a soundfont into a fluid engine
10 | fluidProgramSelect - assign a bank and preset of a soundFont to a midi channel
11 | as well as select
12 | fluidCC - send midi controller data to fluid
13 | fluidPlay - plays a note on a channel
14 | fluidOut - outputs sound from a fluid engine
15 |
16 |
Description
17 |
This family of opcodes are meant to be used together to load and play SoundFonts
18 | using Peter Hannape's Fluidsynth. Use global engines, soundFonts, and outputs.
19 |
20 | Based on work by Michael Gogins.
21 |
22 |
23 |
24 |
Syntax
25 |
iEngineNumber fluidEngine
26 |
27 | iInstrumentNumber fluidLoad sfilename, iEngineNumber
28 |
29 | fluidProgramSelect iEngineNumber, iChannelNumber, iInstrumentNumber,
30 | iBankNumber, iPresetNumber
31 |
32 | fluidCC iEngineNumber, iChannelNumber, iControllerNumber,
33 | kValue
34 |
35 | fluidNote iEngineNumber, iInstrumentNumber, iMidiKeyNumber,
36 | iVelocity
37 |
38 | aLeft, aRight fluidOut iEngineNum
39 |
40 |
41 |
Initialization
42 |
iEngineNumber - engine number assigned from fluid_engine
43 |
44 | iInstrumentNumber - instrument number assigned from fluid_load
45 |
46 | sfilename - String specifying a SoundFont filename
47 |
48 | aLeft - left channel audio output.
49 |
aRight - right channel audio output.
50 |
51 | iMidiKeyNumber - midi key number to play (0-127)
52 |
53 | iVelocity - midi velocity to play at (0-127)
54 |
55 | iBankNum - bank number on soundfont to play
56 |
57 | iPresetNum - preset number on soundfont to play
58 |
59 | iprogram - Number of the fluidsynth program to be assigned to a MIDI channel.
60 |
61 | Performance
62 |
In this implementation, SoundFont effects such as chorus or reverb are used
63 | if and only if they are defaults for the preset. There is no means of turning
64 | such effects on or off, or of changing their parameters, from Csound.
65 |
66 |
67 |
73 |
74 |
Credits
75 |
Opcode library created by Steven Yi, based on fluid opcode
76 | plugin by Michael Gogins.
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/6.x/src/jackops/jackTransport.c:
--------------------------------------------------------------------------------
1 | /**
2 | * jack_transport.c
3 | *
4 | * Copyright (c) 2008 by Cesare Marilungo. All rights reserved.
5 | *
6 | * L I C E N S E
7 | *
8 | * This software is free software; you can redistribute it and/or
9 | * modify it under the terms of the GNU Lesser General Public
10 | * License as published by the Free Software Foundation; either
11 | * version 2.1 of the License, or (at your option) any later version.
12 | *
13 | * This software is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | * Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public
19 | * License along with this software; if not, write to the Free Software
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 | *
22 | * U S A G E
23 | *
24 | * jack_transport 1 - to start jack transport
25 | *
26 | * jack_transport 0 - to stop
27 | *
28 | * the second optional parameter tells where the transport should be located
29 | *
30 | */
31 |
32 | #include
33 | #include
34 | #include
35 |
36 | #include "cs_jack.h"
37 |
38 | enum { STOP, START };
39 |
40 | typedef struct
41 | {
42 | OPDS h;
43 | MYFLT *command;
44 | MYFLT *location;
45 | } JACKTRANSPORT;
46 |
47 | static int32_t jack_transport (CSOUND *csound, JACKTRANSPORT * p)
48 | {
49 | RtJackGlobals *rtjack;
50 | jack_client_t *client;
51 |
52 | rtjack = (RtJackGlobals*)
53 | csound->QueryGlobalVariableNoCheck(csound,
54 | "_rtjackGlobals");
55 | client = rtjack->client;
56 |
57 | if (UNLIKELY(client == NULL)) {
58 | return csound->InitError(csound, "%s", Str("Cannot find Jack client.\n"));
59 | }
60 | else {
61 | //move to specified location (in seconds)
62 | if ((int32_t)(*p->location)>=0) {
63 | MYFLT loc_sec = *p->location;
64 | MYFLT loc_sec_per_sr = loc_sec*csound->GetSr(csound);
65 | jack_transport_locate(client, loc_sec_per_sr);
66 | csound->Warning(csound,
67 | Str("jacktransport: playback head moved "
68 | "at %f seconds\n"), loc_sec);
69 | }
70 | //start or stop
71 | switch ((int32_t
72 | )(*p->command)) {
73 | case START:
74 | csound->Warning(csound, "%s", Str("jacktransport: playing.\n"));
75 | jack_transport_start(client);
76 | break;
77 | case STOP:
78 | csound->Warning(csound, "%s", Str("jacktransport: stopped.\n"));
79 | jack_transport_stop(client);
80 | break;
81 | default:
82 | csound->Warning(csound, "%s", Str("jacktransport: invalid parameter.\n"));
83 | break;
84 | }
85 | }
86 |
87 | return OK;
88 | }
89 |
90 | #define S(x) sizeof(x)
91 |
92 | static OENTRY jackTransport_localops[] = {
93 |
94 | { "jacktransport", S(JACKTRANSPORT), 0, 1, "", "ij",
95 | (SUBR)jack_transport, NULL, NULL },
96 | };
97 |
98 | LINKAGE_BUILTIN(jackTransport_localops)
99 |
--------------------------------------------------------------------------------
/6.x/src/fluidOpcodes/fluidOpcodes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FLUID SYNTH OPCODES
3 | *
4 | * Adapts Fluidsynth to use global engines, soundFonts, and outputs
5 | *
6 | * Based on work by Michael Gogins. License is identical to
7 | * SOUNDFONTS VST License (listed below)
8 | *
9 | * Copyright (c) 2003 by Steven Yi. All rights reserved.
10 | *
11 | * [ORIGINAL INFORMATION BELOW]
12 | *
13 | * S O U N D F O N T S V S T
14 | *
15 | * Adapts Fluidsynth to be both a VST plugin instrument
16 | * and a Csound plugin opcode.
17 | * Copyright (c) 2001-2003 by Michael Gogins. All rights reserved.
18 | *
19 | * L I C E N S E
20 | *
21 | * This software is free software; you can redistribute it and/or
22 | * modify it under the terms of the GNU Lesser General Public
23 | * License as published by the Free Software Foundation; either
24 | * version 2.1 of the License, or (at your option) any later version.
25 | *
26 | * This software is distributed in the hope that it will be useful,
27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 | * Lesser General Public License for more details.
30 | *
31 | * You should have received a copy of the GNU Lesser General Public
32 | * License along with this software; if not, write to the Free Software
33 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 | */
35 |
36 | #ifndef FLUIDOPCODE_H
37 | #define FLUIDOPCODE_H
38 |
39 | #include "csdl.h"
40 | #include
41 |
42 | typedef struct {
43 | OPDS h;
44 | /* OUTPUTS */
45 | MYFLT *iEngineNum;
46 | MYFLT *iReverbEnabled;
47 | MYFLT *iChorusEnabled;
48 | MYFLT *iNumChannels;
49 | MYFLT *iPolyphony;
50 | } FLUIDENGINE;
51 |
52 | typedef struct {
53 | OPDS h;
54 | /* INPUTS */
55 | MYFLT *iEngineNumber, *iChannelNumber, *iInterpMethod;
56 | } FLUID_SET_INTERP_METHOD;
57 |
58 | typedef struct {
59 | OPDS h;
60 | /* OUTPUTS */
61 | MYFLT *iInstrumentNumber;
62 | /* INPUTS */
63 | MYFLT *filename, *iEngineNum, *iListPresets;
64 | } FLUIDLOAD;
65 |
66 | typedef struct {
67 | OPDS h;
68 | /* INPUTS */
69 | MYFLT *iEngineNumber, *iChannelNumber, *iInstrumentNumber, *iBankNumber;
70 | MYFLT *iPresetNumber;
71 | } FLUID_PROGRAM_SELECT;
72 |
73 | typedef struct {
74 | OPDS h;
75 | /* INPUTS */
76 | MYFLT *iEngineNumber, *iChannelNumber, *iControllerNumber, *kVal;
77 | int32_t priorMidiValue;
78 | fluid_synth_t *fluidEngine;
79 | } FLUID_CC;
80 |
81 | typedef struct {
82 | OPDS h;
83 | /* INPUTS */
84 | MYFLT *iEngineNumber, *iChannelNumber, *iMidiKeyNumber, *iVelocity;
85 | int32_t initDone, iChn, iKey;
86 | fluid_synth_t *fluidEngine;
87 | } FLUID_NOTE;
88 |
89 | typedef struct {
90 | OPDS h;
91 | MYFLT *aLeftOut, *aRightOut;
92 | MYFLT *iEngineNum;
93 | fluid_synth_t *fluidEngine;
94 | } FLUIDOUT;
95 |
96 | typedef struct {
97 | OPDS h;
98 | MYFLT *aLeftOut, *aRightOut;
99 | void *fluidGlobals;
100 | } FLUIDALLOUT;
101 |
102 | typedef struct {
103 | OPDS h;
104 | /* Inputs. */
105 | MYFLT *iFluidEngine;
106 | MYFLT *kMidiStatus;
107 | MYFLT *kMidiChannel;
108 | MYFLT *kMidiData1;
109 | MYFLT *kMidiData2;
110 | /* No outputs. */
111 | /* Internal state. */
112 | int32_t priorMidiStatus;
113 | int32_t priorMidiChannel;
114 | int32_t priorMidiData1;
115 | int32_t priorMidiData2;
116 | fluid_synth_t *fluidEngine;
117 | } FLUIDCONTROL;
118 |
119 | #endif
120 |
121 |
--------------------------------------------------------------------------------
/.github/workflows/plugins_build.yml:
--------------------------------------------------------------------------------
1 | name: Csound plugins build
2 |
3 | env:
4 | VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite"
5 |
6 | on:
7 | push:
8 | branches:
9 | - develop
10 | - master
11 | pull_request:
12 | branches:
13 | - develop
14 |
15 | jobs:
16 | build_package:
17 | runs-on: ${{ matrix.os }}
18 |
19 | env:
20 | CSOUND_VERSION: 6.17.2
21 |
22 | strategy:
23 | matrix:
24 | os: [windows-latest]
25 | version: ["6.17.0"]
26 | include:
27 | - os: "windows-latest"
28 | mono: ""
29 | # - os: "ubuntu-latest"
30 | # mono: "mono"
31 | # - os: "macos-latest"
32 | # mono: "mono"
33 |
34 | steps:
35 | - name: Checkout Source Code
36 | uses: actions/checkout@v1
37 | with:
38 | fetch-depth: 1
39 | submodules: true
40 |
41 | - name: Setup platform (windows)
42 | if: startsWith(matrix.os, 'windows')
43 | env:
44 | FAUST_URL: https://github.com/grame-cncm/faust/releases/download/2.60.3/Faust-2.60.3-win64.exe
45 | run: |
46 | Invoke-WebRequest $env:FAUST_URL -OutFile faustInstaller.exe
47 | ./faustInstaller.exe /S
48 | echo "C:/Program Files/csound/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
49 | echo "OPCODE6DIR64=C:/Program Files/csound/plugins64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
50 | echo "PYTHONPATH=C:/Program Files/csound/bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
51 | echo "RAWWAVE_PATH=C:/Program Files/csound/samples" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
52 | .\6.x\vcpkg\bootstrap-vcpkg.bat
53 | choco install csound --version=6.17.0
54 | echo $GITHUB_ENV
55 | ls 'C:\Program Files\Faust\'
56 | echo "C:\Program Files\Faust\;C:\Program Files\Faust\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
57 |
58 | # - name: Setup platform (linux)
59 | # if: startsWith(matrix.os, 'ubuntu')
60 | # run: |
61 | # ./vcpkg/bootstrap-vcpkg.sh
62 | # sudo apt-get update
63 | # sudo apt-get install libcsound64-dev
64 |
65 | # - name: Setup platform (macos)
66 | # if: startsWith(matrix.os, 'macos')
67 | # run: |
68 | # ./vcpkg/bootstrap-vcpkg.sh
69 | # brew install csound
70 |
71 | - name: Setup VCPKG cache
72 | shell: bash
73 | run: |
74 | ${{ matrix.mono }} `./6.x/vcpkg/vcpkg fetch nuget | tail -n 1` \
75 | sources add \
76 | -source "https://nuget.pkg.github.com/csound/index.json" \
77 | -storepasswordincleartext \
78 | -name "GitHub" \
79 | -username "csound" \
80 | -password "${{ secrets.GITHUB_TOKEN }}"
81 | ${{ matrix.mono }} `./6.x/vcpkg/vcpkg fetch nuget | tail -n 1` \
82 | setapikey "${{ secrets.GITHUB_TOKEN }}" \
83 | -source "https://nuget.pkg.github.com/csound/index.json"
84 |
85 | - name: Generate CMake build
86 | run: cmake 6.x/. -B build -DUSE_VCPKG=1
87 |
88 | - name: Build plugins
89 | run: cmake --build build --config Release
90 |
91 | - name: Build installer
92 | run: iscc /o. .\installer\win64\Installer.iss
93 |
94 | - name: Upload installer
95 | uses: actions/upload-artifact@v2
96 | with:
97 | name: Csound_win_x64-${{env.CSOUND_VERSION}}.${{github.run_number}}-plugins-installer
98 | path: ./csound6-plugins-win_x86_64-*.exe
99 | if-no-files-found: error
100 |
--------------------------------------------------------------------------------
/6.x/src/stk/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | option(BUILD_STK_OPCODES "Build the stk opcodes" ON)
2 |
3 | if(BUILD_STK_OPCODES)
4 | if(DEFAULT_STK_RAWWAVE_PATH)
5 | set(rawwave_path "-DDEFAULT_RAWWAVE_PATH=\"${DEFAULT_STK_RAWWAVE_PATH}\"")
6 | endif()
7 |
8 | if(USE_VCPKG)
9 | make_plugin(stkops stkOpcodes.cpp)
10 | find_package(unofficial-libstk CONFIG REQUIRED)
11 | target_link_libraries(stkops PRIVATE unofficial::libstk::libstk)
12 | target_include_directories(stkops PRIVATE ${CSOUND_INCLUDE_DIRS})
13 | message(STATUS "Building STK opcodes for MSVC")
14 | else()
15 | find_package(STK)
16 |
17 | if(STK_LIBRARY)
18 | find_path(STK_INCLUDE_DIR Stk.h
19 | /usr/include/stk
20 | /usr/local/include/stk)
21 |
22 | check_deps(BUILD_STK_OPCODES STK_INCLUDE_DIR)
23 |
24 | if(STK_INCLUDE_DIR)
25 | make_plugin(stkops stkOpcodes.cpp)
26 | target_include_directories(stkops PRIVATE ${CSOUND_INCLUDE_DIRS} ${STK_INCLUDE_DIR})
27 | message(STATUS "Building STK opcodes.")
28 |
29 | if(BUILD_STATIC_LIBRARY)
30 | if(WIN32)
31 | add_library(stk STATIC IMPORTED)
32 | set_target_properties(stk PROPERTIES IMPORTED_LOCATION ${STK_LIBRARY})
33 | target_link_libraries(stkops stk)
34 | else()
35 | target_link_libraries(stkops ${STK_LIBRARY})
36 | endif()
37 | else()
38 | target_link_libraries(stkops ${STK_LIBRARIES} ${PTHREAD_LIBRARY})
39 | endif()
40 |
41 | target_compile_definitions(stkops PRIVATE ${rawwave_path})
42 | endif()
43 | else()
44 | set(stk_remove_srcs
45 | src/InetWvIn.cpp src/InetWvOut.cpp
46 | src/Mutex.cpp src/RtAudio.cpp
47 | src/RtMidi.cpp src/Messager.cpp
48 | src/RtWvIn.cpp src/RtWvOut.cpp
49 | src/Socket.cpp src/TcpClient.cpp
50 | src/TcpServer.cpp src/Thread.cpp
51 | src/UdpSocket.cpp
52 | )
53 |
54 | file(GLOB stk_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*)
55 | list(REMOVE_ITEM stk_srcs ${stk_remove_srcs})
56 | list(APPEND stk_srcs stkOpcodes.cpp)
57 |
58 | # Assume that if this file exists, then we have the sources
59 | find_file(STK_FOUND
60 | NAMES src/InetWvIn.cpp
61 | HINTS ${CMAKE_CURRENT_SOURCE_DIR}
62 | )
63 |
64 | find_path(STK_INCLUDE_DIR Stk.h ./include)
65 | check_deps(BUILD_STK_OPCODES STK_FOUND STK_INCLUDE_DIR)
66 |
67 | make_plugin(stkops "${stk_srcs}")
68 | target_include_directories(stkops PRIVATE
69 | ${CSOUND_INCLUDE_DIRS}
70 | ${CMAKE_CURRENT_SOURCE_DIR}/include
71 | ${CMAKE_CURRENT_SOURCE_DIR}/include/stk
72 | ${CMAKE_CURRENT_SOURCE_DIR}/src
73 | )
74 | set(stkdefs "-D__STK_REALTIME__")
75 |
76 | if(APPLE)
77 | list(APPEND stkdefs "-D__OS_MACOSX__")
78 | list(REMOVE_ITEM stkdefs "-D__STK_REALTIME__")
79 | elseif(LINUX)
80 | list(APPEND stkdefs "-D__OS_LINUX__")
81 | list(APPEND stkdefs "-D__LINUX_ALSA__")
82 | elseif(WIN32)
83 | list(APPEND stkdefs "-D__OS_WINDOWS__")
84 | endif()
85 |
86 | if(BIG_ENDIAN)
87 | list(APPEND stkdefs "-D__BIG_ENDIAN__")
88 | else()
89 | list(APPEND stkdefs "-D__LITTLE_ENDIAN__")
90 | endif()
91 |
92 | target_compile_definitions(stkops PRIVATE ${stkdefs} ${rawwave_path})
93 | endif()
94 | endif()
95 | endif()
96 |
97 |
--------------------------------------------------------------------------------
/6.x/src/jackops/cs_jack.h:
--------------------------------------------------------------------------------
1 | /*
2 | .h:
3 |
4 | Copyright (C) 2008 by Cesare Marilungo
5 |
6 | This file is part of Csound.
7 |
8 | The Csound Library is free software; you can redistribute it
9 | and/or modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 2.1 of the License, or (at your option) any later version.
12 |
13 | Csound is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with Csound; if not, write to the Free Software
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 | 02110-1301 USA
22 | */
23 |
24 | #define MAX_NAME_LEN 32 /* for client and port name */
25 |
26 | typedef struct RtJackBuffer_ {
27 | #ifdef LINUX
28 | pthread_mutex_t csndLock; /* signaled by process callback */
29 | pthread_mutex_t jackLock; /* signaled by audio thread */
30 | #else
31 | void *csndLock; /* signaled by process callback */
32 | void *jackLock; /* signaled by audio thread */
33 | #endif
34 | jack_default_audio_sample_t **inBufs; /* 'nChannels' capture buffers */
35 | jack_default_audio_sample_t **outBufs; /* 'nChannels' playback buffers */
36 | } RtJackBuffer;
37 |
38 | typedef struct RtJackGlobals_ {
39 | CSOUND *csound; /* Csound instance pointer */
40 | int jackState; /* 0: OK, 1: sr changed, 2: quit */
41 | char clientName[MAX_NAME_LEN + 1]; /* client name */
42 | char inputPortName[MAX_NAME_LEN + 1]; /* input port name prefix */
43 | char outputPortName[MAX_NAME_LEN + 1]; /* output port name prefix */
44 | int sleepTime; /* sleep time in us (deprecated) */
45 | char *inDevName; /* device name for -i adc */
46 | char *outDevName; /* device name for -o dac */
47 | int sampleRate; /* sample rate in Hz */
48 | int nChannels; /* number of channels */
49 | int nChannels_i; /* number of in channels */
50 | int bufSize; /* buffer size in sample frames */
51 | int nBuffers; /* number of buffers (>= 2) */
52 | int inputEnabled; /* non-zero if capture (adc) is on */
53 | int outputEnabled; /* non-zero if playback (dac) is on */
54 | int csndBufCnt; /* current buffer in Csound thread */
55 | int csndBufPos; /* buffer position in Csound thread */
56 | int jackBufCnt; /* current buffer in JACK callback */
57 | int jackBufPos; /* buffer position in JACK callback */
58 | jack_client_t *client; /* JACK client pointer */
59 | jack_port_t **inPorts; /* 'nChannels' ports for capture */
60 | jack_default_audio_sample_t **inPortBufs;
61 | jack_port_t **outPorts; /* 'nChannels' ports for playback */
62 | jack_default_audio_sample_t **outPortBufs;
63 | RtJackBuffer **bufs; /* 'nBuffers' I/O buffers */
64 | int xrunFlag; /* non-zero if an xrun has occured */
65 | jack_client_t *listclient;
66 | int outDevNum, inDevNum; /* select devs by number */
67 | } RtJackGlobals;
68 |
--------------------------------------------------------------------------------
/6.x/README.md:
--------------------------------------------------------------------------------
1 | Plugins for Csound 6.x
2 | =======
3 |
4 | Currently, the plugins available in this tree are
5 |
6 | - AbletonLive Link (requires Ableton link)
7 | **link_create link_enable link_is_enabled link_tempo_set link_tempo_get link_beat_get link_metro link_beat_request link_beat_force**
8 |
9 | - chua (requires Eigen library, header-only)
10 | **chuap**
11 |
12 | - Faust (requires libfaust)
13 | **faustgen faustcompile faustaudio faustdsp faustplay faustctl**
14 |
15 | - image (requires libpng)
16 | **imageload imagesave imagecreate imagesize imagegetpixel imagesetpixel imagefree**
17 |
18 | - py (requires a Python 3.x installation with dev libs)
19 | **Many opcodes to call Python code**
20 |
21 | - widgets (requires the FLTK LIB)
22 | **FLTK-based widgets.**
23 | NB: These opcodes do not work correctly on MacOS due
24 | to incompatibilities with the operating system.
25 |
26 | - virtual keyboard (requires the FLTK LIB)
27 | **Virtual MIDI keyboard midi backend**
28 |
29 | - STK opcodes (requires STK library)
30 | **Physical model opcodes using the STK library**
31 |
32 |
33 | Install location
34 | --------------
35 | The CMake scripts in this repository use the default CS_USER_PLUGIN
36 | location on MacOS and Windows as defined in the Csound build, or a
37 | library instalation directory (customisable) on LINUX. These are:
38 |
39 | - LINUX: depends on both `CMAKE_INSTALL_PREFIX` and `USE_LIB64`. It is then installed in:
40 | * if `USE_LIB64=1` then to
41 | * for doubles: `${CSOUND_INSTALL_PREFIX}/lib64/csound/plugins64-${APIVERSION}`
42 | * for floats: `${CSOUND_INSTALL_PREFIX}/lib64/csound/plugins-${APIVERSION}` (floats)`
43 | * if `USE_LIB64=0` then to
44 | * for doubles: `${CSOUND_INSTALL_PREFIX}/lib/csound/plugins64-${APIVERSION}`
45 | * for floats: `${CSOUND_INSTALL_PREFIX}/lib/csound/plugins-${APIVERSION}`
46 |
47 | - MACOS:
48 | * For doubles: `$HOME/Library/csound/${APIVERSION}/plugins64`
49 | * For floats: `$HOME/Library/csound/${APIVERSION}/plugins`
50 | - Windows:
51 | * For doubles: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins64`
52 | * For floats: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins`
53 |
54 |
55 | Build Instructions for Linux and MacOS
56 | ---
57 |
58 | The build requires Csound to be installed, as well as CMake. With this
59 | in place, you can do :
60 |
61 | ```
62 | $ git clone https://github.com/csound/plugins.git
63 | $ cd plugins
64 | $ mkdir build
65 | $ cd build
66 | $ cmake ../
67 | $ make
68 | ```
69 |
70 | By default, all the plugins are built. If one wants to exclude a
71 | plugin from the build process, one can pass an option to the cmake command.
72 | For example, to exclude the chua plugin, the `cmake` command would be:
73 |
74 | ```
75 | $ cmake -DBUILD_CHUA_OPCODES=OFF ../
76 | ```
77 |
78 | For the FLTK dependent plugins, the configuration variable used is
79 | `USE_FLTK`.
80 |
81 | To install the opcodes you have built
82 |
83 | ```
84 | $ make install
85 | ```
86 |
87 | Depending on your permissions, you might need to prepend `sudo` to
88 | these commands. After the first build the plugins can be updated with
89 |
90 | ```
91 | $ git pull
92 | $ make
93 | $ make install
94 | ```
95 |
96 | using `sudo` in the last step if raised permissions are needed. On
97 | Linux, the installation location can be set with the relevant CMake
98 | variables as indicated above.
99 |
100 | Csound Location
101 | ------------
102 | CMake will normally find the installed Csound headers (and library)
103 | automatically. However, if your Csound headers and library are not
104 | placed in the usual locations, you can use the following CMake option variables
105 | to tell CMake where they are:
106 |
107 | ```
108 | CSOUND_INCLUDE_DIR_HINT
109 | ```
110 | and
111 |
112 | ```
113 | CSOUND_LIBRARY_DIR_HINT
114 | ```
115 |
--------------------------------------------------------------------------------
/6.x/cmake/Modules/FindEIGEN3.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Eigen3 lib
2 | #
3 | # This module supports requiring a minimum version, e.g. you can do
4 | # find_package(Eigen3 3.1.2)
5 | # to require version 3.1.2 or newer of Eigen3.
6 | #
7 | # Once done this will define
8 | #
9 | # EIGEN3_FOUND - system has eigen lib with correct version
10 | # EIGEN3_INCLUDE_DIR - the eigen include directory
11 | # EIGEN3_VERSION - eigen version
12 | #
13 | # This module reads hints about search locations from
14 | # the following enviroment variables:
15 | #
16 | # EIGEN3_ROOT
17 | # EIGEN3_ROOT_DIR
18 |
19 | # Copyright (c) 2006, 2007 Montel Laurent,
20 | # Copyright (c) 2008, 2009 Gael Guennebaud,
21 | # Copyright (c) 2009 Benoit Jacob
22 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license.
23 |
24 | if(NOT Eigen3_FIND_VERSION)
25 | if(NOT Eigen3_FIND_VERSION_MAJOR)
26 | set(Eigen3_FIND_VERSION_MAJOR 2)
27 | endif(NOT Eigen3_FIND_VERSION_MAJOR)
28 | if(NOT Eigen3_FIND_VERSION_MINOR)
29 | set(Eigen3_FIND_VERSION_MINOR 91)
30 | endif(NOT Eigen3_FIND_VERSION_MINOR)
31 | if(NOT Eigen3_FIND_VERSION_PATCH)
32 | set(Eigen3_FIND_VERSION_PATCH 0)
33 | endif(NOT Eigen3_FIND_VERSION_PATCH)
34 |
35 | set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
36 | endif(NOT Eigen3_FIND_VERSION)
37 |
38 | macro(_eigen3_check_version)
39 | file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
40 |
41 | string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
42 | set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
43 | string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
44 | set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
45 | string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
46 | set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
47 |
48 | set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
49 | if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
50 | set(EIGEN3_VERSION_OK FALSE)
51 | else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
52 | set(EIGEN3_VERSION_OK TRUE)
53 | endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
54 |
55 | if(NOT EIGEN3_VERSION_OK)
56 |
57 | message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
58 | "but at least version ${Eigen3_FIND_VERSION} is required")
59 | endif(NOT EIGEN3_VERSION_OK)
60 | endmacro(_eigen3_check_version)
61 |
62 | if (EIGEN3_INCLUDE_DIR)
63 |
64 | # in cache already
65 | _eigen3_check_version()
66 | set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
67 |
68 | else (EIGEN3_INCLUDE_DIR)
69 |
70 | # search first if an Eigen3Config.cmake is available in the system,
71 | # if successful this would set EIGEN3_INCLUDE_DIR and the rest of
72 | # the script will work as usual
73 | find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET)
74 |
75 |
76 | if(NOT EIGEN3_INCLUDE_DIR)
77 | find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
78 | HINTS
79 | ENV EIGEN3_ROOT
80 | ENV EIGEN3_ROOT_DIR
81 | PATHS
82 | ${CMAKE_INSTALL_PREFIX}/include
83 | /usr/local/include
84 | ${CMAKE_INSTALL_PREFIX}
85 | $ENV{HOME}/include/
86 | PATH_SUFFIXES eigen3 eigen Eigen
87 | )
88 | endif(NOT EIGEN3_INCLUDE_DIR)
89 |
90 | if(EIGEN3_INCLUDE_DIR)
91 | _eigen3_check_version()
92 | endif(EIGEN3_INCLUDE_DIR)
93 |
94 | include(FindPackageHandleStandardArgs)
95 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
96 |
97 | mark_as_advanced(EIGEN3_INCLUDE_DIR)
98 |
99 | endif(EIGEN3_INCLUDE_DIR)
100 |
101 |
--------------------------------------------------------------------------------
/7.x/cmake/Modules/FindEIGEN3.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Eigen3 lib
2 | #
3 | # This module supports requiring a minimum version, e.g. you can do
4 | # find_package(Eigen3 3.1.2)
5 | # to require version 3.1.2 or newer of Eigen3.
6 | #
7 | # Once done this will define
8 | #
9 | # EIGEN3_FOUND - system has eigen lib with correct version
10 | # EIGEN3_INCLUDE_DIR - the eigen include directory
11 | # EIGEN3_VERSION - eigen version
12 | #
13 | # This module reads hints about search locations from
14 | # the following enviroment variables:
15 | #
16 | # EIGEN3_ROOT
17 | # EIGEN3_ROOT_DIR
18 |
19 | # Copyright (c) 2006, 2007 Montel Laurent,
20 | # Copyright (c) 2008, 2009 Gael Guennebaud,
21 | # Copyright (c) 2009 Benoit Jacob
22 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license.
23 |
24 | if(NOT Eigen3_FIND_VERSION)
25 | if(NOT Eigen3_FIND_VERSION_MAJOR)
26 | set(Eigen3_FIND_VERSION_MAJOR 2)
27 | endif(NOT Eigen3_FIND_VERSION_MAJOR)
28 | if(NOT Eigen3_FIND_VERSION_MINOR)
29 | set(Eigen3_FIND_VERSION_MINOR 91)
30 | endif(NOT Eigen3_FIND_VERSION_MINOR)
31 | if(NOT Eigen3_FIND_VERSION_PATCH)
32 | set(Eigen3_FIND_VERSION_PATCH 0)
33 | endif(NOT Eigen3_FIND_VERSION_PATCH)
34 |
35 | set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
36 | endif(NOT Eigen3_FIND_VERSION)
37 |
38 | macro(_eigen3_check_version)
39 | file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
40 |
41 | string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
42 | set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
43 | string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
44 | set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
45 | string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
46 | set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
47 |
48 | set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
49 | if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
50 | set(EIGEN3_VERSION_OK FALSE)
51 | else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
52 | set(EIGEN3_VERSION_OK TRUE)
53 | endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
54 |
55 | if(NOT EIGEN3_VERSION_OK)
56 |
57 | message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
58 | "but at least version ${Eigen3_FIND_VERSION} is required")
59 | endif(NOT EIGEN3_VERSION_OK)
60 | endmacro(_eigen3_check_version)
61 |
62 | if (EIGEN3_INCLUDE_DIR)
63 |
64 | # in cache already
65 | _eigen3_check_version()
66 | set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
67 |
68 | else (EIGEN3_INCLUDE_DIR)
69 |
70 | # search first if an Eigen3Config.cmake is available in the system,
71 | # if successful this would set EIGEN3_INCLUDE_DIR and the rest of
72 | # the script will work as usual
73 | find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET)
74 |
75 |
76 | if(NOT EIGEN3_INCLUDE_DIR)
77 | find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
78 | HINTS
79 | ENV EIGEN3_ROOT
80 | ENV EIGEN3_ROOT_DIR
81 | PATHS
82 | ${CMAKE_INSTALL_PREFIX}/include
83 | /usr/local/include
84 | ${CMAKE_INSTALL_PREFIX}
85 | $ENV{HOME}/include/
86 | PATH_SUFFIXES eigen3 eigen Eigen
87 | )
88 | endif(NOT EIGEN3_INCLUDE_DIR)
89 |
90 | if(EIGEN3_INCLUDE_DIR)
91 | _eigen3_check_version()
92 | endif(EIGEN3_INCLUDE_DIR)
93 |
94 | include(FindPackageHandleStandardArgs)
95 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
96 |
97 | mark_as_advanced(EIGEN3_INCLUDE_DIR)
98 |
99 | endif(EIGEN3_INCLUDE_DIR)
100 |
101 |
--------------------------------------------------------------------------------
/6.x/src/hdf5/HDF5IO.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Edward Costello
3 | *
4 | * This software is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * This software 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 GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this software; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | *
18 | */
19 |
20 | #include "csdl.h"
21 | #include "hdf5.h"
22 | #include
23 |
24 | typedef enum ArgumentType
25 | {
26 | STRING_VAR,
27 | ARATE_VAR,
28 | KRATE_VAR,
29 | IRATE_VAR,
30 | ARATE_ARRAY,
31 | KRATE_ARRAY,
32 | IRATE_ARRAY,
33 | UNKNOWN
34 | } ArgumentType;
35 |
36 | typedef struct _fft {
37 | OPDS h;
38 | ARRAYDAT *out;
39 | ARRAYDAT *in, *in2;
40 | MYFLT *f;
41 | MYFLT b;
42 | int32_t n;
43 | void *setup;
44 | AUXCH mem;
45 | } nFFT;
46 |
47 |
48 |
49 | typedef struct HDF5Dataset
50 | {
51 | char *datasetName;
52 | AUXCH datasetNameMemory;
53 | void *argumentPointer;
54 | ArgumentType writeType;
55 | ArgumentType readType;
56 | int32_t rank;
57 | hsize_t *chunkDimensions;
58 | AUXCH chunkDimensionsMemory;
59 | hsize_t *maxDimensions;
60 | AUXCH maxDimensionsMemory;
61 | hsize_t *offset;
62 | AUXCH offsetMemory;
63 | hsize_t *datasetSize;
64 | AUXCH datasetSizeMemory;
65 |
66 | hid_t datasetID;
67 |
68 | size_t elementCount;
69 | MYFLT *sampleBuffer;
70 | AUXCH sampleBufferMemory;
71 |
72 | bool readAll;
73 |
74 | } HDF5Dataset;
75 |
76 | typedef struct HDF5File
77 | {
78 | hid_t fileHandle;
79 | char *fileName;
80 | hid_t floatSize;
81 |
82 | } HDF5File;
83 |
84 |
85 | HDF5File *HDF5IO_newHDF5File(CSOUND *csound, AUXCH *hdf5FileMemory,
86 | STRINGDAT *path, bool openForWriting);
87 |
88 | void HDF5IO_deleteHDF5File(CSOUND *csound, HDF5File *hdf5File);
89 |
90 | typedef struct HDF5Write
91 | {
92 | OPDS h;
93 | MYFLT *arguments[20];
94 | int32_t inputArgumentCount;
95 | size_t ksmps;
96 | HDF5File *hdf5File;
97 | AUXCH hdf5FileMemory;
98 | HDF5Dataset *datasets;
99 | AUXCH datasetsMemory;
100 |
101 | } HDF5Write;
102 |
103 | int32_t HDF5Write_initialise(CSOUND *csound, HDF5Write *self);
104 |
105 | int32_t HDF5Write_process(CSOUND *csound, HDF5Write *self);
106 |
107 | int32_t HDF5Write_finish(CSOUND *csound, void *inReference);
108 |
109 | void HDF5Write_checkArgumentSanity(CSOUND *csound, const HDF5Write *self);
110 |
111 | void HDF5Write_createDatasets(CSOUND *csound, HDF5Write *self);
112 |
113 | void HDF5Write_newArrayDataset(CSOUND *csound, HDF5Write *self,
114 | HDF5Dataset *dataset);
115 |
116 | void HDF5Write_deleteArrayDataset(CSOUND *csound, HDF5Dataset *dataset);
117 |
118 |
119 | typedef struct HDF5Read
120 | {
121 | OPDS h;
122 | MYFLT *arguments[20];
123 | STRINGDAT *path;
124 | STRINGDAT *names[20];
125 | int32_t inputArgumentCount;
126 | int32_t outputArgumentCount;
127 | size_t ksmps;
128 | HDF5File *hdf5File;
129 | AUXCH hdf5FileMemory;
130 | HDF5Dataset *datasets;
131 | AUXCH datasetsMemory;
132 | bool isSampleAccurate;
133 |
134 | } HDF5Read;
135 |
136 | int32_t HDF5Read_initialise(CSOUND *csound, HDF5Read *self);
137 |
138 | int32_t HDF5Read_process(CSOUND *csound, HDF5Read *self);
139 |
140 | int32_t HDF5Read_finish(CSOUND *csound, void *inReference);
141 |
142 | void HDF5Read_checkArgumentSanity(CSOUND *csound, const HDF5Read *self);
143 |
144 | void HDF5Read_openDatasets(CSOUND *csound, HDF5Read *self);
145 |
--------------------------------------------------------------------------------
/6.x/src/stk/Android/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | CSOUND_SRC_ROOT := ../../../..
6 |
7 | LOCAL_MODULE := libstk
8 |
9 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../stk/include $(LOCAL_PATH)/../../stk/src $(LOCAL_PATH)/../../../../Engine $(LOCAL_PATH)/../../../../H $(LOCAL_PATH)/../../../../include $(LOCAL_PATH)/../../../.. $(LOCAL_PATH)/../../../ $(NDK_MODULE_PATH)/libsndfile-android/jni $(LOCAL_PATH)/../../../CsoundAndroid/jni
10 | LOCAL_CFLAGS := -O3 -D__BUILDING_LIBCSOUND -DENABLE_NEW_PARSER -DLINUX -DHAVE_DIRENT_H -DHAVE_FCNTL_H -DHAVE_UNISTD_H -DHAVE_STDINT_H -DHAVE_SYS_TIME_H -DHAVE_SYS_TYPES_H -DHAVE_TERMIOS_H
11 | # Might need this: -DDEFAULT_RAWWAVE_PATH=${DEFAULT_STK_RAWWAVE_PATH}
12 | LOCAL_CPPFLAGS :=$(LOCAL_CFLAGS)
13 | LOCAL_CPPFLAGS += -std=c++11 -pthread -frtti -fexceptions
14 | LOCAL_LDFLAGS += -Wl,--export-dynamic
15 | ###
16 |
17 | # OMIT:
18 | # src/InetWvIn.cpp src/InetWvOut.cpp
19 | # src/Mutex.cpp src/RtAudio.cpp
20 | # src/RtMidi.cpp
21 | # src/RtWvIn.cpp src/RtWvOut.cpp
22 | # src/Socket.cpp src/TcpClient.cpp
23 | # src/TcpServer.cpp src/Thread.cpp
24 | # src/UdpSocket.cpp)
25 |
26 | LOCAL_SRC_FILES := $(CSOUND_SRC_ROOT)/Opcodes/stk/stkOpcodes.cpp \
27 | ../../stk/src/ADSR.cpp \
28 | ../../stk/src/Asymp.cpp \
29 | ../../stk/src/BandedWG.cpp \
30 | ../../stk/src/BeeThree.cpp \
31 | ../../stk/src/BiQuad.cpp \
32 | ../../stk/src/Blit.cpp \
33 | ../../stk/src/BlitSaw.cpp \
34 | ../../stk/src/BlitSquare.cpp \
35 | ../../stk/src/BlowBotl.cpp \
36 | ../../stk/src/BlowHole.cpp \
37 | ../../stk/src/Bowed.cpp \
38 | ../../stk/src/Brass.cpp \
39 | ../../stk/src/Chorus.cpp \
40 | ../../stk/src/Clarinet.cpp \
41 | ../../stk/src/DelayA.cpp \
42 | ../../stk/src/Delay.cpp \
43 | ../../stk/src/DelayL.cpp \
44 | ../../stk/src/Drummer.cpp \
45 | ../../stk/src/Echo.cpp \
46 | ../../stk/src/Envelope.cpp \
47 | ../../stk/src/FileLoop.cpp \
48 | ../../stk/src/FileRead.cpp \
49 | ../../stk/src/FileWrite.cpp \
50 | ../../stk/src/FileWvIn.cpp \
51 | ../../stk/src/FileWvOut.cpp \
52 | ../../stk/src/Fir.cpp \
53 | ../../stk/src/Flute.cpp \
54 | ../../stk/src/FM.cpp \
55 | ../../stk/src/FMVoices.cpp \
56 | ../../stk/src/FormSwep.cpp \
57 | ../../stk/src/FreeVerb.cpp \
58 | ../../stk/src/Granulate.cpp \
59 | ../../stk/src/Guitar.cpp \
60 | ../../stk/src/HevyMetl.cpp \
61 | ../../stk/src/Iir.cpp \
62 | ../../stk/src/JCRev.cpp \
63 | ../../stk/src/LentPitShift.cpp \
64 | ../../stk/src/Mandolin.cpp \
65 | ../../stk/src/Mesh2D.cpp \
66 | ../../stk/src/Messager.cpp \
67 | ../../stk/src/MidiFileIn.cpp \
68 | ../../stk/src/ModalBar.cpp \
69 | ../../stk/src/Modal.cpp \
70 | ../../stk/src/Modulate.cpp \
71 | ../../stk/src/Moog.cpp \
72 | ../../stk/src/Noise.cpp \
73 | ../../stk/src/NRev.cpp \
74 | ../../stk/src/OnePole.cpp \
75 | ../../stk/src/OneZero.cpp \
76 | ../../stk/src/PercFlut.cpp \
77 | ../../stk/src/Phonemes.cpp \
78 | ../../stk/src/PitShift.cpp \
79 | ../../stk/src/Plucked.cpp \
80 | ../../stk/src/PoleZero.cpp \
81 | ../../stk/src/PRCRev.cpp \
82 | ../../stk/src/Resonate.cpp \
83 | ../../stk/src/Rhodey.cpp \
84 | ../../stk/src/Sampler.cpp \
85 | ../../stk/src/Saxofony.cpp \
86 | ../../stk/src/Shakers.cpp \
87 | ../../stk/src/Simple.cpp \
88 | ../../stk/src/SineWave.cpp \
89 | ../../stk/src/SingWave.cpp \
90 | ../../stk/src/Sitar.cpp \
91 | ../../stk/src/Skini.cpp \
92 | ../../stk/src/Sphere.cpp \
93 | ../../stk/src/StifKarp.cpp \
94 | ../../stk/src/Stk.cpp \
95 | ../../stk/src/TapDelay.cpp \
96 | ../../stk/src/TubeBell.cpp \
97 | ../../stk/src/Twang.cpp \
98 | ../../stk/src/TwoPole.cpp \
99 | ../../stk/src/TwoZero.cpp \
100 | ../../stk/src/Voicer.cpp \
101 | ../../stk/src/VoicForm.cpp \
102 | ../../stk/src/Whistle.cpp \
103 | ../../stk/src/Wurley.cpp
104 |
105 | include $(BUILD_SHARED_LIBRARY)
106 |
107 |
--------------------------------------------------------------------------------
/6.x/src/widgets/winFLTK.h:
--------------------------------------------------------------------------------
1 | /*
2 | winFLTK.h:
3 |
4 | Copyright (C) 2006 Istvan Varga
5 |
6 | This file is part of Csound.
7 |
8 | The Csound Library is free software; you can redistribute it
9 | and/or modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 2.1 of the License, or (at your option) any later version.
12 |
13 | Csound is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with Csound; if not, write to the Free Software
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 | 02110-1301 USA
22 | */
23 |
24 | #ifndef CSOUND_WINFLTK_H
25 | #define CSOUND_WINFLTK_H
26 |
27 | #include "csdl.h"
28 | #ifdef __cplusplus
29 | #include
30 | #endif
31 |
32 | /**
33 | * FLTK flags is the sum of any of the following values:
34 | * 1 (input): disable widget opcodes by setting up dummy opcodes instead
35 | * 2 (input): disable FLTK graphs
36 | * 4 (input): disable the use of a separate thread for widget opcodes
37 | * 8 (input): disable the use of Fl::lock() and Fl::unlock()
38 | * 16 (input): disable the use of Fl::awake()
39 | * 32 (output): widget opcodes are used
40 | * 64 (output): FLTK graphs are used
41 | * 128 (input): disable widget opcodes by not registering any opcodes
42 | * 256 (input): disable the use of Fl::wait() (implies no widget thread)
43 | */
44 |
45 | static inline int getFLTKFlags(CSOUND *csound)
46 | {
47 | return (*((int*) csound->QueryGlobalVariableNoCheck(csound, "FLTK_Flags")));
48 | }
49 |
50 | static inline int *getFLTKFlagsPtr(CSOUND *csound)
51 | {
52 | return ((int*) csound->QueryGlobalVariableNoCheck(csound, "FLTK_Flags"));
53 | }
54 |
55 | #ifdef __cplusplus
56 |
57 | static inline void Fl_lock(CSOUND *csound)
58 | {
59 | #ifdef NO_FLTK_THREADS
60 | (void) csound;
61 | #else
62 | if (!(getFLTKFlags(csound) & 8)) {
63 | Fl::lock();
64 | }
65 | #endif
66 | }
67 |
68 | static inline void Fl_unlock(CSOUND *csound)
69 | {
70 | #ifdef NO_FLTK_THREADS
71 | (void) csound;
72 | #else
73 | if (!(getFLTKFlags(csound) & 8)) {
74 | Fl::unlock();
75 | }
76 | #endif
77 | }
78 |
79 | static inline void Fl_awake(CSOUND *csound)
80 | {
81 | #ifdef NO_FLTK_THREADS
82 | (void) csound;
83 | #else
84 | if (!(getFLTKFlags(csound) & 16)) {
85 | Fl::awake();
86 | }
87 | #endif
88 | }
89 |
90 | static inline void Fl_wait(CSOUND *csound, double seconds)
91 | {
92 | if (!(getFLTKFlags(csound) & 256))
93 | Fl::wait(seconds);
94 | }
95 |
96 | static inline void Fl_wait_locked(CSOUND *csound, double seconds)
97 | {
98 | int fltkFlags;
99 |
100 | fltkFlags = getFLTKFlags(csound);
101 | if (!(fltkFlags & 256)) {
102 | #ifndef NO_FLTK_THREADS
103 | if (!(fltkFlags & 8))
104 | Fl::lock();
105 | #endif
106 | Fl::wait(seconds);
107 | #ifndef NO_FLTK_THREADS
108 | if (!(fltkFlags & 8))
109 | Fl::unlock();
110 | #endif
111 | }
112 | }
113 |
114 | #endif /* __cplusplus */
115 |
116 | #ifdef __cplusplus
117 | extern "C" {
118 | #endif
119 |
120 | extern int CsoundYield_FLTK(CSOUND *);
121 | extern void DrawGraph_FLTK(CSOUND *, WINDAT *);
122 | extern int ExitGraph_FLTK(CSOUND *);
123 | extern void kill_graph(CSOUND *, uintptr_t);
124 | extern void KillXYin_FLTK(CSOUND *, XYINDAT *);
125 | extern uintptr_t MakeWindow_FLTK(CSOUND *, char *);
126 | extern void MakeXYin_FLTK(CSOUND *, XYINDAT *, MYFLT, MYFLT);
127 | extern int myFLwait(void);
128 | extern void ReadXYin_FLTK(CSOUND *, XYINDAT *);
129 | extern void flgraph_init(CSOUND *csound);
130 | extern void widget_init(CSOUND *);
131 | extern int widget_reset(CSOUND *, void *);
132 |
133 | extern const OENTRY widgetOpcodes_[];
134 |
135 | #ifdef __cplusplus
136 | } /* extern "C" */
137 | #endif
138 |
139 | #endif /* CSOUND_WINFLTK_H */
140 |
141 |
--------------------------------------------------------------------------------
/6.x/src/widgets/virtual_keyboard/SliderBank.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | SliderBank.cpp:
3 |
4 | Copyright (C) 2006 Steven Yi
5 |
6 | This file is part of Csound.
7 |
8 | The Csound Library is free software; you can redistribute it
9 | and/or modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 2.1 of the License, or (at your option) any later version.
12 |
13 | Csound is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with Csound; if not, write to the Free Software
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 | 02110-1301 USA
22 | */
23 |
24 | #include "SliderBank.hpp"
25 |
26 | #include
27 | #include
28 |
29 | int WheelSlider::handle(int event) {
30 | int res = Fl_Value_Slider::handle(event);
31 | if (event == FL_MOUSEWHEEL) {
32 | int dy = Fl::event_dy();
33 | value(clamp(round(increment(value(), -dy))));
34 | return 1;
35 | }
36 | return res;
37 | }
38 |
39 | static void spinnerCallback(Fl_Widget *widget, void *v) {
40 | Fl_Spinner *spinner = (Fl_Spinner *)widget;
41 | SliderBank *sliderBank = (SliderBank *)v;
42 |
43 | for(int i = 0; i < 10; i++) {
44 | if(sliderBank->spinners[i] == spinner) {
45 | sliderBank->lock();
46 | SliderData* data = sliderBank->getSliderData();
47 | data->controllerNumber[i] = (int)spinner->value();
48 | sliderBank->unlock();
49 | }
50 | }
51 | }
52 |
53 | static void sliderCallback(Fl_Widget *widget, void *v) {
54 | Fl_Slider *slider = (Fl_Slider *)widget;
55 | SliderBank *sliderBank = (SliderBank *)v;
56 |
57 | for(int i = 0; i < 10; i++) {
58 | if(sliderBank->sliders[i] == slider) {
59 | sliderBank->lock();
60 | SliderData* data = sliderBank->getSliderData();
61 | data->controllerValue[i] = (int)slider->value();
62 | sliderBank->unlock();
63 | }
64 | }
65 | }
66 |
67 | SliderBank::SliderBank(CSOUND *csound,
68 | int X, int Y, int W, int H)
69 | : Fl_Group(X, Y, W, H)
70 | {
71 |
72 | this->csound = csound;
73 | this->mutex = csound->Create_Mutex(0);
74 |
75 | this->channel = 0;
76 |
77 | this->begin();
78 |
79 | for(int i = 0; i < 10; i++) {
80 | int x, y;
81 |
82 | if(i < 5) {
83 | x = 10;
84 | y = 10 + (i * 25);
85 | } else {
86 | x = 382;
87 | y = 10 + ((i - 5) * 25);
88 | }
89 |
90 | Fl_Spinner *spinner = new Fl_Spinner(x, y, 60, 20);
91 | spinners[i] = spinner;
92 | spinner->maximum(127);
93 | spinner->minimum(0);
94 | spinner->step(1);
95 | spinner->value(i + 1);
96 | spinner->callback((Fl_Callback*)spinnerCallback, this);
97 |
98 |
99 | WheelSlider *slider = new WheelSlider(x + 70, y, 292, 20);
100 | sliders[i] = slider;
101 | slider->type(FL_HOR_SLIDER);
102 | slider->maximum(127);
103 | slider->minimum(0);
104 | slider->step(1);
105 | slider->value(0);
106 | slider->callback((Fl_Callback*)sliderCallback, this);
107 | }
108 |
109 |
110 | this->end();
111 |
112 | }
113 |
114 | SliderBank::~SliderBank()
115 | {
116 | if (mutex) {
117 | csound->DestroyMutex(mutex);
118 | mutex = (void*) 0;
119 | }
120 | }
121 |
122 | void SliderBank::setChannel(int channel) {
123 | this->channel = channel;
124 |
125 | SliderData data = sliderData[channel];
126 |
127 | lock();
128 | for(int i = 0; i < 10; i++) {
129 | spinners[i]->value(data.controllerNumber[i]);
130 | sliders[i]->value(data.controllerValue[i]);
131 | }
132 | unlock();
133 | }
134 |
135 | SliderData * SliderBank::getSliderData() {
136 | return &sliderData[channel];
137 | }
138 |
139 | void SliderBank::incrementSlider(int index, int n) {
140 | Fl_Slider* slider = sliders[index];
141 | slider->value(slider->clamp(slider->round(slider->increment(slider->value(), n))));
142 | }
143 |
144 | void SliderBank::lock() {
145 | if(mutex) {
146 | csound->LockMutex(mutex);
147 | }
148 | }
149 |
150 | void SliderBank::unlock() {
151 | if(mutex) {
152 | csound->UnlockMutex(mutex);
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/6.x/src/mp3/mp3out.c:
--------------------------------------------------------------------------------
1 | /*
2 | mp3out.c:
3 |
4 | Copyright (C) 2019 by John ffitch
5 |
6 | This file is part of Csound.
7 |
8 | The Csound Library is free software; you can redistribute it
9 | and/or modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 2.1 of the License, or (at your option) any later version.
12 |
13 | Csound is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with Csound; if not, write to the Free Software
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 | 02110-1301 USA
22 | */
23 |
24 | #include "csdl.h"
25 | #include
26 |
27 | typedef struct _mp3out {
28 | OPDS h;
29 | MYFLT *al;
30 | MYFLT *ar;
31 | STRINGDAT *filename;
32 | MYFLT *bitrate;
33 | MYFLT *quality;
34 | MYFLT *mode;
35 | lame_global_flags *gfp;
36 | FILE *fout;
37 | AUXCH auxch;
38 | void *mp3buffer;
39 | int mp3buffer_size;
40 | MYFLT *leftpcm;
41 | MYFLT *rightpcm;
42 | } MP3OUT;
43 |
44 | #define DEFAULT_RATE (256)
45 |
46 | #ifdef USE_DOUBLE
47 | #define lame_encode_buffer_ieee_MYFLT lame_encode_buffer_ieee_double
48 | #else
49 | #define lame_encode_buffer_ieee_MYFLT lame_encode_buffer_ieee_float
50 | #endif
51 |
52 | int mp3out_cleanup(CSOUND *csound, MP3OUT *p)
53 | {
54 | IGN(csound);
55 | int bytes = lame_encode_flush(p->gfp,p->mp3buffer, p->mp3buffer_size);
56 | if (bytes>0) fwrite(p->mp3buffer, 1, bytes, p->fout);
57 | lame_mp3_tags_fid(p->gfp, p->fout);
58 | lame_close(p->gfp);
59 |
60 | p->gfp = NULL;
61 | fclose(p->fout);
62 | return OK;
63 | }
64 |
65 |
66 | int mp3out_init(CSOUND *csound, MP3OUT* p)
67 | {
68 | int ret_code;
69 | int bitrate, quality, mode;
70 | unsigned int nsmps = csound->GetKsmps(csound);
71 | lame_global_flags *gfp;
72 | gfp = lame_init();
73 | p->gfp = gfp;
74 |
75 | bitrate = (*p->bitrate<0) ? DEFAULT_RATE : (int)MYFLT2LRND(*p->bitrate);
76 | quality = (*p->quality<0) ? 2 : (int)MYFLT2LRND(*p->quality);
77 | if (quality>9) quality = 9;
78 | mode = MYFLT2LRND(*p->mode);
79 | if (mode>3||mode<0) mode = 1;
80 | lame_set_num_channels(gfp,2);
81 | lame_set_in_samplerate(gfp,csound->GetSr(csound));
82 | lame_set_brate(gfp,bitrate);
83 | lame_set_mode(gfp,mode);
84 | lame_set_quality(gfp,quality); /* 2=high 5 = medium 7=low */
85 |
86 | if (UNLIKELY(ret_code = lame_init_params(gfp)) < 0) {
87 | return csound->InitError(csound,
88 | Str("Failed to initialise LAME %d\n"), ret_code);
89 | }
90 |
91 | p->fout = fopen(p->filename->data, "w+b");
92 | if (p->fout == NULL) {
93 | return csound->InitError(csound, Str("mp3out %s: failed to open file"), p->filename->data);
94 | }
95 |
96 | csound->AuxAlloc(csound,
97 | 2*nsmps*sizeof(MYFLT)+(p->mp3buffer_size=3*nsmps/2+7200),
98 | &p->auxch);
99 |
100 | p->mp3buffer = p->auxch.auxp;
101 | p->leftpcm = (char*)p->auxch.auxp + p->mp3buffer_size;
102 | p->rightpcm = p->leftpcm + nsmps;
103 |
104 | csound->RegisterDeinitCallback(csound, p,
105 | (int32_t (*)(CSOUND*, void*)) mp3out_cleanup);
106 | return OK;
107 | }
108 |
109 | int mp3out_perf(CSOUND *csound, MP3OUT *p)
110 | {
111 | int bytes;
112 | unsigned int i, nsmps = csound->GetKsmps(csound);
113 | MYFLT zdbfs = csound->Get0dBFS(csound);
114 |
115 | for (i = 0; ileftpcm[i] = p->al[i]/zdbfs;
117 | p->rightpcm[i] = p->ar[i]/zdbfs;
118 | }
119 |
120 | bytes = lame_encode_buffer_ieee_MYFLT(p->gfp,
121 | p->leftpcm, p->rightpcm,
122 | nsmps, p->mp3buffer, p->mp3buffer_size);
123 |
124 | if (bytes >= 0) {
125 | fwrite(p->mp3buffer, 1, bytes, p->fout);
126 | }
127 | else if (bytes < 0) {
128 | return csound->PerfError(csound, &(p->h),
129 | Str("mp3out: write error %d\n"), bytes);
130 | }
131 |
132 | return OK;
133 | }
134 |
135 | #define S(x) sizeof(x)
136 |
137 | static OENTRY localops[] = {
138 | { "mp3out", S(MP3OUT), 0, 3, "", "aaSjjp", (SUBR)mp3out_init, (SUBR)mp3out_perf}
139 | };
140 |
141 | LINKAGE
142 |
--------------------------------------------------------------------------------
/6.x/src/CUDA/convf.cu:
--------------------------------------------------------------------------------
1 | // -*- c++ -*-
2 | /* convf.cu
3 | (c) Victor Lazzarini, 2013
4 |
5 | based on M Puckette's pitch tracking algorithm.
6 |
7 | This file is part of Csound.
8 |
9 | The Csound Library is free software; you can redistribute it
10 | and/or modify it under the terms of the GNU Lesser General Public
11 | License as published by the Free Software Foundation; either
12 | version 2.1 of the License, or (at your option) any later version.
13 |
14 | Csound is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU Lesser General Public License for more details.
18 |
19 | You should have received a copy of the GNU Lesser General Public
20 | License along with Csound; if not, write to the Free Software
21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 | 02110-1301 USA
23 | */
24 |
25 | #include
26 |
27 | __global__ void convol(float *out, float *del, float *coefs, int irsize, int rp, int vsize) {
28 | int t = (threadIdx.x + blockIdx.x*blockDim.x);
29 | if(t >= irsize*vsize) return;
30 | int n = t%vsize; /* sample index */
31 | int h = t/vsize; /* coeff index */
32 | int end = irsize+vsize;
33 | rp += n + h; /* read point, oldest -> newest */
34 | out[t] = del[rp < end ? rp : rp%end]*coefs[irsize-1-h]; /* single tap */
35 | if(t >= vsize) return;
36 | __syncthreads();
37 | float a = 0.0;
38 | for(int i=1, j=vsize; i < irsize; i++, j+=vsize)
39 | a += out[n + j]; /* mix all taps */
40 | out[n] += a;
41 | }
42 |
43 | typedef struct _CONV {
44 | OPDS h;
45 | MYFLT *aout, *asig, *ifn;
46 | float *coeffs, *out, *del;
47 | int wp, irsize;
48 | AUXCH buf;
49 | int blocks, threads;
50 | } CONV;
51 |
52 |
53 | static int destroy_conv(CSOUND *csound, void *pp){
54 | CONV *p = (CONV *) pp;
55 | cudaFree(p->coeffs);
56 | cudaFree(p->del);
57 | cudaFree(p->out);
58 | return OK;
59 | }
60 |
61 | static int conv_init(CSOUND *csound, CONV *p){
62 |
63 | FUNC *ftab = csound->FTnp2Find(csound, p->ifn);
64 | int irsize = ftab->flen;
65 | int nsmps = CS_KSMPS,i;
66 | int threads = irsize*nsmps;
67 | float *tmp;
68 |
69 | cudaMalloc(&p->coeffs, sizeof(float)*irsize);
70 |
71 | tmp = (float*) malloc(sizeof(float)*irsize);
72 | for(i=0; i< irsize; i++)
73 | tmp[i] = (float) ftab->ftable[i];
74 | cudaMemcpy(p->coeffs,tmp, sizeof(float)*irsize,
75 | cudaMemcpyHostToDevice);
76 | free(tmp);
77 |
78 | cudaMalloc(&p->del, sizeof(float)*(irsize+nsmps));
79 | cudaMalloc(&p->out, sizeof(float)*threads);
80 | cudaMemset(p->del,0,sizeof(float)*(irsize+nsmps));
81 | cudaMemset(p->out, 0, sizeof(float)*threads);
82 |
83 | p->wp = 0;
84 | p->irsize = irsize;
85 |
86 | cudaDeviceProp deviceProp;
87 | cudaGetDeviceProperties(&deviceProp, 0);
88 | int blockspt = deviceProp.maxThreadsPerBlock;
89 | csound->Message(csound, "CUDAconv: using device %s (capability %d.%d)\n",
90 | deviceProp.name,deviceProp.major, deviceProp.minor);
91 |
92 | p->blocks = threads > blockspt ? ceil(threads/blockspt) : 1;
93 | p->threads = threads > blockspt ? blockspt : threads;
94 |
95 | csound->RegisterDeinitCallback(csound, p, destroy_conv);
96 | OPARMS parms;
97 | csound->GetOParms(csound, &parms);
98 | if(parms.odebug)
99 | csound->Message(csound, "blocks %d, threads %d - %d\n", p->blocks, p->threads, threads);
100 | if(p->buf.auxp == NULL)
101 | csound->AuxAlloc(csound, sizeof(float)*CS_KSMPS, &p->buf);
102 |
103 | return OK;
104 |
105 | }
106 | /* the delay size is irsize + vsize so that
107 | we can shift in a whole block of samples */
108 | int conv_perf(CSOUND *csound, CONV *p){
109 |
110 | int nsmps = CS_KSMPS;
111 | MYFLT *sig = p->asig, *aout = p->aout;
112 | float *del = p->del, *out = p->out, *coefs = p->coeffs, *buf = (float *)p->buf.auxp;
113 | int irsize = p->irsize;
114 | int wp = p->wp, i;
115 |
116 | for(i=0; i < nsmps; i++) buf[i] = (float) sig[i];
117 | if(wp > irsize) {
118 | int front = wp - irsize;
119 | cudaMemcpy(&del[wp], buf, sizeof(float)*(nsmps-front), cudaMemcpyHostToDevice);
120 | cudaMemcpy(del, &buf[nsmps-front], sizeof(float)*front, cudaMemcpyHostToDevice);
121 | }
122 | else cudaMemcpy(&del[wp], buf, sizeof(float)*nsmps, cudaMemcpyHostToDevice);
123 |
124 | wp = (wp+nsmps)%(irsize+nsmps); /* wp is now the oldest sample in the delay */
125 | convol<<blocks,p->threads>>>(out, del, coefs, irsize, wp, nsmps);
126 |
127 | cudaMemcpy(buf, out, sizeof(float)*nsmps, cudaMemcpyDeviceToHost);
128 |
129 | for(i=0; i < nsmps; i++) aout[i] = (float) buf[i];
130 | p->wp = wp;
131 | return OK;
132 | }
133 |
134 | static OENTRY localops[] = {
135 | {"cudaconv", sizeof(CONV),0, 5, "a", "ai", (SUBR) conv_init, NULL,
136 | (SUBR) conv_perf},
137 | };
138 |
139 | extern "C" {
140 | LINKAGE
141 | }
142 |
--------------------------------------------------------------------------------