Pattern recording produces an empty file

Hi,

I’m trying to record some pattern to an audio file and the produced file is just empty.

It used to work, so I don’t know where to check.

The instruction is :

t=TempoClock(56/60).permanent_(true);
~file=thisProcess.platform.recordingsDir+/+"test_"++Date.getDate.stamp++".wav"; // une sorte de timestamp

p=Pbind(
	\dur, 0.2, //Pwhite(2.0,3.0)
	\degree, Pbrown(-14,14,2)
	).record(server: s, clock: t, dur: 10, path: ~file, headerFormat: "WAV", sampleFormat: "int16");

A file is produced but it is empty :

Instance of SoundFile {    (00000223D474D648, gc=DC, fmt=00, flg=00, set=03)
  instance variables [7]
    fileptr : RawPointer 00000223D5185AC0
    headerFormat : "WAV"
    sampleFormat : "int16"
    numFrames : Integer 0
    numChannels : Integer 2
    sampleRate : Integer 44100
    path : "C:\Users\laurent\Documents\SuperCollider\Rec..."
}

I also retried the example in this thread without more success.


However, if I try to record from UI directly, then sound is recorded.

What’s wrong in my statement/config ?

I’m afraid I can’t reproduce the problem. I ran exactly your code snippet and:

Instance of SoundFile {    (0x55b1758d7628, gc=04, fmt=00, flg=00, set=03)
  instance variables [7]
    fileptr : RawPointer 0x55b1756875c0
    headerFormat : "WAV"
    sampleFormat : "int16"
    numFrames : Integer 507776
    numChannels : Integer 2
    sampleRate : Integer 44100
    path : "..."
}

I tried two ways: 1. Server already booted. 2. Recompile classlib, and run the whole block without booting the server (record boots the server automatically). Both times, the recorded file was valid.

Perhaps try capturing OSC: s.dumpOSC(1); – in this case, 10 seconds may be too much, try dur: 2 – and copy/paste the messages from the post window. Should be like:

[ "#bundle", 1, 
  [ "/sync", 1008 ]
]
[ "/b_alloc", 0, 32768, 2, 0 ]
[ "/b_write", 0, "/home/xxxxx/.local/share/SuperCollider/Recordings/test_230117_103004.wav", "WAV", "int16", 0, 0, 1, 0 ]
[ "/d_recv", DATA[152], 0 ]
[ 21, 1055, 0, 1 ]
[ "#bundle", 16676977577536223054, 
  [ 21, 1056, 1, 1055 ],
  [ 9, "system_link_audio_1", 1057, 1, 1056, "out", 0, "in", 4, "level", 1, "fadeTime", 0.02, "vol", 1 ],
  [ 9, "system_link_audio_1", 1058, 1, 1056, "out", 1, "in", 5, "level", 1, "fadeTime", 0.02, "vol", 1 ]
]
[ "#bundle", 1, 
  [ "/sync", 1009 ]
]
[ "#bundle", 16676977577733352608, 
  [ 9, "temp__1", 1059, 3, 1055, "bufnum", 0, "bus", 4 ]
]
[ "#bundle", 16676977577733352608, 
  [ 9, "default", 1060, 0, 1, "out", 4, "freq", 246.942, "amp", 0.1, "pan", 0 ]
]
[ "#bundle", 16676977578469632716, 
  [ 15, 1060, "gate", 0 ]
]

... trim most of the notes...

... cleanup...
[ 11, 1055 ]
[ "/b_free", 0, 0 ]  // this *should* close the file but maybe that's a bit funny in Windows?
[ "/d_free", "temp__1" ]

hjh

On second thought: try changing line 129 in Patterns.sc (original is buffer.free;) to:

					buffer.close({ buffer.freeMsg });

This “shouldn’t” be necessary (and isn’t in Linux) but maybe it is necessary in Windows. If you confirm that it works then I can put in a bugfix.

hjh

Well, this is strange…

I was replying that your suggestion hasn’t changed anything and that my recordings kept being empty despite my log output being similar to yours, when all suddenly it started working as expected…

What did I changed ?

Actually, my code snippet is working fine when I start my SuperCollider session with it.

But whenever I run the following code, no more recording occurs. Not even my code snippet. So I guess this code is breaking something within SuperCollider. I suspected the accented character of the file name. So I retry with a non accented version. I didn’t change anything. This code seems to break somehow Supercollider…

(
s.waitForBoot({
	t=TempoClock(56/60).permanent_(true);


	// ~buffer = Buffer.readChannel(s,"G:/Enregistrements/Synthèse_Divers_Sons/CourtDoucâtre.wav", channels: [0] );
	~buffer = Buffer.readChannel(s,"D:/Misc/temp/CourtDouc.wav", channels: [0] );

	SynthDef.new(\granular,{
		arg sync=1, buf=0, grainDur=0.8,
		atk=0.01,rel=1, c1=3,c2=(-1),rate=1, pos=0, amp=0.5,
		freqCtrl=0.01, durMin=0.001, durMax=1,
		panFreq=1, panRand=0,
		int=2, pan=0, envBuf=(-1), maxGrains=512, out=0;

		var pulseMin=\pulseMin.ir(20), pulseMax=\pulseMax.ir(21);

		var sig, env, densCtrl, durCtrl, panCtrl;

		densCtrl=Dust.ar({ExpRand(pulseMin,pulseMax)});
		durCtrl = grainDur * LFNoise1.ar(freqCtrl!8).exprange(durMin,durMax);
		panCtrl = pan + SinOsc.kr(panFreq).bipolar(panRand);
		env=Env([0,1,0],[atk,rel],[c1,c2],1).kr(doneAction:2,gate: \gate.kr(1));

		sig=GrainBuf.ar(
			2,
			densCtrl,
			durCtrl,
			buf,
			rate,
			pos,
			int,
			panCtrl,
			envBuf,
			maxGrains,
			amp,
		);

		sig= sig*env*amp;

		Out.ar(out, sig);

	}).add;

	s.sync;

	~buffer.postln;

});

)


(

~file=thisProcess.platform.recordingsDir+/+"115_rythmique_"++Date.getDate.stamp++".wav"; // une sorte de timestamp

p=Pbind(
	\instrument, \granular,
	\buf, ~buffer,
	\dur, 0.2,
	\rate, 1,
	\pulseMin, 50,
	\pulseMax, 70,
	\durMin, 0.008,
	\durMax, 0.4,
	\freqCtrl, 1,
	\pos,   Prand([0.83],inf),
	\panFreq, 1,
	\panRand, 0.25,
	\amp, 1.5,
	\atk, 0.01,
	\rel, 0.01 //
	// ).play(t,quant:4);
).record(server: s, clock: t, dur: 10, path: ~file, headerFormat: "WAV", sampleFormat: "int16");
format("Recording to %",~file).postln;
)


Your code modification suggestion

Hasn’t changed anything.

PostWindow when a recording is empty

-> a Pbind
[ "/b_alloc", 1, 32768, 2, 0 ]
[ "/b_write", 1, "C:\xxxx\Recordings\test_230117_092615.wav", "WAV", "int16", 0, 0, 1, 0 ]
[ "/d_recv", DATA[152], 0 ]
[ 21, 1070, 0, 1 ]
[ "#bundle", 16677069285514986938, 
  [ 21, 1071, 1, 1070 ],
  [ 9, "system_link_audio_1", 1072, 1, 1071, "out", 0, "in", 4, "level", 1, "fadeTime", 0.02, "vol", 1 ],
  [ 9, "system_link_audio_1", 1073, 1, 1071, "out", 1, "in", 5, "level", 1, "fadeTime", 0.02, "vol", 1 ]
]
[ "#bundle", 1, 
  [ "/sync", 1013 ]
]
[ "#bundle", 16677069285713363746, 
  [ 9, "temp__2", 1074, 3, 1070, "bufnum", 0, "bus", 4 ]
]
[ "#bundle", 16677069285713363746, 
  [ 9, "default", 1075, 0, 1, "out", 4, "freq", 987.767, "amp", 0.1, "pan", 0 ]
]
[ "#bundle", 16677069286449643854, 
  [ 15, 1075, "gate", 0 ]
]
[ "#bundle", 16677069286633713881, 
  [ 9, "default", 1076, 0, 1, "out", 4, "freq", 987.767, "amp", 0.1, "pan", 0 ]
]
[ "#bundle", 16677069287369993989, 
  [ 15, 1076, "gate", 0 ]
]
[ "#bundle", 16677069287554064016, 
  [ 9, "default", 1077, 0, 1, "out", 4, "freq", 783.991, "amp", 0.1, "pan", 0 ]
]
[ "#bundle", 16677069288290344124, 
  [ 15, 1077, "gate", 0 ]
]
// ...
]
[ "#bundle", 16677069298336143238, 
  [ "/n_free", 1074 ]
]
[ 11, 1070 ]
[ "/b_free", 1, 0 ]
[ "/d_free", "temp__2" ]

This is wrong: it allocates buffer 1, but then the recording synth uses buffer 0. This would explain why nothing gets recorded.

I can’t look at it right this second but I’m certain this is the problem, should not be hard to fix.

Thank you for providing the trace! I never would have guessed this.

hjh

1 Like

Bit late reply… upon investigation, I find 1/ it was my mistake initially :man_facepalming: and 2/ this has been fixed – pbind: fix pbind not recording · supercollider/supercollider@66b4df9 · GitHub – but it was fixed after SC 3.12.2 went out.

The fix is in SC 3.13.0 (currently in release-candidate status: Release 3.13.0-rc1 · supercollider/supercollider · GitHub). So you should upgrade to the release candidate.

hjh

1 Like