Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/csound/plugins into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Lazzarini committed Feb 6, 2022
2 parents a0986d9 + fcf15e0 commit e57f73f
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 51 deletions.
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(Csound-plugins)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANG 1)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")

# C++11 needed
if(NOT MSVC)
Expand Down Expand Up @@ -114,38 +115,38 @@ if (HAS_CXX_VISIBILITY_HIDDEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()

if(LINUX)
option(USE_LIB64 "Set to on to set installation directory for
libraries to lib64" OFF)
if(USE_LIB64)
set(LIBRARY_INSTALL_DIR "lib64")
set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib64")
add_definitions("-DLIB64")
else()
set(LIBRARY_INSTALL_DIR "lib")
set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()
if(NOT APPLE)
message(STATUS "LIBRARY INSTALL DIR: ${LIBRARY_INSTALL_DIR}")
message(STATUS "LIBRARY INSTALL DIR: ${LIBRARY_INSTALL_DIR}")
endif()

# plugin install directories (CS_USER_PLUGIN)
# plugin install directories (CS_USER_PLUGIN on MacOs/Windows)
if(USE_DOUBLE)
message(STATUS "Building with 64-bit floats")
if(APPLE)
set(PLUGIN_INSTALL_DIR
"$ENV{HOME}/Library/csound/${APIVERSION}/plugins64")
set(PLUGIN_INSTALL_DIR
"$ENV{HOME}/Library/csound/${APIVERSION}/plugins64" CACHE PATH "Plugin install path")
elseif(LINUX)
set(PLUGIN_INSTALL_DIR
"$ENV{HOME}/.local/lib/csound/${APIVERSION}/plugins64")
"${LIBRARY_INSTALL_DIR}/csound/plugins64-${APIVERSION}")
elseif(WINDOWS)
set(PLUGIN_INSTALL_DIR "${env.LOCALAPPDATA}/csound/${APIVERSION}/plugins64")
endif()
else()
message(STATUS "Building with 32-bit floats")
if(APPLE)
set(PLUGIN_INSTALL_DIR
"$ENV{HOME}/Library/csound/${APIVERSION}/plugins")
"$ENV{HOME}/Library/csound/${APIVERSION}/plugins" CACHE PATH "Plugin install path")
elseif(LINUX)
set(PLUGIN_INSTALL_DIR
"$ENV{HOME}/.local/lib/csound/${APIVERSION}/plugins")
"${LIBRARY_INSTALL_DIR}/csound/plugins-${APIVERSION}")
elseif(WINDOWS)
set(PLUGIN_INSTALL_DIR "${env.LOCALAPPDATA}/csound/${APIVERSION}/plugins")
endif()
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,23 @@ to incompatibilities with the operating system.
Install location
--------------
The CMake scripts in this repository use the default CS_USER_PLUGIN
location as defined in the Csound build. These are:
location on MacOS and Windows as defined in the Csound build, or a
library instalation directory (customisable) on LINUX. These are:

- LINUX: `$HOME/.local/lib/csound/${APIVERSION}/plugins64`(doubles)
or `$HOME/.local/lib/csound/${APIVERSION}/plugins` (floats)
- MACOS: `$HOME/Library/csound/${APIVERSION}/plugins64` (doubles)
or `$HOME/Library/csound/${APIVERSION}/plugins` (floats)
- Windows: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins64`(doubles)
or `%LOCALAPPDATA%\csound\${APIVERSION}\plugins` (floats)
- LINUX: depends on both `CMAKE_INSTALL_PREFIX` and `USE_LIB64`. It is then installed in:
* if `USE_LIB64=1` then to
* for doubles: `${CSOUND_INSTALL_PREFIX}/lib64/csound/plugins64-${APIVERSION}`
* for floats: `${CSOUND_INSTALL_PREFIX}/lib64/csound/plugins-${APIVERSION}` (floats)`
* if `USE_LIB64=0` then to
* for doubles: `${CSOUND_INSTALL_PREFIX}/lib/csound/plugins64-${APIVERSION}`
* for floats: `${CSOUND_INSTALL_PREFIX}/lib/csound/plugins-${APIVERSION}`

- MACOS:
* For doubles: `$HOME/Library/csound/${APIVERSION}/plugins64`
* For floats: `$HOME/Library/csound/${APIVERSION}/plugins`
- Windows:
* For doubles: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins64`
* For floats: `%LOCALAPPDATA%\csound\${APIVERSION}\plugins`


Build Instructions for Linux and MacOS
Expand Down Expand Up @@ -89,7 +98,9 @@ $ make
$ make install
```

using `sudo` in the last step if raised permissions are needed.
using `sudo` in the last step if raised permissions are needed. On
Linux, the installation location can be set with the relevant CMake
variables as indicated above.

Csound Location
------------
Expand Down
13 changes: 13 additions & 0 deletions cmake/Modules/FindFLUIDSYNTH.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ if (FLUIDSYNTH_INCLUDE_DIR AND FLUIDSYNTH_LIBRARIES)
set (FluidSynth_FIND_QUIETLY TRUE)
endif ()

if(APPLE)
find_path(FLUIDSYNTH_INCLUDE_DIR fluidsynth.h HINTS
/Library/Frameworks/FluidSynth.framework/Headers
${FLUIDSYNTH_INCLUDE_DIR_HINT})
else()
find_path (FLUIDSYNTH_INCLUDE_DIR fluidsynth.h)
endif()

if(APPLE)
find_library(FLUIDSYNTH_LIBRARIES NAMES FluidSynth HINTS /Library/Frameworks/FluidSynth.framework/
${FLUIDSYNTH_LIBRARY_DIR_HINT})
else()
find_library (FLUIDSYNTH_LIBRARIES NAMES fluidsynth libfluidsynth)
endif()

mark_as_advanced (FLUIDSYNTH_LIBRARIES FLUIDSYNTH_INCLUDE_DIR)

# handle the QUIETLY and REQUIRED arguments and set FLUIDSYNTH_FOUND to TRUE if
Expand Down
20 changes: 20 additions & 0 deletions cmake/Modules/FindLAME.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# - Find LAME
# Find the native LAME includes and library
#
# LAME_INCLUDE_DIR - where to find lame.h
# LAME_LIBRARY - lame library
# LAME_FOUND - lame found

if (LAME_INCLUDE_DIR AND LAME_LIBRARY)
# Already in cache, be silent
set (LAME_FIND_QUIETLY TRUE)
endif ()

find_path (LAME_INCLUDE_DIR lame/lame.h HINTS /usr/local/include)
find_library (LAME_LIBRARY NAMES mp3lame libmp3lame HINTS /usr/local/lib)
mark_as_advanced (LAME_LIBRARIES LAME_INCLUDE_DIR)

# handle the QUIETLY and REQUIRED arguments and set LAME_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LAME DEFAULT_MSG LAME_LIBRARY LAME_INCLUDE_DIR)
2 changes: 1 addition & 1 deletion fluidOpcodes/fluidOpcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class FluidEngine : public csound::OpcodeBase<FluidEngine> {
result =
csound->InitError(csound, "%s", Str("error allocating fluid engine\n"));
} else {
#if (FLUIDSYNTH_VERSION_MAJOR >= 2 && FLUIDSYNTH_VERSION_MINOR >= 3)
#if (FLUIDSYNTH_VERSION_MAJOR >= 2 && FLUIDSYNTH_VERSION_MINOR >= 2)
// TODO: Change -1 to a configurable FX group?
fluid_synth_chorus_on(fluidSynth, -1, chorusEnabled);
fluid_synth_reverb_on(fluidSynth, -1, reverbEnabled);
Expand Down
49 changes: 17 additions & 32 deletions hdf5/HDF5IO.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ int32_t HDF5Read_initialise(CSOUND *csound, HDF5Read *self)
HDF5Read_checkArgumentSanity(csound, self);
csound->RegisterDeinitCallback(csound, self, HDF5Read_finish);
self->isSampleAccurate = HDF5IO_getSampleAccurate(csound);
STRINGDAT *path = (STRINGDAT *)self->arguments[self->outputArgumentCount];
self->hdf5File = HDF5IO_newHDF5File(csound, &self->hdf5FileMemory, path, false);
//STRINGDAT *path = (STRINGDAT *)self->arguments[self->outputArgumentCount];
self->hdf5File = HDF5IO_newHDF5File(csound, &self->hdf5FileMemory, self->path, false);
HDF5Read_openDatasets(csound, self);

return OK;
Expand Down Expand Up @@ -830,7 +830,6 @@ void HDF5Read_readAudioData(CSOUND *csound, HDF5Read *self,
{
if (dataset->offset[0] >=
dataset->datasetSize[0]) {

return;
}

Expand All @@ -845,24 +844,24 @@ void HDF5Read_readAudioData(CSOUND *csound, HDF5Read *self,
vectorSize = (int32_t)(dataset->datasetSize[0] -
dataset->offset[0]);
}

MYFLT *dataPointer =
vectorSize != self->ksmps ? dataset->sampleBuffer : inputDataPointer;

// FIXME if this is called frequently or on the audio thread then this won't
// work and will need a different solution
#ifdef _MSC_VER
hsize_t* chunkDimensions = malloc (dataset->rank * sizeof (hsize_t));
//hsize_t* chunkDimensions = malloc (dataset->rank * sizeof (hsize_t));
hsize_t chunkDimensions[16];
#else
hsize_t chunkDimensions[dataset->rank];
#endif
memcpy(&chunkDimensions[1], &dataset->datasetSize[1],
sizeof(hsize_t) * dataset->rank);
sizeof(hsize_t) * (dataset->rank-1)); // Reads too much
chunkDimensions[0] = vectorSize;

memcpy (chunkDimensions, dataset->datasetSize,
sizeof (hsize_t) * dataset->rank);
chunkDimensions[dataset->rank - 1] = vectorSize;
// memcpy (chunkDimensions, dataset->datasetSize,
// sizeof (hsize_t)/* * dataset->rank */
// );
//chunkDimensions[dataset->rank - 1] = vectorSize;

HDF5Read_readData (csound, self, dataset, dataset->offset,
chunkDimensions, dataPointer);
Expand All @@ -877,8 +876,9 @@ void HDF5Read_readAudioData(CSOUND *csound, HDF5Read *self,
dataset->offset[0] += vectorSize;

#ifdef _MSC_VER
free (chunkDimensions);
//free (chunkDimensions);
#endif

}

// Read data at control rate from a hdf5 dataset
Expand Down Expand Up @@ -1016,23 +1016,9 @@ void HDF5Read_checkArgumentSanity(CSOUND *csound, const HDF5Read *self)

for (i = 0; i < self->inputArgumentCount; ++i) {

ArgumentType inputType =
HDF5IO_getArgumentTypeFromArgument(csound,
self->arguments[self->outputArgumentCount + i]);
ArgumentType outputType =
HDF5IO_getArgumentTypeFromArgument(csound, self->arguments[i]);

if (UNLIKELY(inputType != STRING_VAR)) {

csound->Die(csound, Str("hdf5read: Error, input argument %d does not "
"appear to be a string, exiting"), i + 1);
}
else if (UNLIKELY(inputType == UNKNOWN)) {

csound->Die(csound, Str("hdf5read: Error, input argument %d type "
"is unknown, exiting"), i + 1);
}

if (UNLIKELY(outputType == STRING_VAR)) {

csound->Die(csound, Str("hdf5read: Error, output argument %d appears "
Expand Down Expand Up @@ -1320,7 +1306,7 @@ void HDF5Read_initialiseScalarOutput(CSOUND *csound, HDF5Read *self,
// Assign the input argument name to the dataset name
// Get the read type from the arguments
// Assign the argument data pointer
// Check that the read type and write type are compatible
// Check that the read type and write type are compatiblea
// Initialise the data set using the corresponding function for read type specified

void HDF5Read_openDatasets(CSOUND *csound, HDF5Read *self)
Expand All @@ -1333,10 +1319,9 @@ void HDF5Read_openDatasets(CSOUND *csound, HDF5Read *self)
for (i = 0; i < self->inputArgumentCount; ++i) {

HDF5Dataset *currentDataset = &self->datasets[i];
STRINGDAT *inputArgument =
(STRINGDAT *)self->arguments[self->outputArgumentCount + i + 1];
STRINGDAT *inputArgument = (STRINGDAT *)self->names[i];

csound->AuxAlloc(csound, sizeof(char) * strlen(inputArgument->data),
csound->AuxAlloc(csound, sizeof(char) * strlen(inputArgument->data)+1,
&currentDataset->datasetNameMemory);
currentDataset->datasetName = currentDataset->datasetNameMemory.auxp;
strcpy(currentDataset->datasetName, inputArgument->data);
Expand All @@ -1346,7 +1331,6 @@ void HDF5Read_openDatasets(CSOUND *csound, HDF5Read *self)
currentDataset->readAll = true;
currentDataset->datasetName[strlen(inputArgument->data) - 1] = '\0';
}

currentDataset->readType =
HDF5IO_getArgumentTypeFromArgument(csound, self->arguments[i]);
currentDataset->argumentPointer = self->arguments[i];
Expand Down Expand Up @@ -1389,6 +1373,7 @@ void HDF5Read_openDatasets(CSOUND *csound, HDF5Read *self)

}
}

}


Expand All @@ -1408,8 +1393,8 @@ static OENTRY localops[] = {
.opname = "hdf5read",
.dsblksiz = sizeof(HDF5Read),
.thread = 3,
.outypes = "*",
.intypes = "*",
.outypes = "********************",
.intypes = "SW",
.iopadr = (SUBR)HDF5Read_initialise,
.kopadr = (SUBR)HDF5Read_process,
.aopadr = NULL
Expand Down
2 changes: 2 additions & 0 deletions hdf5/HDF5IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ typedef struct HDF5Read
{
OPDS h;
MYFLT *arguments[20];
STRINGDAT *path;
STRINGDAT *names[20];
int32_t inputArgumentCount;
int32_t outputArgumentCount;
size_t ksmps;
Expand Down

0 comments on commit e57f73f

Please sign in to comment.