JSyn,通过另一个振荡器和一个常数馈入/控制/输入到/菊花链式连接的振荡器发出警报声,并产生多个声音 [英] JSyn, siren sound using oscillator fed/controlled/inputInto/daisy-chainedTo by another oscillator and a constant...and generating more than one sound

查看:134
本文介绍了JSyn,通过另一个振荡器和一个常数馈入/控制/输入到/菊花链式连接的振荡器发出警报声,并产生多个声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试按照此处的示例进行操作,但是该示例无法正常工作,并且无法找到其他任何来源: [ http://www.softsynth.com/jsyn/tutorial/osc_control.php] [1]

I have been trying to follow the example here, but it is not working, and I have not been able to find any other sources: [ http://www.softsynth.com/jsyn/tutorial/osc_control.php ][1]

据我所知,我完全按照此示例代码片段进行了操作(除了发现自该网页更新后的某个时间AddUnit更改为Add之外):

As far as I can tell, I have followed this sample code snippet exactly (except that I found out that AddUnit changed to Add sometime since that webpage was updated):

[...]使频率稍微在一个更有用的范围内的中心频率左右波动.我们可以通过使用AddUnit将振荡器的输出添加到我们可以设置的恒定值来实现.我们还可以将第一个振荡器的幅度减小到一个较小的范围内.

[...]make the frequency to waver slightly about a central frequency that is in a more useful range. We can do this by using an AddUnit to add the output of an oscillator to a constant value that we can set. We can also reduce the amplitude of the first oscillator to be within a smaller range.

AddUnit  freqAdder  = new AddUnit();
sineOsc1.output.connect( freqAdder.inputA );     // pass through adder
freqAdder.output.connect( sineOsc2.frequency );  // control second oscillator freq
freqAdder.inputB.set( 500.0 );   // add constant that will center us at 500 Hz
sineOsc1.amplitude.set( 100.0 ); // reduce offset to +/- 100 Hz

因此sineOsc2的频率将是sineOsc1.output加上inputB.

Thus the frequency of sineOsc2 will be sineOsc1.output plus inputB.

有人可以看到我的代码有什么问题吗(如下)?我已经有一个简单的振荡器声音工作了.我只是听不到这第二个更复杂的声音,听起来像是警笛声.

Can anybody see what is wrong with my code (below)? I already have a simple oscillator sound working. I just can't hear this second, more complicated sound, which is supposed to be siren-like.

这可能是我对警笛声音编码的问题,或者可能仅仅是我产生两种声音的编码问题. (是否需要2个Synthesizers?我已经用1个和2个Synthesizers进行了尝试.)(是否需要2个lineOuts?其他Web来源说否".)

It may be a problem with my coding of the siren sound, or it may just be a problem with my coding of generating two sounds. (Are 2 Synthesizers required? I have tried it with 1 and 2 Synthesizers.) (Are 2 lineOuts required? Other web sources say "no".)

这是我的代码,带有2个synthesizers和1个输出:

Here is my code with 2 synthesizers and 1 output:

(引号中的注释来自其他示例代码.我仅了解这些注释的内容.)

(Comments in quotes are from other sample code. I only understand a little of what those comments are getting at.)

import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.Add;
import com.jsyn.unitgen.LineOut;
import com.jsyn.unitgen.SineOscillator;

[...]

    com.jsyn.Synthesizer synthPCMSonification = JSyn.createSynthesizer();
    com.jsyn.Synthesizer synthPCMAlarm = JSyn.createSynthesizer();
                                // "an instance of Synthesizer"
    com.jsyn.unitgen.SineOscillator oscData = new SineOscillator();
    SineOscillator oscAlarmWaverEnvelope = new SineOscillator();
    SineOscillator oscAlarmComplete = new SineOscillator();
                                // "a unit"
    com.jsyn.unitgen.LineOut oscsLineOut = new LineOut();
                                // "a unit"

[...]

    // "start synthesis engine"
    synthPCMSonification.start();
    synthPCMAlarm.start();

    // "build unit generators"
    synthPCMSonification.add(oscData);
    //synthPCM.add(oscAlarmWaverEnvelope); //TODO:  Figure out if need line
    synthPCMAlarm.add(oscAlarmComplete);

    synthPCMSonification.add(oscsLineOut);
    synthPCMAlarm.add(oscsLineOut);

    oscData.frequency.set(LOWEST_FREQUENCY_C);
    oscData.amplitude.set(volSonification);

    //create a frequency adder for a siren-like alarm
    com.jsyn.unitgen.Add oscAlarmFreqAdder = new Add(); //used to be AddUnit

    //set the alarm centre frequency
    alarmCentreFreq = (LOWEST_FREQUENCY_C
                       * Math.pow(2, OCTAVES_SPANNED_C + 1));
                       //This formula centres the alarm one octave
                       //above the threshold's sonification freqency
    alarmWaverFreq = alarmCentreFreq / 10;
                     //This sets the waver at one tenth of the centre freq
                     //Unfortunately, the waver appears to need to be the
                     //same amount above and below the centre
                     //(linear, vice perceptually-linear (exponential))
    System.out.println(alarmCentreFreq + "-Hz alarm centre frequency");
    oscAlarmFreqAdder.inputB.set(alarmCentreFreq);

    //set the alarm waver envelope
            //(alarm will range between centre-waver and centre+waver)
    oscAlarmWaverEnvelope.frequency.set(alarmCentreFreq / 10);

    //"pass through adder" (??)
oscAlarmWaverEnvelope.output.connect(oscAlarmFreqAdder.inputA);
//(entered this with by starting to type, then hitting [Ctrl]+[Space]!)

//"control the 2nd oscillator frequency" (?)
oscAlarmFreqAdder.output.connect(oscAlarmComplete.frequency);

    //set alarm volume
    oscAlarmComplete.amplitude.set(volAlarm);

    // "connect unit generators"
    // connect oscillator to both channels of stereo player
    oscAlarmComplete.output.connect(0, oscsLineOut.input, 0);
    oscAlarmComplete.output.connect(0, oscsLineOut.input, 1);

    // "startUnitGenerators"
    // "start execution of units.  JSyn 'pulls' data so the only unit
    // you have to start() is the last one, in this case our LineOut"
    oscsLineOut.start();

有多少人知道并使用JSyn? meta-oscillators怎么样?

How many people out there know and use JSyn? How about meta-oscillators?

如果您曾经将不同的JSyn部分连接在一起,或者只是让它一次输出多个声音,您将比我了解的更多...

If you have ever connected different JSyn parts together, or even just got it to output more than one sound at once, you know more than I do...

推荐答案

有很多地方可以改进.

1)您创建了两个合成器:

1) You created two synthesizers:

com.jsyn.Synthesizer synthPCMSonification = JSyn.createSynthesizer();
com.jsyn.Synthesizer synthPCMAlarm = JSyn.createSynthesizer();

仅当您以非实时或不同的采样率运行某些综合时才需要.我强烈建议仅使用一个合成器.跨合成器连接单元或在两个合成器上运行相同的单元将引起问题.我怀疑这是主要错误.

That is only needed if you are running some synthesis in non-real-time or at a different sample rate. I highly recommend only using one synthesizer. Connecting units across synthesizers or running the same unit on both synthesizers will cause problems. I suspect that is the main error.

您可以在一个合成器中包含多个LineOut单元.或者,您也可以通过将多个单元连接到LineOut来自动混音.

You can have multiple LineOut units in one synth. Or you can mix automatically by connecting multiple units to the LineOut.

2)我建议仅从连接到LineOut的一个振荡器开始.获得声音后,添加调制.

2) I recommend starting with just one oscillator connected to a LineOut. After you can get that to make sound, add the modulation.

3)您可以使用优化的PowerOfTwo单元获得指数频率(音调)调制.

3) You can get exponential frequency (pitch) modulation using the optimized PowerOfTwo unit.

http://www.softsynth.com/jsyn/docs/javadocs/com/jsyn/unitgen/PowerOfTwo.html

将LFO连接到PowerOfTwo单元.然后使用乘"单位缩放中心频率.从+1.0到-1.0的LFO会将频率向上和向下扩展八度.

Connect the LFO to a PowerOfTwo unit. Then use a Multiply unit to scale the center frequency. An LFO that goes from +1.0 to -1.0 will scale the frequency up and down an octave.

4)本教程使用旧的JSyn API.我需要更新它.请注意,在新的JSyn API中,您几乎不需要添加单元,因为输入端口会自动对所有连接的输入求和.

4) The tutorial uses the old JSyn API. I need to update it. Note that in the new JSyn API you rarely need an Add unit because the input ports will automatically sum any connected inputs.

5)StackOverflow很棒,但是您可以通过注册JSyn邮件列表来获得600多个人的JSyn社区的支持.

5) StackOverflow is great but you can get support from the JSyn community of over 600 people by signing up for the JSyn mail list.

http://www.softsynth.com/jsyn/support/index.php

这篇关于JSyn,通过另一个振荡器和一个常数馈入/控制/输入到/菊花链式连接的振荡器发出警报声,并产生多个声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆