./../../src/sndfilenet.lsp

## palette/sndfilenet [ Classes ]

[ Top ] [ palette ] [ Classes ]

NAME

     sndfile-palette

     File:             sndfilenet.lsp

     Class Hierarchy:  named-object -> linked-named-object -> sclist ->
                       circular-sclist -> assoc-list -> recursive-assoc-list ->
                       palette -> sndfile-palette -> sndfilenet

     Version:          1.0.12

     Project:          slippery chicken (algorithmic composition)

     Purpose:          Implementation of the sndfilenet class which extends
                       sndfile-palette to add functionality for loading and
                       playing sounds within MaxMSP.

     Author:           Michael Edwards: m@michael-edwards.org

     Creation date:    23rd October 2017, Essen

     $$ Last modified:  17:34:58 Sat Jan 30 2021 CET

     SVN ID: $Id$

## sndfilenet/(setf next-sfes) [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DATE

     October 21st 2017, Essen

DESCRIPTION

     A setf :after method. Set the next-sfes slot to be a sndfile-ext object. If
     it is already, leave it as is. If it's an integer, assume it's a cue number
     and get the right object, otherwise get the object with this ID.

     If this is causing problems, use (setf (slot-value sfn 'next-sfes) ... )

     If we're trying to set using a reference/id like '(group1 snd3) then it
     will have to be a two-element list.

SYNOPSIS

    (defmethod (setf next-sfes) :after (value (sfn sndfilenet))

## sndfilenet/analyse-followers [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DESCRIPTION

     Using the followers slots of each sndfile in the palette, go through each
     sndfile in the palette and generate a large number of following sounds,
     i.e. emulate max-play. The results of the follow-on process are then
     analysed and a warning will be issued if any sndfile seems to dominate
     (defined as being present at least twice as many times as its 'fair share',
     where 'fair share' would mean an even spread for all the sound files in the
     palette).

ARGUMENTS

     - The sndfilenet object.

OPTIONAL ARGUMENTS

     - integer: How many times to repeat the generation process.  Default = 1000.
     - T or NIL for verbose warnings: if T, the emulation list of sound files
       will be printed. Default NIL.

RETURN VALUE

     T or NIL depending on whether the analysis detects an even spread or not.

SYNOPSIS

    (defmethod analyse-followers ((sfn sndfilenet)
                                  &optional (depth 1000) verbose)

## sndfilenet/auto-cue-nums [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DESCRIPTION

     Set the cue-num slot of every sndfile-ext object in the palette to be an
     ascending integer starting at 2. NB If a sndfile has it's :use slot set to
     NIL it won't be given a cue number.

ARGUMENTS

     - a sndfilenet object.

RETURN VALUE

     The cue number of the last sndfile-ext object.

SYNOPSIS

    (defmethod auto-cue-nums ((sfn sndfilenet))

## sndfilenet/auto-followers [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DATE

     October 20th 2017

DESCRIPTION

     Automatically generate follower sound files for every sound file in the
     palette. These are a mixture of the other files in the same group plus one
     from another group, so that we'll move through.

ARGUMENTS

     - a sndfilenet object

OPTIONAL ARGUMENTS

     - a list of references for which auto-followers should be generated. Default
     = NIL = all groups (which applies also if T is passed here).

RETURN VALUE

     T

SYNOPSIS

    (defmethod auto-followers ((sfn sndfilenet) &optional refs)

## sndfilenet/get-snd-with-cue-num [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DATE

     December 21st 2012

DESCRIPTION

     Return the (first, but generally unique) sndfile object which has the
     given cue-num slot.

ARGUMENTS

     - the sndfilenet object.
     - the cue number (integer).

RETURN VALUE

     The sndfile/sndfile-ext object with the given cue number or NIL if it can't
     be found.

SYNOPSIS

    (defmethod get-snd-with-cue-num ((sfn sndfilenet) cue-num)

## sndfilenet/make-sfn [ Functions ]

[ Top ] [ sndfilenet ] [ Functions ]

DESCRIPTION

     Make a sndfilenet object. This object is a simple palette which checks
     to make sure that all of the sound files in a given list exist for each
     given ID.

     Sound files are given as as single names, without the path and without the
     extension. These can be given using the optional keyword arguments <paths>
     and <extensions>.

     NB Although this class is a palette and therefore a subclass of
     recursive-assoc-list, the sound lists in this case cannot be nested beyond
     a depth of two (as in example below).

ARGUMENTS

     - An ID for the palette.
     - A list of lists that contains IDs for the names of one or more groups of
       sound files, each paired with a list of one or more names of existing
       sound files. The sound file names themselves can be paired with keywords
       from the sndfile class, such as :start, :end, and :frequency, to define
       and describe segments of a given sound file.

OPTIONAL ARGUMENTS

     keyword arguments:
     - :paths. A list of one or more paths to where the sound files are located.
     - :extensions. A list of one or more sound file extensions for the
       specified sound files. The default initialization for this slot of the
       sndfilenet already contains ("wav" "aiff" "aif" "snd"), so this
       argument can often be left unspecified.
     - :warn-not-found. T or NIL to indicate whether a warning should be printed
       to the Lisp listener if the specified sound file cannot be found.
       T = print warning. Default = T.
     - :auto-followers. T or NIL to indicate whether the auto-followers method
       should be called once the object is initialised. Note that if this is T,
       then all the followers slots of the sndfile-ext objects will be deleted as
       part of the process. Default = NIL.
     - :analyse-followers. T or NIL to indicate whether to call the
       analyse-followers after initialisation (and possibly auto-followers is
       called). Default = NIL.

RETURN VALUE

     Returns NIL.

EXAMPLE

    ;;; NB won't work unless you change /path/to/ below
    (let ((msfn (make-sfn 'sfn-test
                          '((sndfile-group-1
                             (test-sndfile-1))
                            (sndfile-group-2
                             (test-sndfile-2 test-sndfile-3
                              (test-sndfile-4 :frequency 261.61)))
                            (sndfile-group-3
                             ((test-sndfile-5 :start 0.006 :end 0.182)
                              test-sndfile-6)))
                          :paths '("/path/to/sound-files-dir-1/"
                                   "/path/to/sound-files-dir-2/")))))

SYNOPSIS

    (defun make-sfn (id sfn &key paths (extensions '("wav" "aiff" "aif" "snd"))
                              auto-freq (warn-not-found t)
                              auto-followers analyse-followers)

## sndfilenet/max-play-from-id [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DESCRIPTION

     This generates the data necessary to play the next sound in the current
     sound's followers list. See the sndfile-ext method for details.

ARGUMENTS

     - The sndfilenet object.
     - The group ID to play the next sound from, i.e. the topmost ID to group of
       sounds
     - The fade (in/out) duration in seconds.
     - The maximum loop duration in seconds.
     - The time to trigger the next file, as a percentage of the current
       sndfile-ext's duration.

OPTIONAL ARGUMENTS

     - whether to print data to the listener as it is generated. Default = NIL.

RETURN VALUE

     A list of values returned by the sndfile-ext method.

SYNOPSIS

    (defmethod max-play-from-id ((sfn sndfilenet) id fade-dur max-loop start-next
                                 &optional print)

## sndfilenet/preload-cues [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DESCRIPTION

     Return a list of preload commands for each sound file in a form that a Max
     sflist~ can process and store (which will include the path and start/stop
     data: see sndfile-ext::max-cue for details).

     E.g. preload 231 triplet-mphonic-001.wav 0. 3300.612305 0 1.

ARGUMENTS

     - the sndfilenet object.

RETURN VALUE

     The list of preload strings that osc-call can then pass on to the sflist~

SYNOPSIS

    #+(and darwin sbcl)
    (defmethod preload-cues ((sfn sndfilenet))

## sndfilenet/reset [ Methods ]

[ Top ] [ sndfilenet ] [ Methods ]

DESCRIPTION

     Reset the followers' slot circular list to the beginning or to <where> and
     the starting sounds for each group also.

ARGUMENTS

     - the sndfilenet object.

OPTIONAL ARGUMENTS

     - an integer to set the point at which to restart.  This can be higher than
       the number of followers as it will wrap.  Default = nil (which equates to
       0 lower down in the class hierarchy).
     - whether to issue a warning if <where> is greater than the number of
       followers (i.e. that wrapping will occur).  Default = T.

RETURN VALUE

     T

SYNOPSIS

    (defmethod reset ((sfn sndfilenet) &optional (where 0) (warn t))