---
# System prepended metadata

title: 開發進度(week 3)
tags: [JUCE]

---

# 開發進度(week 3)
###### tags: `JUCE`
* Student : P76101152朱俊霖
* JUCE環境設定
![](https://i.imgur.com/V3GtKd1.png)
* 簡單run JUCE視窗介面
![](https://i.imgur.com/hcqvQTQ.png)
* 控制波形
  * PluginProcessor.cpp(processBlock) → SynthVoice.cpp(renderNextBlock)
  * Sine波
```cpp=
void SynthVoice::renderNextBlock (juce::AudioBuffer <float> &outputBuffer, int startSample, int numSamples)
{
    if (tailOff > 0.0)
    {
        for (int i = startSample; i < (startSample + numSamples); i++)
        {
            float value = std::sin(currentAngle) * level * tailOff;
            outputBuffer.addSample(0, i, value);
            outputBuffer.addSample(1, i, value);
            
            currentAngle += angleIncrement;
            tailOff *= 0.99;
            
            if (tailOff <= 0.05)
            {
                clearCurrentNote();
                angleIncrement = 0.0;
                level = 0.0;
                break;
            }
        }

    }
    else
    {
        for (int i = startSample; i < (startSample + numSamples); i++)
        {
            float value = std::sin(currentAngle) * level;
            outputBuffer.addSample(0, i, value);
            outputBuffer.addSample(1, i, value);
            
            currentAngle += angleIncrement;
        }
    }
}
```
  * 三角波 : 將sin()改成arcsin(sin)即可
  * 方波 : 使用正弦函數定義法，當sin為正，value=1;當sin為負，value=-1
  * 鋸齒波 : 將sin()改為arctan(tan)即可




