Skip to content

Commit

Permalink
Added install target to build (#165).
Browse files Browse the repository at this point in the history
  • Loading branch information
gogins committed Jul 23, 2021
1 parent b082117 commit 9d3fbed
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 259 deletions.
56 changes: 56 additions & 0 deletions playpen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.5)

message("CMAKE BUILD SYSTEM FOR THE CSOUND PLAYPEN")

project(csound-playpen)

# Top-level CMake configuration.

cmake_policy(SET CMP0078 NEW)
cmake_policy(SET CMP0086 NEW)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")

find_package(PkgConfig REQUIRED)
pkg_check_modules(WEBKIT2_GTK_WEB_EXTENSION REQUIRED webkit2gtk-web-extension-4.0)

# This is here only to warn in advance that the sourceview component will be
# missing when running the playpen.

pkg_check_modules(GTKSOURCEVIEW REQUIRED gtksourceview-4)
find_package(Csound REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(SWIG)
include(UseSWIG)
include_directories(${Python3_INCLUDE_DIRS})
include_directories(${CSOUND_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-unknown-pragmas -Wno-misleading-indentation -Wno-unused-variable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
add_definitions("-DUSE_DOUBLE")
if(USE_LIB64)
set(LIBRARY_INSTALL_DIR "lib64")
add_definitions("-DLIB64")
else()
set(LIBRARY_INSTALL_DIR "lib")
endif()

set_property(SOURCE csound.i PROPERTY CPLUSPLUS ON)
swig_add_library(CsoundThreaded
TYPE MODULE
LANGUAGE python
SOURCES csound.i
)
swig_link_libraries(CsoundThreaded ${Python3_LIBRARY_RELEASE} ${CSOUND_LIBRARY} ${LIBSNDFILE_LIBRARY})
install(TARGETS CsoundThreaded
LIBRARY DESTINATION "${Python3_SITEARCH}"
ARCHIVE DESTINATION "${Python3_SITEARCH}")
install(FILES "CsoundThreaded.py"
DESTINATION "${Python3_SITEARCH}")

add_library(jsc_csound SHARED
jsc_csound.cpp)
target_include_directories(jsc_csound PUBLIC ${WEBKIT2_GTK_WEB_EXTENSION_INCLUDE_DIRS})
target_link_libraries(jsc_csound PUBLIC ${WEBKIT2_GTK_WEB_EXTENSION_LIBRARIES} ${CSOUND_LIBRARY} ${LIBSNDFILE_LIBRARY})
install(TARGETS jsc_csound
LIBRARY DESTINATION "${LIBRARY_INSTALL_DIR}")
45 changes: 28 additions & 17 deletions playpen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ an external score-generating program directly from Csound using the <CsScore>
other composition software is needed to generate a score that is then sent to
Csound or some other synthesizer for rendering.

The playpen can edit and automatically render pieces written in Python, Csound,
HTML5, or Javascript. By writing a little extra Python code, pieces can be
written in any programming language.

## Getting Started

Install the following software requirements, each according to its own
Expand Down Expand Up @@ -85,29 +81,43 @@ Everything should be installed for the same version of Python.
Execute `python3 playpen.py` and then open and run the `xanadu.csd` example
to check that everything is working.

You must download or build two shared libraries in this repository. On Linux,
running `build.sh` should do the job. These shared libraries are:
You must download or build two shared libraries in this repository. These
shared libraries are:

1. `CsoundThreaded`, a native Python module generated from `csound.i` by
the SWIG program. This provides a simplified implementation of the Csound
API that can be used from Python.
the SWIG program. This provides a simplified implementation of the native
Csound API that can be used from Python.
2. `libjsc_csound.so`, a native loadable module (providing the same
simplified Csound API) that can be used by the JavaScriptCore engine in
the embedded WebKit2 browser.
the playpen's embedded WebKit2 browser.

To build and install these shared libraries, in the repository root directory,
execute:
```
cmake .
make
sudo make install
```

## A Few Examples

### xanadu.csd

This is a high-resolution version of Kung's "Xanadu" piece often used as an
introduction to Csound. It's the simplest possible test that your installation
of the playpen is working.
of the playpen is working. Just load the file and click on the __Play__ button.

### sierpinski-csound.py

For this example, install Rick Taube's Python port of the Common Music
algorithmic composition system, [musx](https://github.com/musx-admin/musx).

### message.html

This is a basic HTML5 example that runs native Csound using JavaScript and
has a custom user interface implemented with JQuery. In this case, the __Play__
button is part of the HTML5 user interface.

## User Guide

The philosophy of the playpen is to keep it simple, stupid and yet to have
Expand Down Expand Up @@ -155,10 +165,11 @@ right:
exiting Glade. The changes you have saved will immediately show up in
the Controls pane of the playpen.
6. Play the piece to real-time audio
7. Render the piece to a soundfile. When the rendering is complete, the
soundfile will be normalized, tagged with metadata from `setting.ini`,
translated to MP3, FLAC, and MP4 (suitable for YouTube) formats;
finally the normalized soundfile will be opened in a soundfile editor.
7. Render the piece to a soundfile (applies only to CSD pieces).
When the rendering is complete, the soundfile will be normalized,
tagged with metadata from `setting.ini`, translated to MP3, FLAC, and MP4
(suitable for YouTube) formats; finally the normalized soundfile will be
opened in a soundfile editor.

When using the user interface builder, there are some things that must be
understood:
Expand All @@ -168,15 +179,15 @@ understood:
other layout, but you must give it the id "user_controls_layout."
2. The Scale widget is the usual choice for controlling variables in Csound.
Each Scale widget must have its own associated Adjustment. The Adjustment
can be given a minimum and maximum value that match the range needed
can be given minimum and maximum values to match the range needed
in Csound. Both the name, and the id, of the Scale must be set to the same
value as the name of the global Csound variable that will be controlled by
that Scale.
3. In the header of your Csound orchestra, create global variables with the
same names and types as the Gtk widgets you have created to control them.
Then use the `chnexport` opcode to create the global variables and
Then just use the `chnexport` opcode to create the global variables and
associate them with control channels having the same names. This greatly
simplifies writing Csound orchestras. Example:
simplifies writing controllable Csound orchestras. Example:
<pre>
gk_Harpsichord_level init 0
gk_Harpsichord_pan init .3
Expand Down
29 changes: 29 additions & 0 deletions playpen/cmake/Modules/FindCsound.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Try to find the Csound library.
# Once done this will define:
# CSOUND_FOUND - System has the Csound library
# CSOUND_INCLUDE_DIRS - The Csound include directories.
# CSOUND_LIBRARIES - The libraries needed to use the Csound library.

if(APPLE)
find_path(CSOUND_INCLUDE_DIR csound.h HINTS /Library/Frameworks/CsoundLib64.framework/Headers
"$ENV{HOME}/Library/Frameworks/CsoundLib64.framework/Headers")
else()
find_path(CSOUND_INCLUDE_DIR csound.h PATH_SUFFIXES csound)
endif()

if(APPLE)
find_library(CSOUND_LIBRARY NAMES CsoundLib64 HINTS /Library/Frameworks/CsoundLib64.framework/
"$ENV{HOME}/Library/Frameworks/CsoundLib64.framework")
else()
find_library(CSOUND_LIBRARY NAMES csound64 csound)
endif()

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CSOUND_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CSOUND
CSOUND_LIBRARY CSOUND_INCLUDE_DIR)
mark_as_advanced(CSOUND_INCLUDE_DIR CSOUND_LIBRARY)

set(CSOUND_INCLUDE_DIRS ${CSOUND_INCLUDE_DIR})
set(CSOUND_LIBRARIES ${CSOUND_LIBRARY} )
4 changes: 2 additions & 2 deletions playpen/examples/sierpinski/sierpinski-csound.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def sierpinski(score, tone, shape, trans, levels, dur, amp):
# first compose() generates 120 events, the second 726, and the third 2728!
#score.compose(sierpinski(score, keynum('a0'), [0, 7, 5], 12, 4, 3, .5))
#score.compose(sierpinski(score, keynum('a0'), [0, 7, 5], 8, 5, 7, .5))
#score.compose(sierpinski(score, musx.keynum('a0'), [0, -1, 2, 13], 12, 5, 24, .5))
score.compose(sierpinski(score, 24., [0, -1, 2, 13], 12, 5, 24, .5))
score.compose(sierpinski(score, musx.keynum('a0'), [0, -1, 2, 7], 12, 5, 24, .5))
#score.compose(sierpinski(score, 24., [0, -1, 2, 13], 12, 5, 24, .5))

# Write the tracks to a midi file in the current directory.
file = MidiFile("sierpinski.mid", [track0, track1]).write()
Expand Down
Loading

0 comments on commit 9d3fbed

Please sign in to comment.