diff options
Diffstat (limited to 'sonics')
-rwxr-xr-x | sonics/README.md | 31 | ||||
-rwxr-xr-x | sonics/__config__.udo | 35 | ||||
-rwxr-xr-x | sonics/instrument_gchord1.udo | 2 | ||||
-rwxr-xr-x | sonics/instrument_portchord.udo | 60 | ||||
-rwxr-xr-x | sonics/pgdb.udo | 16 | ||||
-rwxr-xr-x | sonics/sequencing_melodic.udo | 11 | ||||
-rwxr-xr-x | sonics/sequencing_melodic_portamento.udo | 5 | ||||
-rwxr-xr-x | sonics/sounddb.udo | 229 | ||||
-rwxr-xr-x | sonics/soundxdb.udo | 28 |
9 files changed, 44 insertions, 373 deletions
diff --git a/sonics/README.md b/sonics/README.md index 14763ae..366b654 100755 --- a/sonics/README.md +++ b/sonics/README.md @@ -3,8 +3,10 @@ The UDO files in this directory are a slimmed excerpt from the SONICS collection. The full collection will be made available in the future.
SONICS is a framework of frontends, Csound UDOs and PostgreSQL database functionality allowing for easier sound processing, sequencing and live performance.
-The frontend components consist of elements using SDL, Qt and HTML, while audio engines can utilise Pyo, Puredata and Csound. Data is stored on disk and in databases (of which PostgreSQL, MySQL/MariaDB and SQLite are supported).
-Only the Csound UDO and PostgreSQL database components are featured in the extract for Partial Emergence, and those are mainly limited to the required functionality for the installation but may have some reuse potential.
+The frontend components consist of elements using SDL, Qt and HTML, while audio engines can utilise Pyo, Puredata and Csound. Data is stored on disk and in
+databases (of which PostgreSQL, MySQL/MariaDB and SQLite are supported).
+Only the Csound UDO and PostgreSQL database components are featured in the extract for Partial Emergence, and those are mainly limited to the required
+functionality for the installation but may have some reuse potential.
## Key concepts
@@ -18,19 +20,32 @@ The f-tables defined at the top of the file contain details of the current chord sequencing_melodic_persistence.udo deals with loading and saving chord progressions to/from disk or database.
-sequencing_melodic_portamento.udo makes the current chord note frequencies available in f-tables with an applied portamento based on a time that can be set globally.
+sequencing_melodic_portamento.udo makes the current chord note frequencies available in f-tables with an applied portamento based on a time that can be
+set globally.
-### Sound DB
-sounddb.udo provides a way to load sounds to f-tables stored on disk and defined in the database. Sounds are allocated collections which can be of a regular or melodic type. Melodic sounds also have the corresponding MIDI note number stored in the database and thus can then be retrieved based on the requested note. Functions in the database handle the retrieval and calculation of the pitch ratio adjustment required to make the sound match the requested note.
+### Sound DB Extract
+soundxdb.udo provides a way to manage sound collections specified in a database extract. The fundamental database access opcodes contained in sounddb.udo
+are not included in this slim excerpt, as they rely on [database plugin opcodes](https://git.1bpm.net/csound-sqldb), but will be made available in the
+future.
+The SONICS database provides a way to export data and access with the same interface; the export opcodes are provided herein.
+Sounds are allocated collections which can be of a regular or melodic type. Melodic sounds also have the corresponding MIDI note number stored in the
+database and thus can then be retrieved based on the requested note. Functions in the database handle the retrieval and calculation of the pitch ratio
+adjustment required to make the sound match the requested note.
-soundxdb.udo provides the same interface as sounddb.udo, but utilises a database extract to allow for offline sound retrieval.
+The extract in [../include/soundexport.xdb](../include/soundexport.xdb) features such a set of arrays and f-tables that mimic what the database would return.
+For each sound collection, *gixdb_pitchreference* stores a reference for all possible MIDI notes (0 to 127) which is accessed by a collection specific offset
+held in *gixdb_pitchrefoffset*. The values returned from *gixdb_pitchreference* then point to the upper and lower bounds in *gixdb_pitchnotes* and
+*gixdb_pitchadjust* which contain the index in *gisounddb* and the pitch adjustment ratio required in order to match the requested note. This fulfillment
+of such a request is carried out by *sounddb_mel_nearestnote* in [soundxdb.udo](soundxdb.udo).
### Bussing
-bussing.udo provides stereo wrappers around chnset/chnget/chnmix opcodes to allow for easier bussing, and a default master bus which has a global amplitude control.
+bussing.udo provides stereo wrappers around chnset/chnget/chnmix opcodes to allow for easier bussing, and a default master bus which has a global amplitude
+control.
### Instruments
-While SONICS is mainly a control framework, there are also extension opcodes which use the framework to provide audio processing and generation; the UDO files are prepended with *instrument_*
+While SONICS is mainly a control framework, there are also extension opcodes which use the framework to provide audio processing and generation; the UDO
+files are prepended with *instrument_*
diff --git a/sonics/__config__.udo b/sonics/__config__.udo deleted file mode 100755 index 962e78a..0000000 --- a/sonics/__config__.udo +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef UDO_CONFIG
-#define UDO_CONFIG ##
-/*
- SONICS config
- Slim excerpt for Partial Emergence
-
- This file is part of the SONICS UDO collection by Richard Knight 2021
- License: GPL-2.0-or-later
- http://1bpm.net
-*/
-
-
-; database: allow macro overrides from command line or pre-include etc
-#ifndef PGDB_HOST
-#define PGDB_HOST #192.168.1.69#
-#endif
-
-#ifndef PGDB_NAME
-#define PGDB_NAME #partialemergence#
-#endif
-
-#ifndef PGDB_USER
-#define PGDB_USER #partialemergence#
-#endif
-
-#ifndef PGDB_PASSWORD
-#define PGDB_PASSWORD #dj939jfh9sh948nd#
-#endif
-
-
-; FFT defaults
-giFFTsize = 512
-giFFTwinFactor = 4
-
-#end
diff --git a/sonics/instrument_gchord1.udo b/sonics/instrument_gchord1.udo index 314ea0a..64ed324 100755 --- a/sonics/instrument_gchord1.udo +++ b/sonics/instrument_gchord1.udo @@ -10,7 +10,7 @@ */
#include "sonics/wavetables.udo"
#include "sonics/sequencing_melodic_portamento.udo"
-#include "sonics/sounddb.udo"
+#include "sonics/soundxdb.udo"
#include "sonics/frequency_tools.udo"
#include "sonics/uniqueid.udo"
diff --git a/sonics/instrument_portchord.udo b/sonics/instrument_portchord.udo index 97c1ec2..1948f6e 100755 --- a/sonics/instrument_portchord.udo +++ b/sonics/instrument_portchord.udo @@ -9,55 +9,12 @@ http://1bpm.net
*/
-#include "sonics/__config__.udo"
#include "sonics/sequencing_melodic_persistence.udo"
#include "sonics/sequencing_melodic_portamento.udo"
#include "sonics/wavetables.udo"
-#include "sonics/sounddb.udo"
+#include "sonics/soundxdb.udo"
-/*
- Play continuous chords from melodic sequencer with portamento, using oscil as an instrument and a specified wavetable
-
- aL, aR portchord_wave [iwavefn=gifnSine, ifreqmult=1, ivibdepth=1, ivibrate=3, index=0]
-
- aL, aR stereo outputs
- iwavefn the f-table to use with oscil
- ifreqmult frequency multiplier of the chord note frequencies to be applied
- ivibdepth vibrato depth
- ivibrate vibrato rate in Hz
- index internal start index of the chord notes; could also be used to specify starting note offset
-*/
-opcode portchord_wave, aa, jpjjo
- iwavefn, ifreqmult, ivibdepth, ivibrate, index xin
-
- iwavefn = (iwavefn == -1) ? gifnSine : iwavefn
- ivibdepth = (ivibdepth == -1) ? 1 : ivibdepth
- ivibrate = (ivibrate == -1) ? 3 : ivibrate
-
- kamp table index, gimel_amps
- kfreq table index, gimel_freqs
-
- klfo = oscil:k(ivibdepth, ivibrate) ;oscil:k(7, 5)
- kfreq += klfo
- kfreq *= ifreqmult
-
- ;kamp portk kamp, (i(gkseq_beattime) * gimel_portamento_beatratio) ; fade out when change
-
- aL oscil kamp*0.1, kfreq, iwavefn
- ipan = random(0, 1)
- aR = aL * ipan
- aL *= (1 - ipan)
-
- if (index + 1 < ftlen(gimel_amps)) then
- aLx, aRx portchord_wave iwavefn, ifreqmult, ivibdepth, ivibrate, index + 1
- aL += aLx
- aR += aRx
- endif
-
- xout aL, aR
-endop
-
/*
@@ -75,7 +32,7 @@ endop opcode portchord_sound, aa, ippjo
icollectionid, imode, ifreqmult, ifftsize, index xin
- ifftsize = (ifftsize == -1) ? giFFTsize : ifftsize
+ ifftsize = (ifftsize == -1) ? 512 : ifftsize
inote = round(random(50, 80))
ibasefreq = cpsmidinn(inote)
@@ -95,13 +52,13 @@ opcode portchord_sound, aa, ippjo istart = random(0.05, 0.2)
iend = random(istart+0.1, 0.8)
- atime = abs(oscil(iend - istart, random(0.001, 0.1), gifnSine, random(0, 1))) + istart
-
-
- klfo = oscil:k(random(0.0001, 0.009), random(1, 5)) + 1
- kpitch *= klfo
+
if (kamp != 0) then
+ atime = abs(oscil(iend - istart, random(0.001, 0.1), gifnSine, random(0, 1))) + istart
+ klfo = oscil:k(random(0.0001, 0.009), random(1, 5)) + 1
+ kpitch *= klfo
+
if (imode == 0) then
kpitch *= (ftsr(ifn) / sr) ; adjustment for sndwarp required
@@ -130,4 +87,7 @@ opcode portchord_sound, aa, ippjo xout aL, aR
endop
+
+
+
#end
diff --git a/sonics/pgdb.udo b/sonics/pgdb.udo deleted file mode 100755 index be2598a..0000000 --- a/sonics/pgdb.udo +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef UDO_PGDB
-#define UDO_PGDB ##
-/*
- PostgreSQL connection and tools
- Slim excerpt for Partial Emergence
-
- This file is part of the SONICS UDO collection by Richard Knight 2021, 2022
- License: GPL-2.0-or-later
- http://1bpm.net
-*/
-
-#include "sonics/__config__.udo"
-
-gidb dbconnect "postgresql", "$PGDB_HOST", "$PGDB_NAME", "$PGDB_USER", "$PGDB_PASSWORD"
-
-#end
diff --git a/sonics/sequencing_melodic.udo b/sonics/sequencing_melodic.udo index 05fb614..69f6a70 100755 --- a/sonics/sequencing_melodic.udo +++ b/sonics/sequencing_melodic.udo @@ -10,11 +10,8 @@ http://1bpm.net
*/
-
-#include "sonics/__config__.udo" ; using fftsize for tuning
#include "sonics/chords.udo" ; chord data
#include "sonics/sequencing.udo" ; sequencer base
-#include "sonics/wavetables.udo" ; for tuning
; if these are set, then don't launch the manager automatically. sequencing_melodic_persistence will load accordingly
#ifdef MEL_INITPATH
@@ -48,6 +45,7 @@ gimel_next_notes ftgen 0, 0, -13, -7, 0 ; next notes: index 0 is the length gimel_temp_random ftgen 0, 0, -gimel_number, -7, 0 ; temp storage for pattern randomisation
gkmel_section_change init 0 ; section change trigger
+gkmel_section_change_due init 0 ; how many beats until next section change
gkmel_futures_refresh_trig init 0 ; trigger to set if futures are to be recalculated
gkmel_pause init 0 ; pause progression changes
@@ -536,12 +534,15 @@ instr _mel_manager gkmel_section_change = 1
endif
- if (kstep < table:k(_mel_currentsectionget:k(), gimel_lengths) - 1) then ; current step < current length
+ ksectionlength = table:k(_mel_currentsectionget:k(), gimel_lengths)
+ gkmel_section_change_due = ksectionlength - kstep
+
+ if (kstep < ksectionlength - 1) then ; current step < current length
kstep += 1
else
kstep = 0
endif
-
+
endif ; end each beat
diff --git a/sonics/sequencing_melodic_portamento.udo b/sonics/sequencing_melodic_portamento.udo index 208919d..dc6b4cf 100755 --- a/sonics/sequencing_melodic_portamento.udo +++ b/sonics/sequencing_melodic_portamento.udo @@ -10,7 +10,6 @@ http://1bpm.net
*/
-#include "sonics/__config__.udo" ; using fftsize for tuning
#include "sonics/sequencing_melodic.udo"
#include "sonics/wavetables.udo"
@@ -152,8 +151,8 @@ opcode mel_tune_portamento, aa, aaooooP aL, aR, ifn, imaxmult, ifftrate, ifftdiv, kfreqmult xin
ifn = (ifn == 0) ? gifnSine : ifn
imaxmult = (imaxmult == 0) ? 4 : imaxmult
- ifftrate = (ifftrate == 0) ? giFFTsize : ifftrate
- ifftdiv = (ifftdiv == 0) ? giFFTwinFactor : ifftdiv
+ ifftrate = (ifftrate == 0) ? 512 : ifftrate
+ ifftdiv = (ifftdiv == 0) ? 4 : ifftdiv
fmods pvsanal _mel_tune_chord_portamento(kfreqmult, ifn, imaxmult), ifftrate, ifftrate/ifftdiv, ifftrate, 1
fL1 pvsanal aL, ifftrate, ifftrate/ifftdiv, ifftrate, 1
fR1 pvsanal aR, ifftrate, ifftrate/ifftdiv, ifftrate, 1
diff --git a/sonics/sounddb.udo b/sonics/sounddb.udo deleted file mode 100755 index 502d007..0000000 --- a/sonics/sounddb.udo +++ /dev/null @@ -1,229 +0,0 @@ -#ifndef UDO_SOUNDDB
-#define UDO_SOUNDDB ##
-/*
- SQL database interface to sound object management.
- Slim excerpt for Partial Emergence
-
- This file is part of the SONICS UDO collection by Richard Knight 2021
- License: GPL-2.0-or-later
- http://1bpm.net
-
-*/
-
-; if XDB extract has been loaded, don't use database
-#ifdef XDB_SET
-#include "sonics/soundxdb.udo"
-#else
-
-#include "sonics/pgdb.udo"
-
-; set max number of files for global array allocation
-imaxindex dbscalar gidb, "SELECT MAX(id)+1 FROM file"
-gisounddb[][] init imaxindex, 4
-
-
-/*
- Load file to gisounddb: to be used internally and passed parameters from database
-
- _sounddb_loadfile ifileid, Spath, ichannels, iduration, irmsnorm, isamplerate
-
- ifileid database file ID, corresponds to index of gisounddb
- Spath path to load sound file from
- ichannels number of channels
- iduration sound duration
- irmsnorm normalisation factor
- isamplerate sample rate
-*/
-opcode _sounddb_loadfile, 0, iSiiii
- ifileid, Spath, ichannels, iduration, irmsnorm, isamplerate xin
- isize = iduration * isamplerate * ichannels
- ifn = ftgen(0, 0, isize, 1, strcat("$SOUND_BASE/", Spath), 0, 0, 0)
- gisounddb[ifileid][0] = ifn
- gisounddb[ifileid][1] = ichannels
- gisounddb[ifileid][2] = iduration
- gisounddb[ifileid][3] = irmsnorm
-endop
-
-
-/*
- Get file details for a give file ID
-
- ifn, ichannels, iduration, irmsnorm sounddb_get ifileid
-
- ifn ftable number containing sound
- ichannels number of channels in file
- iduration duration of file in seconds
- irmsnorm RMS normalisation factor
- ifileid file ID to look up
-*/
-opcode sounddb_get, iiii, i
- ifileid xin
- xout gisounddb[ifileid][0], gisounddb[ifileid][1], gisounddb[ifileid][2], gisounddb[ifileid][3]
-endop
-
-
-/*
- Load files to gisounddb if not already loaded, to be passed a 2D string array as returned from a database query. Returns the file IDs in an array
-
- ifileids[] _sounddb_loadobject SqueryResult[][]
-
- ifileids[] database file IDs, which also correspond to indexes in gisounddb
- SqueryResult[][] query result from database with each row containing file ID, path, channels, duration, RMS normalisation factor and samplerate
-*/
-opcode _sounddb_loadobject, i[], S[][]
- Sres[][] xin
- iarraylength = lenarray(Sres)
- idata[] init iarraylength
- index = 0
- while (index < iarraylength) do
- ifileid strtod Sres[index][0] ; fileid
- idata[index] = ifileid
-
- if (gisounddb[ifileid][0] == 0) then ; load required
- _sounddb_loadfile ifileid, Sres[index][1], strtod(Sres[index][2]), strtod(Sres[index][3]), strtod(Sres[index][4]), strtod(Sres[index][5])
- endif
- index += 1
- od
- xout idata
-endop
-
-
-/*
- Load a sound to gisounddb if not already loaded, based on a specified query using f_nearestnote.
- Return the file ID and the result of column 6, which is the ratio to the nearest pitch requested.
- Used internally by the sounddb_mel_nearestnote opcodes which select one row
-
- ifileid, ipitchratio _sounddb_mel_nearestnote_inner Squery
-
- ifileid file ID
- ipitchratio pitch ratio to note requested
- Squery query to evaluate
-*/
-opcode _sounddb_mel_nearestnote_inner, ii, S
- Squery xin
- Sres[][] dbarray gidb, Squery
- ifileid strtod Sres[0][0]
-
- if (gisounddb[ifileid][0] == 0) then ; load required
- _sounddb_loadfile ifileid, Sres[0][1], strtod(Sres[0][2]), strtod(Sres[0][3]), strtod(Sres[0][4]), strtod(Sres[0][5])
- endif
- xout ifileid, strtod(Sres[0][6])
-endop
-
-
-; nearest note query base
-#define SOUNDDB_NNQUERYBASE #SELECT file_id, path, channels, duration, rmsnormal, samplerate, pitchratio FROM f_nearestnote#
-
-
-/*
- Get the nearest note in a filecollection, return the file ID and the pitch ratio adjustment required to the requested note.
-
- ifileid, ipitchratio sounddb_mel_nearestnote Scollection, inote
-
- ifileid file ID, corresponding to index in gisounddb
- ipitchratio pitch ratio adjustment required to make the file match the requested note
- Scollection collection name
- inote MIDI note number
-*/
-opcode sounddb_mel_nearestnote, ii, Si
- Scollection, inote xin
- ifileid, ipitchratio _sounddb_mel_nearestnote_inner sprintf("$SOUNDDB_NNQUERYBASE (%f, '%s')", inote, Scollection)
- xout ifileid, ipitchratio
-endop
-
-
-/*
- Get the nearest note in a filecollection, return the file ID and the pitch ratio adjustment required to the requested note.
-
- ifileid, ipitchratio sounddb_mel_nearestnote icollectionid, inote
-
- ifileid file ID, corresponding to index in gisounddb
- ipitchratio pitch ratio adjustment required to make the file match the requested note
- icollectionid collection ID
- inote MIDI note number
-*/
-opcode sounddb_mel_nearestnote, ii, ii
- icollectionid, inote xin
- ifileid, ipitchratio _sounddb_mel_nearestnote_inner sprintf("$SOUNDDB_NNQUERYBASE (%f, %d)", inote, icollectionid)
- xout ifileid, ipitchratio
-endop
-
-
-/*
- Get the ID of a filecollection by name
-
- icollectionid sounddb_getcollectionid Scollection
-
- icollectionid collection ID
- Scollection collection name
-*/
-opcode sounddb_getcollectionid, i, S
- Scollection xin
- icollectionid = dbscalar(gidb, sprintf("SELECT id FROM filecollection WHERE name = '%s'", Scollection))
- xout icollectionid
-endop
-
-
-/*
- Get the collection ID and file IDs of a filecollection, also loading each file to gisounddb
-
- ifileids[], icollectionid sounddb_getcollection Scollection
-
- ifileids[] file IDs in the collection, accessible as indexes to f-tables in gisounddb
- icollectionid collection ID
- Scollection collection name
-*/
-opcode sounddb_getcollection, i[]i, S
- Scollection xin
- Sbase = {{select file_id, path, channels, duration, rmsnormal, samplerate, fc.id
- from svw.analysis_basic_collectionnorm a
- join filecollection fc on fc.id = a.filecollection_id
- where %s
- }}
-
- if (strindex(Scollection, ",") > 0) then
- Sclause = "(1=2"
- index = 1
- Stemp = Scollection
- while (index > 0) do
- index strindex Stemp, ","
- if (index > 0) then
- Sclause strcat Sclause, sprintf(" OR fc.name='%s'", strsub(Stemp, 0, index))
- Stemp strsub Stemp, index+1
- else
- Sclause strcat Sclause, sprintf(" OR fc.name='%s'", Stemp)
- endif
- od
- Sclause strcat Sclause, ")"
- else
- Sclause = sprintf("fc.name = '%s'", Scollection)
- endif
-
- Squery sprintf Sbase, Sclause
-prints Squery
-prints "\n\n"
- Sres[][] dbarray gidb, Squery
- idata[] _sounddb_loadobject Sres
- icollectionid = strtod(Sres[0][6])
- xout idata, icollectionid
-endop
-
-
-/*
- Get the file IDs of a filecollection, also loading each file to gisounddb
-
- ifileids[] sounddb_getcollection Scollection
-
- ifileids[] file IDs in the collection, accessible as indexes to f-tables in gisounddb
- Scollection collection name
-*/
-opcode sounddb_getcollection, i[], S
- Scollection xin
- idata[], icollectionid sounddb_getcollection Scollection
- xout idata
-endop
-
-; end of XDB_SET
-#end
-
-#end
diff --git a/sonics/soundxdb.udo b/sonics/soundxdb.udo index c27b2bf..4e0ad61 100755 --- a/sonics/soundxdb.udo +++ b/sonics/soundxdb.udo @@ -78,7 +78,6 @@ endop */
opcode sounddb_getcollection, i[]i, S
Scollection xin
-
itotalsize = 0
if (strindex(Scollection, ",") > 0) then
index = 1
@@ -94,7 +93,6 @@ opcode sounddb_getcollection, i[]i, S itotalsize += ftlen(gixdb_collectionsfn[icollectionid])
endif
od
-
idata[] init itotalsize
iwriteindex = 0
index = 1
@@ -124,7 +122,7 @@ opcode sounddb_getcollection, i[]i, S od
else
- icollectionid = sounddb_getcollectionid(Stemp)
+ icollectionid = sounddb_getcollectionid(Scollection)
idata[] tab2array gixdb_collectionsfn[icollectionid]
igoto complete
endif
@@ -137,28 +135,6 @@ endop /*
- gixdb_pitchreference
- has 127 * 4 entries. get start and end indexes for gixdb_pitchnotes by
- index = (inote + (icollectionid * 127)) * 2
-
- then values
- iminindex table index, gixdb_pitchreference
- imaxindex table index+1, gixdb_pitchreference
-
- then get the actual files which are between min and max indexes eg
-
- iselected = round(random(iminindex, imaxindex))
- ifileid table iselected, gixdb_pitchnotes
- ipitchadjust table iselected, gixdb_pitchadjust
-
-
-
-*/
-
-
-
-
-/*
Get the nearest note in a filecollection, return the file ID and the pitch ratio adjustment required to the requested note.
ifileid, ipitchratio sounddb_mel_nearestnote icollectionid, inote
@@ -170,7 +146,7 @@ endop */
opcode sounddb_mel_nearestnote, ii, ii
icollectionid, inote xin
- irefindex = ((inote - $XDB_MINNOTE) + (icollectionid * 128)) * 2 ;, gixdb_pitchreference
+ irefindex = ((inote - $XDB_MINNOTE) + tab_i(icollectionid, gixdb_pitchrefoffset)) * 2
iselected = round(random(tab_i(irefindex, gixdb_pitchreference), tab_i(irefindex+1, gixdb_pitchreference)))
ifileid tab_i iselected, gixdb_pitchnotes
ipitchratio tab_i iselected, gixdb_pitchadjust
|