Skip to content

Instantly share code, notes, and snippets.

@cleemy-desu-wayo
Last active September 18, 2025 02:41
An example of SuperCollider code that plays different wav files depending on the received OSC value

An example of SuperCollider code that plays different wav files depending on the received OSC value

the following preparations are required:

  1. prepare a local file maoudamashii-inst-guitar08.wav from https://maou.audio/se_inst_guitar08/
  2. prepare a local file maoudamashii-inst-guitar10.wav from https://maou.audio/se_inst_guitar10/
  3. prepare a local file maoudamashii-inst-guitar13.wav from https://maou.audio/se_inst_guitar13/
  4. change the line that initializes base_dir

this example code is based on:
https://gist.github.com/cleemy-desu-wayo/ed47772c4e26841bb6ad17810c1953c1


NOTE

If you use this example code to train an AI on the playback results, or if you combine this code with an AI that sends OSC data, you may be violating the terms of use of the resource site.
再生結果をAIに学習させたり、OSCデータを送信するようなAIとこのコードを組み合わせて使ったりすると、素材サイトの規約に違反することになるかもしれません。
https://maou.audio/rule/

/*
* An example of SuperCollider code that plays different wav files depending on the received OSC value
* written by cleemy desu wayo / Licensed under CC0 1.0
* 2025-09-18
* ----
* maybe the updated version is here:
* https://gist.github.com/cleemy-desu-wayo/0da95cacc9d85c66d2ff565c4c73d0f3
*
* this example code is based on:
* https://gist.github.com/cleemy-desu-wayo/ed47772c4e26841bb6ad17810c1953c1
*
* ----
* the following preparations are required:
* 1. prepare a local file maoudamashii-inst-guitar08.wav from https://maou.audio/se_inst_guitar08/
* 2. prepare a local file maoudamashii-inst-guitar10.wav from https://maou.audio/se_inst_guitar10/
* 3. prepare a local file maoudamashii-inst-guitar13.wav from https://maou.audio/se_inst_guitar13/
* 4. change the line that initializes base_dir
*
* ----
* NOTE: If you use this example code to train an AI on the playback results, or if you combine this
* code with an AI that sends OSC data, you may be violating the terms of use of the resource site.
* 注意: 再生結果をAIに学習させたり、OSCデータを送信するようなAIとこのコードを組み合わせて
* 使ったりすると、素材サイトの規約に違反することになるかもしれません。
* https://maou.audio/rule/
*
*/
(
var port = 9003; // change this line appropriately
var base_dir = "/home/hoge/wav/"; // change this line appropriately
var wav1 = Buffer.read(s, base_dir ++ "maoudamashii-inst-guitar08.wav");
var wav2 = Buffer.read(s, base_dir ++ "maoudamashii-inst-guitar10.wav");
var wav3 = Buffer.read(s, base_dir ++ "maoudamashii-inst-guitar13.wav");
var play_wav = { |wav|
{
PlayBuf.ar(1, wav, BufRateScale.kr(wav) * 1, 1, 0, 0, 2);
}.play;
};
OSCdef(\osctest1,
{ |args| case { args[1].class == True } { ('absolutely true - ' ++ wav1).postln; play_wav.value(wav1) }
{ args[1].class == False } { ('absolutely false - ' ++ wav2).postln; play_wav.value(wav2) }
{ args[1].class == Nil } { ('absolutely nil - ' ++ wav3).postln; play_wav.value(wav3) };
}, '/test', nil, port);
play_wav.value(wav1);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment