Play in Tidal using a buffer from SuperCollider (SC)

Hi everyone!
I'm learning these new languages (Tidal and SC) every day, but there's something I don't quite get ^^
I'm trying to use a buffer as a SynthDef in SC and play it with
$ sound "" in Tidal, but it doesn't seem to work... Well it's working with other synths that i build but not with buffers, i think i missed a part...

Any idea how I could do that?

Thanks

Tom

b = Buffer.read(s, "/Users/tommyheisler/Downloads/recording.wav");

(SynthDef(\buffer_play, {
	var sig, env;
	sig = PlayBuf.ar(1,
		bufnum: \buf.kr(0),
		rate: BufRateScale.kr(\buf.kr(0)) * \rate.kr(0.3),
		startPos: \spos.kr(2),
		loop: 1,
		doneAction: 2
	);
	env = EnvGen.kr(Env([0,1,0], [0.2,0.1], [-2,-3], 2),
		\gate.kr(1),
		doneAction: 2
	);
	sig = sig * env;
	sig = sig * \amp.kr(0);

	Out.ar(\out.kr(0), sig);
}).add)

And then in Tidal:

d1 $ s "buffer_play"

Cool, thanks! I did it! But I need to stop the sample in SC... I can't use hush or d1 $ silence in Tidal to stop it...

Any guess?

Here is my superdirt_startup file:"

s.waitForBoot {
    ~dirt = SuperDirt(2, s); // two output channels
    ~dirt.loadSoundFiles("/Users/tommyheisler/Documents/LIVE CODING/sonif"); // specify sample folder to load
    s.sync; // wait for supercollider to finish booting up
    ~dirt.start(57120, 0 ! 12); // start superdirt, listening on port 57120, create twelve orbits each sending audio to channel 0
};




(
s.reboot { // server options are only updated on reboot
	// configure the sound server: here you could add hardware specific options
	// see http://doc.sccode.org/Classes/ServerOptions.html
	s.options.numBuffers = 1024 * 256; // increase this if you need to load more samples
	s.options.memSize = 8192 * 32; // increase this if you get "alloc failed" messages
	s.options.numWireBufs = 2048; // increase this if you get "exceeded number of interconnect buffers" messages
	s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes"
	s.options.numOutputBusChannels = 2; // set this to your hardware output channel size, if necessary
	s.options.numInputBusChannels = 2; // set this to your hardware output channel size, if necessary
	// boot the server and start SuperDirt
	s.waitForBoot {
		~dirt.stop; // stop any old ones, avoid duplicate dirt (if it is nil, this won't do anything)
		~dirt = SuperDirt(2, s); // two output channels, increase if you want to pan across more channels
		~dirt.loadSoundFiles;   // load samples (path containing a wildcard can be passed in)
		// for example: ~dirt.loadSoundFiles("/Users/myUserName/Dirt/samples/*");
		// s.sync; // optionally: wait for samples to be read
		~dirt.start(57120, 0 ! 12);   // start listening on port 57120, create two busses each sending audio to channel 0
		SuperDirt.default = ~dirt; // make this instance available in sclang (optional)

		// optional, needed for convenient access from sclang:
		(
			~d1 = ~dirt.orbits[0]; ~d2 = ~dirt.orbits[1]; ~d3 = ~dirt.orbits[2];
			~d4 = ~dirt.orbits[3]; ~d5 = ~dirt.orbits[4]; ~d6 = ~dirt.orbits[5];
			~d7 = ~dirt.orbits[6]; ~d8 = ~dirt.orbits[7]; ~d9 = ~dirt.orbits[8];
			~d10 = ~dirt.orbits[9]; ~d11 = ~dirt.orbits[10]; ~d12 = ~dirt.orbits[11];
		);

		// directly below here, in your own copy of this file, you could add further code that you want to call on startup
		// this makes sure the server and ~dirt are running
		// you can keep this separate and make it easier to switch between setups
		// by using "path/to/my/file.scd".load and if necessary commenting out different load statements
		// ...

	};

	s.latency = 0.3; // increase this if you get "late" messages


};
);

And i get this sometimes...

1 existing sample bank:
sonif (1) 
... file reading complete. Required 6 MB of memory.

SuperDirt: listening on port 57120
no synth or sample named 'sonif' could be found.
module 'sound': instrument not found: sonif

Ok i found it by myself ^^
I maybe used a bad sample (a noise one)
I think it works :slight_smile: thanks Igor !

1 Like

Hello everyone,

I’m encountering again an issue with using custom samples in TidalCycles and SuperCollider. Here’s what I did following the Tidal guide for custom samples.

What I did:

  • I added the following code to the startup.scd file in SuperCollider to automatically load my samples:
~dirt.loadSoundFiles("/Users/tommyheisler/Library/Application Support/SuperCollider/downloaded-quarks/Dirt-Samples/sample_tom/*");
~dirt.loadSoundFiles("/Users/tommyheisler/Library/Application Support/SuperCollider/downloaded-quarks/Dirt-Samples/sample_tom/india/*");
~dirt.loadSoundFiles("/Users/tommyheisler/Library/Application Support/SuperCollider/downloaded-quarks/Dirt-Samples/sample_tom/sonif/*");
~dirt.loadSoundFiles;

I then recompiled the classes and tried to play a specific sample located in the "india" folder using the following Tidal command:

d3 $ loopAt 1 $ s "india"

The issue:

With this command, the sample plays extremely fast, it doesn’t loop, and I can stop it properly using Tidal. However, I would like to use the original sample, which is about 10 seconds long.

When I try to play the sample with loopAt 1, it plays too fast, and I can’t retain its original length. If I try to play the sample normally without loopAt, SuperCollider automatically creates a loop that I can’t control.

Has anyone experienced this kind of issue or know what might be going wrong?

Thanks in advance for your help!

controlling long samples is a tricky beast -
loopAt 1 fits the sample into 1 cycle, it sounds a lot longer than 1 cycle (although, you can set your own "cycles per second" with for example, # cps 0.1 which would set the full cycle length to 10s

Another option, experiment with higher loopAt numbers - loopAt 2 would play the sample across the length of 2 cycles, loopAt 4 across 4, etc

You also have time stretching options with # timescale:

You should look also at # cut (which will stop your sample playback overlapping), slice splice and chop for further control measures

2 Likes

Allright ! :slight_smile: it's works ! thanks