在 SuperCollider 中渲染文件声音的最佳方式是什么?

发布于 2024-11-25 01:20:52 字数 94 浏览 2 评论 0原文

以编程方式将 SuperCollider 程序渲染到文件(例如 wav 文件)的最佳方法是什么?

我可以指定文件的持续时间(例如30秒)吗?

What is the best way to programatically render a SuperCollider program to a file (say a wav file).

Can I specify the duration of the file (eg 30 seconds)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屋檐 2024-12-02 01:20:52

您可以使用 Score.recordNRT 来完成此操作。

有一个关于如何使用它的教程 这里

You can do this with Score.recordNRT.

There's a tutorial on how to use it here.

半城柳色半声笛 2024-12-02 01:20:52

除了 Score.recordNRT(这可能是更方便的方法之一,也是我不知道的方法)之外,还有很多不同的方法可以做到这一点。 DiskOut.arpathchannelsArray 作为 args。您还可以尝试 Server 具有的 .record 实例方法。以下是两者的示例(来自帮助文档):

DiskOut.ar 方式

// start something to record
x = Synth.new("bubbles");

// allocate a disk i/o buffer
b= Buffer.alloc(s, 65536, 2);

// create an output file for this buffer, leave it open
b.write("~/diskouttest.aiff".standardizePath, "aiff", "int16", 0, 0, true);
// create the diskout node; making sure it comes after the source
d = Synth.tail(nil, "help-Diskout", ["bufnum", b]);
// stop recording
d.free;
// stop the bubbles
x.free;
// close the buffer and the soundfile
b.close;
// free the buffer
b.free;

// play it back
(
x = Synth.basicNew("help-Diskin-2chan");
m = { arg buf; x.addToHeadMsg(nil, [\bufnum,buf])};

b = Buffer.cueSoundFile(s,"~/diskouttest.aiff".standardizePath, 0, 2, completionMessage: m);
)
x.free; b.close; b.free; // cleanup

Server.record 方式:

s.boot; // start the server

// something to record
(
SynthDef("bubbles", {
    var f, zout;
    f = LFSaw.kr(0.4, 0, 24, LFSaw.kr([8,7.23], 0, 3, 80)).midicps; // glissando function
    zout = CombN.ar(SinOsc.ar(f, 0, 0.04), 0.2, 0.2, 4); // echoing sine wave
    Out.ar(0, zout);
}).add;
SynthDef("tpulse", { arg out=0,freq=700,sawFreq=440.0;
    Out.ar(out, SyncSaw.ar(freq,  sawFreq,0.1) )
}).add;

)

x = Synth.new("bubbles");

s.prepareForRecord; // you have to call this first

s.record;

s.pauseRecording; // pausable

s.record // start again

s.stopRecording; // this closes the file and deallocates the buffer recording node, etc.

x.free; // stop the synths

// look in your recordings folder and you'll find a file named for this date and time    

There are lots of different ways to do this in addition to Score.recordNRT (which is maybe one of the more convenient ones, and also something I did not know about). DiskOut.ar takes path and channelsArray as args. You could also try the .record instance method that Server has. Here are examples (from the help docs) of both:

The DiskOut.ar way

// start something to record
x = Synth.new("bubbles");

// allocate a disk i/o buffer
b= Buffer.alloc(s, 65536, 2);

// create an output file for this buffer, leave it open
b.write("~/diskouttest.aiff".standardizePath, "aiff", "int16", 0, 0, true);
// create the diskout node; making sure it comes after the source
d = Synth.tail(nil, "help-Diskout", ["bufnum", b]);
// stop recording
d.free;
// stop the bubbles
x.free;
// close the buffer and the soundfile
b.close;
// free the buffer
b.free;

// play it back
(
x = Synth.basicNew("help-Diskin-2chan");
m = { arg buf; x.addToHeadMsg(nil, [\bufnum,buf])};

b = Buffer.cueSoundFile(s,"~/diskouttest.aiff".standardizePath, 0, 2, completionMessage: m);
)
x.free; b.close; b.free; // cleanup

The Server.record way:

s.boot; // start the server

// something to record
(
SynthDef("bubbles", {
    var f, zout;
    f = LFSaw.kr(0.4, 0, 24, LFSaw.kr([8,7.23], 0, 3, 80)).midicps; // glissando function
    zout = CombN.ar(SinOsc.ar(f, 0, 0.04), 0.2, 0.2, 4); // echoing sine wave
    Out.ar(0, zout);
}).add;
SynthDef("tpulse", { arg out=0,freq=700,sawFreq=440.0;
    Out.ar(out, SyncSaw.ar(freq,  sawFreq,0.1) )
}).add;

)

x = Synth.new("bubbles");

s.prepareForRecord; // you have to call this first

s.record;

s.pauseRecording; // pausable

s.record // start again

s.stopRecording; // this closes the file and deallocates the buffer recording node, etc.

x.free; // stop the synths

// look in your recordings folder and you'll find a file named for this date and time    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文