Csound Csound-dev Csound-tekno Search About

Re: [Csnd] array question (fwd)

Date2014-01-01 12:10
Fromjpff
SubjectRe: [Csnd] array question (fwd)
Never could get the hang of non-emacs mailers.  This should have gone to 
the list.  Hope the information is right!

---------- Forwarded message ----------
Date: Wed, 1 Jan 2014 12:08:40 +0000 (GMT)
From: jpff 
To: Forrest Cahoon 
Subject: Re: [Csnd] array question

Try

iScale[] = giStdScale


Date2014-01-01 21:18
FromForrest Cahoon
SubjectRe: [Csnd] array question (fwd)
I guessed that, but I got another error when my opcode is called:

SECTION 1:
new alloc for instr 901:
null opadr
Early return from csoundPerform().
inactive allocs returned to freespace
end of score.           overall amps:  0.00000  0.00000
       overall samples out of range:        0        0
1 errors in performance



On Wed, Jan 1, 2014 at 6:10 AM, jpff <jpff@codemist.co.uk> wrote:
Never could get the hang of non-emacs mailers.  This should have gone to the list.  Hope the information is right!

---------- Forwarded message ----------
Date: Wed, 1 Jan 2014 12:08:40 +0000 (GMT)
From: jpff <jpff@codemist.co.uk>
To: Forrest Cahoon <forrest.cahoon@gmail.com>
Subject: Re: [Csnd] array question

Try


iScale[] = giStdScale



Send bugs reports to the Sourceforge bug trackers
csound6:
           https://sourceforge.net/p/csound/tickets/
csound5:
           https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




Date2014-01-01 21:31
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Re:
AttachmentsNone  

Date2014-01-01 21:31
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Re:
AttachmentsNone  

Date2014-01-01 23:22
FromForrest Cahoon
Subject[Csnd] Re:
I hope I'm not leaving too much cruft in here. In this version I have two opcodes, getFreqBroken and getFreqWorks. When I try to use getFreqBroken, I get the "null opadr" error. When I comment out the call to getFreqBroken and uncomment the call to getFreqWorks, it runs correctly.


<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   No messages  MIDI in
-odac -Ma -d -+rtmidi=portmidi
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 24
nchnls = 2
0dbfs = 1

giEWIChannel = 1 ; MIDI channel for EWI controller

giSine ftgen 0, 0, 2^14, 10, 1
giStdScale[] array 1, 16/15, 9/8, 6/5, 5/4, 4/3, 45/32,  3/2,  8/5,  5/3, 16/9,  15/8
giAltScale[] array 1, 15/14, 8/7, 7/6, 9/7, 7/5, 64/45, 10/7, 14/9, 12/7,  7/4, 28/15

giBaseFreq = 8

;;  MIDI continuous controller globals
gkAftertouch init 0
gkPitchBend init 0
gkPortamentoTime init 0   ; controller 5
gkPlateUp init 0          ; controller 48
gkPlateDown init 0        ; controller 49
gkHoldKey init 0          ; controller 64
gkPortamentoSwitch init 0 ; controller 65
gkOctaveKey init 0        ; controller 69

;;  MIDI note parameters
gkNoteNumber init 0
gkNoteVelocity init 0

massign giEWIChannel, 0

;;  Smooth controller changes, but always
; ; return immediately to zero
opcode port0, k, k
iPortHalfTime = 0.01
kPortHalfTimeZero linseg iPortHalfTime, iPortHalfTime, 0, iPortHalfTime, 0
kIn xin
    kOut portk kIn, kPortHalfTimeZero, -1
xout kOut
endop

opcode getFreqBroken, k, kk
kNoteNumber, kHoldKey xin
kOctave = floor(kNoteNumber/12)
kStep = kNoteNumber - (kOctave * 12)
if kHoldKey > 0 then
    iScale[] = giAltScale
else
    iScale[] = giStdScale
endif
kFreq = giBaseFreq * (2^kOctave) * iScale[kStep]
xout kFreq
endop

opcode getFreqWorks, k, kk
kNoteNumber, kHoldKey xin
kOctave = floor(kNoteNumber/12)
kStep = kNoteNumber - (kOctave * 12)
if kHoldKey > 0 then
     kFreq = giBaseFreq * (2^kOctave) * giAltScale[kStep]
else
    kFreq = giBaseFreq * (2^kOctave) * giStdScale[kStep]
endif
xout kFreq
endop


instr 901

midi_read_loop:
kstatus, kchan, kdata1, kdata2 midiin
if kchan != giEWIChannel kgoto midi_read_loop
if kstatus == 144 && kdata2 > 0 then ; note on
    gkNoteNumber = kdata1
    gkNoteVelocity = kdata2
elseif kstatus == 176 then ; control change
    kCtrlVal = kdata2/127 ; normalize control value to [0,1]
    if kdata1 == 5 then
        gkPortamentoTime port0 kCtrlVal
    elseif kdata1 == 48 then
        gkPlateUp port0 kCtrlVal
    elseif kdata1 == 49 then
        gkPlateDown port0 kCtrlVal
    elseif kdata1 == 64 then
        gkHoldKey = (kCtrlVal <= 0.5 ? 0 : 1)
    elseif kdata1 == 65 then
        gkPortamentoSwitch = (kCtrlVal <= 0.5 ? 0 : 1)
    elseif kdata1 == 69 then
        gkOctaveKey = (kCtrlVal <= 0.5 ? 0 : 1)
    endif
elseif kstatus = 208 then ; aftertouch
    kCtrlVal = kdata1/127
    gkAftertouch port0 kCtrlVal
elseif kstatus = 224 then ; pitch bend
    kCtrlVal = (127*kdata2 + kdata1 - 8192)/8192 ; normalized to [-1:1)
    gkPitchBend port0 kCtrlVal
endif
if kstatus != 0 kgoto midi_read_loop

printks "af=%5.3f pb=%6.3f nn=%2d pt=%5.3f pu=%5.3f pd=%5.3f hk=%d ps=%d ok=%d\n", 0.5,\
        gkAftertouch, gkPitchBend, gkNoteNumber, gkPortamentoTime, gkPlateUp, gkPlateDown, \
        gkHoldKey, gkPortamentoSwitch, gkOctaveKey

kFreq getFreqBroken gkNoteNumber, gkHoldKey
;kFreq getFreqWorks gkNoteNumber, gkHoldKey

aOut foscil 0dbfs * 0.9 * gkAftertouch, kFreq, \
            1 - 0.05*gkPlateUp, 1 - 0.05*gkPlateDown, 5.0 * (1 - (1 - gkAftertouch)^2) + 2.0 * gkPitchBend, giSine

outs aOut, aOut

endin

</CsInstruments>
<CsScore>
i901 0 3600

e 3600
</CsScore>
</CsoundSynthesizer>



On Wed, Jan 1, 2014 at 3:31 PM, <jpff@cs.bath.ac.uk> wrote:
null opadr means that somehow you called an opcode which does not exist in the format called, such as wrong rate.  Yes the message should be better but it means it tried to obey a function that was null.

To get further I need the orchestra

==John ff

Quoting Forrest Cahoon <forrest.cahoon@gmail.com>:

I guessed that, but I got another error when my opcode is called:

SECTION 1:
new alloc for instr 901:
null opadr
Early return from csoundPerform().
inactive allocs returned to freespace
end of score.           overall amps:  0.00000  0.00000
       overall samples out of range:        0        0
1 errors in performance



On Wed, Jan 1, 2014 at 6:10 AM, jpff <jpff@codemist.co.uk> wrote:

Never could get the hang of non-emacs mailers.  This should have gone to
the list.  Hope the information is right!

---------- Forwarded message ----------
Date: Wed, 1 Jan 2014 12:08:40 +0000 (GMT)
From: jpff <jpff@codemist.co.uk>
To: Forrest Cahoon <forrest.cahoon@gmail.com>
Subject: Re: [Csnd] array question

Try


iScale[] = giStdScale



Send bugs reports to the Sourceforge bug trackers
csound6:
           https://sourceforge.net/p/csound/tickets/
csound5:
           https://sourceforge.net/p/csound/bugs/
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 trackers
csound6:
            https://sourceforge.net/p/csound/tickets/
csound5:
            https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"