The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
stk::Stk Class Reference

STK base class. More...

`#include <Stk.h>`

Inheritance diagram for stk::Stk:

## Public Member Functions
void | ignoreSampleRateChange (bool ignore=true)
| A function to enable/disable the automatic updating of class data when the STK sample rate changes.

## Static Public Member Functions
static StkFloat | sampleRate (void)
| Static method that returns the current STK sample rate.
static void | setSampleRate (StkFloat rate)
| Static method that sets the STK sample rate.
static void | clear_alertList ()
| Static method that frees memory from alertList_.
static std::string | rawwavePath (void)
| Static method that returns the current rawwave path.
static void | setRawwavePath (std::string path)
| Static method that sets the STK rawwave path.
static void | swap16 (unsigned char *ptr)
| Static method that byte-swaps a 16-bit data type.
static void | swap32 (unsigned char *ptr)
| Static method that byte-swaps a 32-bit data type.
static void | swap64 (unsigned char *ptr)
| Static method that byte-swaps a 64-bit data type.
static void | sleep (unsigned long milliseconds)
| Static cross-platform method to sleep for a number of milliseconds.
static bool | inRange (StkFloat value, StkFloat min, StkFloat max)
| Static method to check whether a value is within a specified range.
static void | handleError (const char *message, StkError::Type type)
| Static function for error reporting and handling using c-strings.
static void | handleError (std::string message, StkError::Type type)
| Static function for error reporting and handling using c++ strings.
static void | showWarnings (bool status)
| Toggle display of WARNING and STATUS messages.
static void | printErrors (bool status)
| Toggle display of error messages before throwing exceptions.

## Static Public Attributes
static const StkFormat | STK_SINT8
static const StkFormat | STK_SINT16
static const StkFormat | STK_SINT24
static const StkFormat | STK_SINT32
static const StkFormat | STK_FLOAT32
static const StkFormat | STK_FLOAT64

## Protected Member Functions
| Stk (void)
| Default constructor.
virtual | ~Stk (void)
| Class destructor.
virtual void | sampleRateChanged (StkFloat newRate, StkFloat oldRate)
| This function should be implemented in subclasses that depend on the sample rate.
void | addSampleRateAlert (Stk *ptr)
| Add class pointer to list for sample rate change notification.
void | removeSampleRateAlert (Stk *ptr)
| Remove class pointer from list for sample rate change notification.
void | handleError (StkError::Type type) const
| Internal function for error reporting that assumes message in `oStream_` variable.

## Detailed Description

STK base class.

Nearly all STK classes inherit from this class. The global sample rate and rawwave path variables can be queried and modified via Stk. In addition, this class provides error handling and byte-swapping functions.

The Synthesis ToolKit in C++ (STK) is a set of open source audio signal processing and algorithmic synthesis classes written in the C++ programming language. STK was designed to facilitate rapid development of music synthesis and audio processing software, with an emphasis on cross-platform functionality, realtime control, ease of use, and educational example code. STK currently runs with realtime support (audio and MIDI) on Linux, Macintosh OS X, and Windows computer platforms. Generic, non-realtime support has been tested under NeXTStep, Sun, and other platforms and should work with any standard C++ compiler.

STK WWW site: http://ccrma.stanford.edu/software/stk/

The Synthesis ToolKit in C++ (STK) Copyright (c) 1995–2023 Perry R. Cook and Gary P. Scavone

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Any person wishing to distribute modifications to the Software is asked to send the modifications to the original developer so that they can be incorporated into the canonical version. This is, however, not a binding provision of this license.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## Member Function Documentation

## ◆ setSampleRate()

static void stk::Stk::setSampleRate | ( | StkFloat | rate | ) |
| static

Static method that sets the STK sample rate.

The sample rate set using this method is queried by all STK classes that depend on its value. It is initialized to the default SRATE set in Stk.h. Many STK classes use the sample rate during instantiation. Therefore, if you wish to use a rate that is different from the default rate, it is imperative that it be set BEFORE STK objects are instantiated. A few classes that make use of the global STK sample rate are automatically notified when the rate changes so that internal class data can be appropriately updated. However, this has not been fully implemented. Specifically, classes that appropriately update their own data when either a setFrequency() or noteOn() function is called do not currently receive the automatic notification of rate change. If the user wants a specific class instance to ignore such notifications, perhaps in a multi-rate context, the function Stk::ignoreSampleRateChange() should be called.

## ◆ ignoreSampleRateChange()

void stk::Stk::ignoreSampleRateChange | ( | bool | ignore = `true` | ) |
| inline

A function to enable/disable the automatic updating of class data when the STK sample rate changes.

This function allows the user to enable or disable class data updates in response to global sample rate changes on a class by class basis.

176{ ignoreSampleRateChange_ = ignore; };

## Member Data Documentation

## ◆ STK_SINT8

const StkFormat stk::Stk::STK_SINT8
| static

-128 to +127

## ◆ STK_SINT16

const StkFormat stk::Stk::STK_SINT16
| static

-32768 to +32767

## ◆ STK_SINT24

const StkFormat stk::Stk::STK_SINT24
| static

Lower 3 bytes of 32-bit signed integer.

## ◆ STK_SINT32

const StkFormat stk::Stk::STK_SINT32
| static

-2147483648 to +2147483647.

## ◆ STK_FLOAT32

const StkFormat stk::Stk::STK_FLOAT32
| static

Normalized between plus/minus 1.0.

## ◆ STK_FLOAT64

const StkFormat stk::Stk::STK_FLOAT64
| static

Normalized between plus/minus 1.0.

The documentation for this class was generated from the following file:

- Stk.h

The Synthesis ToolKit in C++ (STK)
©1995--2023 Perry R. Cook and Gary P. Scavone. All Rights Reserved.