Csound Csound-dev Csound-tekno Search About

what is wrong here?

Date2016-07-13 18:48
Fromjoachim heintz
Subjectwhat is wrong here?
hi all -

i cannot understand something which i thought is easy.  i want to change 
a global variable for volume from 1 to 0 or vice versa, whenever i 
trigger an instrument.  but the change should perform as a line in the 
duration of the instrument:





ksmps = 32

   instr Master
gkVol init 1
printk .5, gkVol
   endin

   instr MuteUnmute
iStart = i(gkVol)
iEnd = (iStart == 0 ? 1 : 0)
print iStart, iEnd
gkVol linseg iStart, p3, iEnd
   endin



i "Master" 0 5
i "MuteUnmute" 1 .1
i "MuteUnmute" 2 .1
i "MuteUnmute" 3 .1
i "MuteUnmute" 4 .1



i expected to get gkVol down to zero after the first call of MuteUnmute, 
then back to 1 after the second call, and so on.  but i get:

new alloc for instr Master:
  i   1 time     0.00073:     1.00000
  i   1 time     0.25034:     1.00000
  i   1 time     0.75029:     1.00000
B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
new alloc for instr MuteUnmute:
instr 2:  iStart = 1.000  iEnd = 0.000
  i   1 time     1.25025:     0.00725
  i   1 time     1.75020:     0.00725
B  1.000 ..  2.000 T  2.000 TT  2.000 M:      0.0
instr 2:  iStart = 0.007  iEnd = 0.000
  i   1 time     2.25016:     0.00005
  i   1 time     2.75011:     0.00005
B  2.000 ..  3.000 T  3.000 TT  3.000 M:      0.0
instr 2:  iStart = 0.000  iEnd = 0.000
  i   1 time     3.25007:     0.00000
  i   1 time     3.75002:     0.00000
B  3.000 ..  4.000 T  4.000 TT  4.000 M:      0.0
instr 2:  iStart = 0.000  iEnd = 0.000
B  4.000 ..  4.100 T  4.100 TT  4.100 M:      0.0
  i   1 time     4.25070:     0.00000
  i   1 time     4.75066:     0.00000
B  4.100 ..  5.000 T  5.000 TT  5.000 M:      0.0

i thought it might be because the line does not reach exactly the zero 
(although it should), so i added some time to p3, but this did not help 
at all.

am i overlooking anything obvious, or is something wrong with linseg?

thanks -
	joachim

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-13 19:06
FromRory Walsh
SubjectRe: what is wrong here?
Looks like line doesn't quite get to its end points. The modified version below works. Is this why there is a linsegb opcode?  

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32

  instr Master
gkVol init 1
printk2 gkVol
  endin

  instr MuteUnmute
iStart = i(gkVol)
iEnd = (iStart == 0 ? 1 : 0)
prints "iStart=%f iEnd=%f\n", iStart, iEnd
gkVol linseg iStart, p3-.01, iEnd, .01, iEnd
  endin

</CsInstruments>
<CsScore>
i "Master" 0 5
i "MuteUnmute" 1 .1
i "MuteUnmute" 2 .1
i "MuteUnmute" 3 .1
i "MuteUnmute" 4 .1
</CsScore>
</CsoundSynthesizer> 

On 13 July 2016 at 18:48, joachim heintz <jh@joachimheintz.de> wrote:
hi all -

i cannot understand something which i thought is easy.  i want to change a global variable for volume from 1 to 0 or vice versa, whenever i trigger an instrument.  but the change should perform as a line in the duration of the instrument:

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32

  instr Master
gkVol init 1
printk .5, gkVol
  endin

  instr MuteUnmute
iStart = i(gkVol)
iEnd = (iStart == 0 ? 1 : 0)
print iStart, iEnd
gkVol linseg iStart, p3, iEnd
  endin

</CsInstruments>
<CsScore>
i "Master" 0 5
i "MuteUnmute" 1 .1
i "MuteUnmute" 2 .1
i "MuteUnmute" 3 .1
i "MuteUnmute" 4 .1
</CsScore>
</CsoundSynthesizer>

i expected to get gkVol down to zero after the first call of MuteUnmute, then back to 1 after the second call, and so on.  but i get:

new alloc for instr Master:
 i   1 time     0.00073:     1.00000
 i   1 time     0.25034:     1.00000
 i   1 time     0.75029:     1.00000
B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
new alloc for instr MuteUnmute:
instr 2:  iStart = 1.000  iEnd = 0.000
 i   1 time     1.25025:     0.00725
 i   1 time     1.75020:     0.00725
B  1.000 ..  2.000 T  2.000 TT  2.000 M:      0.0
instr 2:  iStart = 0.007  iEnd = 0.000
 i   1 time     2.25016:     0.00005
 i   1 time     2.75011:     0.00005
B  2.000 ..  3.000 T  3.000 TT  3.000 M:      0.0
instr 2:  iStart = 0.000  iEnd = 0.000
 i   1 time     3.25007:     0.00000
 i   1 time     3.75002:     0.00000
B  3.000 ..  4.000 T  4.000 TT  4.000 M:      0.0
instr 2:  iStart = 0.000  iEnd = 0.000
B  4.000 ..  4.100 T  4.100 TT  4.100 M:      0.0
 i   1 time     4.25070:     0.00000
 i   1 time     4.75066:     0.00000
B  4.100 ..  5.000 T  5.000 TT  5.000 M:      0.0

i thought it might be because the line does not reach exactly the zero (although it should), so i added some time to p3, but this did not help at all.

am i overlooking anything obvious, or is something wrong with linseg?

thanks -
        joachim

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-07-13 19:20
Fromjoachim heintz
SubjectRe: what is wrong here?
thanks for the quick look and the help, rory.  i see now the also
   gkVol linseg iStart, p3-2/kr, iEnd
works.

in a way i was thinking the wrong way; i tried
   gkVol linseg iStart, p3+2/kr, iEnd
which is of course nonsense because then the line definitely cannot 
reach zero ...

thinking is soo difficult ... =)

	j


On 13/07/16 20:06, Rory Walsh wrote:
> Looks like line doesn't quite get to its end points. The modified
> version below works. Is this why there is a linsegb opcode?
>
> 
> 
> 
> 
> ksmps = 32
>
>    instr Master
> gkVol init 1
> printk2 gkVol
>    endin
>
>    instr MuteUnmute
> iStart = i(gkVol)
> iEnd = (iStart == 0 ? 1 : 0)
> prints "iStart=%f iEnd=%f\n", iStart, iEnd
> gkVol linseg iStart, p3-.01, iEnd, .01, iEnd
>    endin
>
> 
> 
> i "Master" 0 5
> i "MuteUnmute" 1 .1
> i "MuteUnmute" 2 .1
> i "MuteUnmute" 3 .1
> i "MuteUnmute" 4 .1
> 
> 
>
> On 13 July 2016 at 18:48, joachim heintz  > wrote:
>
>     hi all -
>
>     i cannot understand something which i thought is easy.  i want to
>     change a global variable for volume from 1 to 0 or vice versa,
>     whenever i trigger an instrument.  but the change should perform as
>     a line in the duration of the instrument:
>
>     
>     
>     
>     
>     ksmps = 32
>
>        instr Master
>     gkVol init 1
>     printk .5, gkVol
>        endin
>
>        instr MuteUnmute
>     iStart = i(gkVol)
>     iEnd = (iStart == 0 ? 1 : 0)
>     print iStart, iEnd
>     gkVol linseg iStart, p3, iEnd
>        endin
>
>     
>     
>     i "Master" 0 5
>     i "MuteUnmute" 1 .1
>     i "MuteUnmute" 2 .1
>     i "MuteUnmute" 3 .1
>     i "MuteUnmute" 4 .1
>     
>     
>
>     i expected to get gkVol down to zero after the first call of
>     MuteUnmute, then back to 1 after the second call, and so on.  but i get:
>
>     new alloc for instr Master:
>       i   1 time     0.00073:     1.00000
>       i   1 time     0.25034:     1.00000
>       i   1 time     0.75029:     1.00000
>     B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
>     new alloc for instr MuteUnmute:
>     instr 2:  iStart = 1.000  iEnd = 0.000
>       i   1 time     1.25025:     0.00725
>       i   1 time     1.75020:     0.00725
>     B  1.000 ..  2.000 T  2.000 TT  2.000 M:      0.0
>     instr 2:  iStart = 0.007  iEnd = 0.000
>       i   1 time     2.25016:     0.00005
>       i   1 time     2.75011:     0.00005
>     B  2.000 ..  3.000 T  3.000 TT  3.000 M:      0.0
>     instr 2:  iStart = 0.000  iEnd = 0.000
>       i   1 time     3.25007:     0.00000
>       i   1 time     3.75002:     0.00000
>     B  3.000 ..  4.000 T  4.000 TT  4.000 M:      0.0
>     instr 2:  iStart = 0.000  iEnd = 0.000
>     B  4.000 ..  4.100 T  4.100 TT  4.100 M:      0.0
>       i   1 time     4.25070:     0.00000
>       i   1 time     4.75066:     0.00000
>     B  4.100 ..  5.000 T  5.000 TT  5.000 M:      0.0
>
>     i thought it might be because the line does not reach exactly the
>     zero (although it should), so i added some time to p3, but this did
>     not help at all.
>
>     am i overlooking anything obvious, or is something wrong with linseg?
>
>     thanks -
>              joachim
>
>     Csound mailing list
>     Csound@listserv.heanet.ie 
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     Send bugs reports to
>     https://github.com/csound/csound/issues
>     Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-13 20:04
FromRory Walsh
SubjectRe: what is wrong here?
thinking is soo difficult ... =)

Tell me about it. I tried out some thinking in the mid-90s but it put such a drain on my mental resources that I had to give it up...  


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-07-13 20:12
Fromjoachim heintz
SubjectRe: what is wrong here?
=)

On 13/07/16 21:04, Rory Walsh wrote:
>     thinking is soo difficult ... =)
>
>
> Tell me about it. I tried out some thinking in the mid-90s but it put
> such a drain on my mental resources that I had to give it up...
>
>
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-13 20:30
FromAnders Genell
SubjectRe: what is wrong here?
That's why they invented beer. As soon as you feel an urge to think, you imbibe suitable quantities of beer until the urge is diminished or until the active ingredient in the beer has minimized the ability to think. 



13 juli 2016 kl. 21:04 skrev Rory Walsh <rorywalsh@EAR.IE>:

thinking is soo difficult ... =)

Tell me about it. I tried out som e thinking in the mid-90s but it put such a drain on my mental resources that I had to give it up...  


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-07-13 20:35
FromRory Walsh
SubjectRe: what is wrong here?
That's what beer is for?! Oh man, it makes so much sense now...

On 13 July 2016 at 20:30, Anders Genell <anders.genell@gmail.com> wrote:
That's why they invented beer. As soon as you feel an urge to think, you imbibe suitable quantities of beer until the urge is diminished or until the active ingredient in the beer has minimized the ability to think. 



13 juli 2016 kl. 21:04 skrev Rory Walsh <rorywalsh@EAR.IE>:

thinking is soo difficult ... =)

Tell me about it. I tried out some thinking in the mid-90s but it put such a drain on my mental resources that I had to give it up...  


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here