Cabbage Logo
Back to Cabbage Site

Instrument with audio and waveforms

Hello, I have a question regarding file uploads. I am working on an instrument with multiple oscillator modes, one of which relies on audio files. To illustrate, I’ve attached a simple example. This example consists of two modes: Mode 1 employs a sine oscillator, while Mode 2 functions by playing user-loaded audio files. The instrument do not start if the audio is not loaded.

For Mode 2 to operate, the instrument requires an audio file to be loaded by the user. I’m wondering if there’s a way to make Mode 1 independent of the audio file loading process for Mode 2. One potential solution I’m considering is to save a preset that includes a pre-loaded audio file and set the instrument to start with that preset. By having the audio file information within the preset, it might enable the instrument to start without user intervention. However, I’m uncertain if this is achievable.

Play modes.csd (2.1 KB)

You can do this with presets, but you also just load the a default sample when the instrument starts. If you call ftgen before instrument 1 in so-called instrument 0 space:

0dbfs = 1

ifno1 ftgen 99, 0, 0 1, "myfile.wav", 0, 4, 1

Or you could load the sample in your score section too. Presets will work too but might be overkill for such a simple thing.

Thank you for the response and suggestion. The concept of utilizing instrument 0 has indeed proven to be quite helpful. Although I couldn’t fix it by calling ftgen on instrument 0 since “soundfiler” , “loadfile” and “Sfile” are involved, I managed to find a solution through the following lines of code in instrument 0:

cabbageSet 1, “soundfiler1”, “file”, “beats.wav”
cabbageSet 1, “loadfile1”, “file”, “beats.wav”

This solution has worked seamlessly in the latest version, automatically loading the files on the screen and populating the tables when the instrument is triggered.

1 Like