[Csnd] Harmonics generation and buffer underrun.
Date | 2012-09-05 17:18 |
From | Dima Bak |
Subject | [Csnd] Harmonics generation and buffer underrun. |
Hi! I want to generate some harmonics and I get constantly (I try to render it offline and wav file has same jitters): WARNING: Buffer underrun in real-time audio output Here is the .csd for CsoundQt (Ubuntu 12.04 x64 csound 5.17 Qutecsound 0.6.1 Alsa (i try same csd on win7 and the same result)) What is wrong? Thanks. <CsoundSynthesizer> <CsOptions> </CsOptions> <CsInstruments> sr = 44100 kr = 1 ;Важно! nchnls = 2 0dbfs = 1 instr 1 kfreq = p4 kamp = 0.2 kcount = 16 kfreq_mult_coof invalue "kfreq_mult_coof" kdiv_amp_coof invalue "kdiv_amp_coof" aout = 0 add_harmonics: apart oscil kamp,kfreq,1 aout = aout + apart kcount = kcount - 1 kfreq = kfreq * kfreq_mult_coof kamp = kamp / kdiv_amp_coof if (kcount>0) goto add_harmonics outs aout,aout endin </CsInstruments> <CsScore> f 1 0 1024 10 1 i 1 0 1 440 i 1 + 1 550 i 1 + 12 660 e </CsScore> </CsoundSynthesizer><bsbPanel> <label>Widgets</label> <objectName/> <x>0</x> <y>0</y> <width>283</width> <height>376</height> <visible>true</visible> <uuid/> <bgcolor mode="nobackground"> <r>231</r> <g>46</g> <b>255</b> </bgcolor> <bsbObject version="2" type="BSBVSlider"> <objectName>kfreq_mult_coof</objectName> <x>73</x> <y>67</y> <width>20</width> <height>256</height> <uuid>{80ee8b63-c218-45d4-b6f3-ec62b6cd2474}</uuid> <visible>true</visible> <midichan>0</midichan> <midicc>0</midicc> <minimum>1.00000000</minimum> <maximum>1.10000000</maximum> <value>1.09296875</value> <mode>lin</mode> <mouseControl act="jump">continuous</mouseControl> <resolution>-1.00000000</resolution> <randomizable group="0">false</randomizable> </bsbObject> <bsbObject version="2" type="BSBVSlider"> <objectName>kdiv_amp_coof</objectName> <x>241</x> <y>68</y> <width>20</width> <height>256</height> <uuid>{25e40fbc-473f-405b-a9a4-b516e6a033c3}</uuid> <visible>true</visible> <midichan>0</midichan> <midicc>0</midicc> <minimum>1.01000000</minimum> <maximum>2.00000000</maximum> <value>1.10281250</value> <mode>lin</mode> <mouseControl act="jump">continuous</mouseControl> <resolution>-1.00000000</resolution> <randomizable group="0">false</randomizable> </bsbObject> <bsbObject version="2" type="BSBLabel"> <objectName/> <x>7</x> <y>14</y> <width>115</width> <height>30</height> <uuid>{ac4e9fa1-461d-43de-bfa7-106adecdddf4}</uuid> <visible>true</visible> <midichan>0</midichan> <midicc>0</midicc> <label>kfreq_mult_coof</label> <alignment>left</alignment> <font>Arial</font> <fontsize>16</fontsize> <precision>3</precision> <color> <r>0</r> <g>0</g> <b>0</b> </color> <bgcolor mode="background"> <r>192</r> <g>255</g> <b>192</b> </bgcolor> <bordermode>border</bordermode> <borderradius>1</borderradius> <borderwidth>1</borderwidth> </bsbObject> <bsbObject version="2" type="BSBLabel"> <objectName/> <x>164</x> <y>17</y> <width>115</width> <height>26</height> <uuid>{18bdc664-e424-4b3b-b190-a12cbc7af701}</uuid> <visible>true</visible> <midichan>0</midichan> <midicc>0</midicc> <label>kdiv_amp_coof</label> <alignment>left</alignment> <font>Arial</font> <fontsize>16</fontsize> <precision>3</precision> <color> <r>0</r> <g>0</g> <b>0</b> </color> <bgcolor mode="background"> <r>255</r> <g>192</g> <b>192</b> </bgcolor> <bordermode>border</bordermode> <borderradius>1</borderradius> <borderwidth>1</borderwidth> </bsbObject> <bsbObject version="2" type="BSBScrollNumber"> <objectName>kfreq_mult_coof</objectName> <x>54</x> <y>351</y> <width>80</width> <height>25</height> <uuid>{34f07aea-8305-4a1d-b384-45fcbf697e20}</uuid> <visible>true</visible> <midichan>0</midichan> <midicc>0</midicc> <alignment>left</alignment> <font>Arial</font> <fontsize>16</fontsize> <color> <r>0</r> <g>0</g> <b>0</b> </color> <bgcolor mode="background"> <r>192</r> <g>255</g> <b>192</b> </bgcolor> <value>1.09296875</value> <resolution>0.00100000</resolution> <minimum>-999999999999.00000000</minimum> <maximum>999999999999.00000000</maximum> <bordermode>border</bordermode> <borderradius>1</borderradius> <borderwidth>1</borderwidth> <randomizable group="0">false</randomizable> <mouseControl act=""/> </bsbObject> <bsbObject version="2" type="BSBScrollNumber"> <objectName>kdiv_amp_coof</objectName> <x>232</x> <y>334</y> <width>51</width> <height>28</height> <uuid>{7d97ecaa-8475-4da8-b43b-c00afcfd821f}</uuid> <visible>true</visible> <midichan>0</midichan> <midicc>0</midicc> <alignment>left</alignment> <font>Arial</font> <fontsize>16</fontsize> <color> <r>0</r> <g>0</g> <b>0</b> </color> <bgcolor mode="background"> <r>255</r> <g>192</g> <b>192</b> </bgcolor> <value>1.10281250</value> <resolution>0.00100000</resolution> <minimum>-999999999999.00000000</minimum> <maximum>999999999999.00000000</maximum> <bordermode>border</bordermode> <borderradius>1</borderradius> <borderwidth>1</borderwidth> <randomizable group="0">false</randomizable> <mouseControl act=""/> </bsbObject> </bsbPanel> <bsbPresets> </bsbPresets> <MacOptions> Version: 3 Render: Real Ask: Yes Functions: ioObject Listing: Window WindowBounds: 780 57 98 28 CurrentView: io IOViewEdit: On Options: </MacOptions> <MacGUI> ioView nobackground {59367, 11822, 65535} ioSlider {73, 67} {20, 256} 1.000000 1.100000 1.092969 kfreq_mult_coof ioSlider {241, 68} {20, 256} 1.010000 2.000000 1.102812 kdiv_amp_coof ioText {7, 14} {115, 30} label 0.000000 0.00100 "" left "Arial" 16 {0, 0, 0} {49152, 65280, 49152} nobackground noborder kfreq_mult_coof ioText {164, 17} {115, 26} label 0.000000 0.00100 "" left "Arial" 16 {0, 0, 0} {65280, 49152, 49152} nobackground noborder kdiv_amp_coof ioText {54, 351} {80, 25} scroll 1.092969 0.001000 "kfreq_mult_coof" left "Arial" 16 {0, 0, 0} {49152, 65280, 49152} background noborder ioText {232, 334} {51, 28} scroll 1.102812 0.001000 "kdiv_amp_coof" left "Arial" 16 {0, 0, 0} {65280, 49152, 49152} background noborder </MacGUI> |
Date | 2012-09-05 17:58 |
From | Adam Puckett |
Subject | Re: [Csnd] Harmonics generation and buffer underrun. |
From what I can tell your code looks good, but see the harmonic generating example in the FLOSS manual. Also, try setting ksmps to 1 instead of kr. I'm not sure, but that may be what's causing the jitters. BTW, could you translate your comment beside where you set kr to 1 into English? Thanks! Adam On 9/5/12, Dima Bak |
Date | 2012-09-05 18:01 |
From | Justin Smith |
Subject | Re: [Csnd] Harmonics generation and buffer underrun. |
kr of 1 will definitely cause discontinuities (once per second) if any parameters are changing at k rate. Though ksmps of 1 will be even more likely to cause buffer underruns. I would use jack, find a jack setting that is stable, then set ksmps equal to the jack period size to get best RT efficiency. On Wed, Sep 5, 2012 at 9:58 AM, Adam Puckett |