Csound Csound-dev Csound-tekno Search About

[Csnd] Harmonics generation and buffer underrun.

Date2012-09-05 17:18
FromDima 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>
 

Date2012-09-05 17:58
FromAdam Puckett
SubjectRe: [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  wrote:
> 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.
>
> 
> 
> 
> 
>
> 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
>
>
> 
> 
> f 1 0 1024 10 1
> i 1 0 1 440
> i 1 + 1 550
> i 1 + 12 660
> e
> 
> 
>  
>  
>  0
>  0
>  283
>  376
>  true
>  
>  
>   231
>   46
>   255
>  
>  
>   kfreq_mult_coof
>   73
>   67
>   20
>   256
>   {80ee8b63-c218-45d4-b6f3-ec62b6cd2474}
>   true
>   0
>   0
>   1.00000000
>   1.10000000
>   1.09296875
>   lin
>   continuous
>   -1.00000000
>   false
>  
>  
>   kdiv_amp_coof
>   241
>   68
>   20
>   256
>   {25e40fbc-473f-405b-a9a4-b516e6a033c3}
>   true
>   0
>   0
>   1.01000000
>   2.00000000
>   1.10281250
>   lin
>   continuous
>   -1.00000000
>   false
>  
>  
>   
>   7
>   14
>   115
>   30
>   {ac4e9fa1-461d-43de-bfa7-106adecdddf4}
>   true
>   0
>   0
>   
>   left
>   Arial
>   16
>   3
>   
>    0
>    0
>    0
>   
>   
>    192
>    255
>    192
>   
>   border
>   1
>   1
>  
>  
>   
>   164
>   17
>   115
>   26
>   {18bdc664-e424-4b3b-b190-a12cbc7af701}
>   true
>   0
>   0
>   
>   left
>   Arial
>   16
>   3
>   
>    0
>    0
>    0
>   
>   
>    255
>    192
>    192
>   
>   border
>   1
>   1
>  
>  
>   kfreq_mult_coof
>   54
>   351
>   80
>   25
>   {34f07aea-8305-4a1d-b384-45fcbf697e20}
>   true
>   0
>   0
>   left
>   Arial
>   16
>   
>    0
>    0
>    0
>   
>   
>    192
>    255
>    192
>   
>   1.09296875
>   0.00100000
>   -999999999999.00000000
>   999999999999.00000000
>   border
>   1
>   1
>   false
>   
>  
>  
>   kdiv_amp_coof
>   232
>   334
>   51
>   28
>   {7d97ecaa-8475-4da8-b43b-c00afcfd821f}
>   true
>   0
>   0
>   left
>   Arial
>   16
>   
>    0
>    0
>    0
>   
>   
>    255
>    192
>    192
>   
>   1.10281250
>   0.00100000
>   -999999999999.00000000
>   999999999999.00000000
>   border
>   1
>   1
>   false
>   
>  
> 
> 
> 
> 
> Version: 3
> Render: Real
> Ask: Yes
> Functions: ioObject
> Listing: Window
> WindowBounds: 780 57 98 28
> CurrentView: io
> IOViewEdit: On
> Options:
> 
>
> 
> 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
> 
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
>


Date2012-09-05 18:01
FromJustin Smith
SubjectRe: [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  wrote:
> 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  wrote:
>> 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.
>>
>> 
>> 
>> 
>> 
>>
>> 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
>>
>>
>> 
>> 
>> f 1 0 1024 10 1
>> i 1 0 1 440
>> i 1 + 1 550
>> i 1 + 12 660
>> e
>> 
>> 
>>  
>>  
>>  0
>>  0
>>  283
>>  376
>>  true
>>  
>>  
>>   231
>>   46
>>   255
>>  
>>  
>>   kfreq_mult_coof
>>   73
>>   67
>>   20
>>   256
>>   {80ee8b63-c218-45d4-b6f3-ec62b6cd2474}
>>   true
>>   0
>>   0
>>   1.00000000
>>   1.10000000
>>   1.09296875
>>   lin
>>   continuous
>>   -1.00000000
>>   false
>>  
>>  
>>   kdiv_amp_coof
>>   241
>>   68
>>   20
>>   256
>>   {25e40fbc-473f-405b-a9a4-b516e6a033c3}
>>   true
>>   0
>>   0
>>   1.01000000
>>   2.00000000
>>   1.10281250
>>   lin
>>   continuous
>>   -1.00000000
>>   false
>>  
>>  
>>   
>>   7
>>   14
>>   115
>>   30
>>   {ac4e9fa1-461d-43de-bfa7-106adecdddf4}
>>   true
>>   0
>>   0
>>   
>>   left
>>   Arial
>>   16
>>   3
>>   
>>    0
>>    0
>>    0
>>   
>>   
>>    192
>>    255
>>    192
>>   
>>   border
>>   1
>>   1
>>  
>>  
>>   
>>   164
>>   17
>>   115
>>   26
>>   {18bdc664-e424-4b3b-b190-a12cbc7af701}
>>   true
>>   0
>>   0
>>   
>>   left
>>   Arial
>>   16
>>   3
>>   
>>    0
>>    0
>>    0
>>   
>>   
>>    255
>>    192
>>    192
>>   
>>   border
>>   1
>>   1
>>  
>>  
>>   kfreq_mult_coof
>>   54
>>   351
>>   80
>>   25
>>   {34f07aea-8305-4a1d-b384-45fcbf697e20}
>>   true
>>   0
>>   0
>>   left
>>   Arial
>>   16
>>   
>>    0
>>    0
>>    0
>>   
>>   
>>    192
>>    255
>>    192
>>   
>>   1.09296875
>>   0.00100000
>>   -999999999999.00000000
>>   999999999999.00000000
>>   border
>>   1
>>   1
>>   false
>>   
>>  
>>  
>>   kdiv_amp_coof
>>   232
>>   334
>>   51
>>   28
>>   {7d97ecaa-8475-4da8-b43b-c00afcfd821f}
>>   true
>>   0
>>   0
>>   left
>>   Arial
>>   16
>>   
>>    0
>>    0
>>    0
>>   
>>   
>>    255
>>    192
>>    192
>>   
>>   1.10281250
>>   0.00100000
>>   -999999999999.00000000
>>   999999999999.00000000
>>   border
>>   1
>>   1
>>   false
>>   
>>  
>> 
>> 
>> 
>> 
>> Version: 3
>> Render: Real
>> Ask: Yes
>> Functions: ioObject
>> Listing: Window
>> WindowBounds: 780 57 98 28
>> CurrentView: io
>> IOViewEdit: On
>> Options:
>> 
>>
>> 
>> 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
>> 
>>
>> Send bugs reports to the Sourceforge bug tracker
>>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>