Benvenuto, Visitatore. Per favore, effettua il login o registrati.

  Hai perso la tua email di attivazione?

Main Home Help Ricerca Login Registrati

+  Virtual Sound - FORUM
|-+  Linguaggi per Computer Music, Video e Grafica
| |-+  Csound
| | |-+  dove sbaglio?
« precedente successivo »
Pagine: [1] Stampa
Autore Topic: dove sbaglio?  (Letto 539 volte)
leonardo
Newbie
*
Posts: 11


Guarda Profilo
« il: Febbraio 11, 2012, 17:26:19 »

Salve a tutti,
vi chiedo di darmi gentilmente ancora un aiuto.
L'orchestra che vi posto utilizza due strumenti banali:
il primo genera rumore bianco, il secondo lo filtra.
Sono comandati da due FLbutton.
Se faccio partire prima il rumore bianco e poi lo filtro funziona tutto, ma se li faccio ripartire non funziona più niente. Mi viene segnalato un problema di reinizializzazione che non sò risolvere.
Vi ringrazio anticipatamente per l'aiuto.

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

      FLpanel   "rumore e filtro",  350,    70,    0,  0

;SWITCHES                                                     ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | DUR   
gkOnOff,gihOnOff      FLbutton   "On/Off",      1,   0,     2,    150,     30,    0,  0,    0,      1,      0,      3600
gkOnOff1,gihOnOff1      FLbutton   "On/Offfiltro",      1,   0,     2,    150,     30,  155,  0,    0,      2,      0,      3600

            ;FLsetVal_i   0,       gihOnOff
            ;FLsetVal_i   0,       gihOnOff1
FLpanel_end   
FLrun

opcode genrum, a,i                       ; GENERA IL RUMORE BIANCO
ifreq  xin
anois   rand ifreq
xout   anois
endop

opcode filtropassabanda, a,akk   ; FILTRO PASSABANDA
asig, kfc, kbw   xin
ares   areson   asig, kfc, kbw
xout   ares
endop
   
   instr 1


 key = ( gkOnOff = 1 && gkOnOff1 = 0 ? 1 : 0 )

if   key ==1   then
arand   genrum   2000
   out arand

elseif key == 0  then
garand   genrum   2000

endif
   endin


   instr 2

key = ( gkOnOff = 1 && gkOnOff1 = 1 ? 1 : 0)

if   key != 1   then
turnoff   
      
elseif   key == 1 then
kft = 200
kres = 2
aout   filtropassabanda   garand,kft,kres
a1 balance aout, garand
   out a1
endif
   endin

</CsInstruments>


<CsScore>
f 3600
e
</CsScore>


</CsoundSynthesizer>

Loggato
vallste
Jr. Member
**
Posts: 76


Guarda Profilo WWW
« Risposta #1 il: Febbraio 13, 2012, 09:13:08 »

Ho cambiato instr 1 e instr 2 così:

instr 1
if gkOnOff == 0 then
   turnoff
endif
if gkOnOff1 == 0 then
   arand   genrum   2000
   out arand
elseif gkOnOff1 == 1 then
   garand   genrum   2000
endif
endin

instr 2
if gkOnOff1 == 0 then
   turnoff
endif
kft = 200
kres = 2
aout   filtropassabanda   garand,kft,kres
a1 balance aout, garand
out a1
garand = 0
endin

Ho semplificato un pò il codice e sembra funzionare.

Se vuoi fare in modo che il filtro si attivi solo se è attivato il pulsante del rumore bianco nel codice di qui sopra puoi cambiare instr 2 così:

instr 2
kButtonChange changed gkOnOff + gkOnOff1
if gkOnOff1 == 0 || gkOnOff == 0 then
   FLsetVal kButtonChange, 0, gihOnOff1
   turnoff
endif
kft = 200
kres = 2
aout   filtropassabanda   garand,kft,kres
a1 balance aout, garand
out a1
garand = 0
endin

Molto probabilmente c'è un modo più elegante per farlo...
Loggato
Pagine: [1] Stampa 
« precedente successivo »
Salta a:  


Login con username, password e lunghezza della sessione

Powered by MySQL Powered by PHP © Copyright 1996 - 2008 - ConTempoNet Edizioni Musicali ® - P.IVA: 05174251008
Tutti i diritti riservati - Tutti i marchi sono registrati -
È vietata la riproduzione, anche parziale, dei testi e delle immagini.
Powered by SMF 1.1.15 | SMF © 2006-2008, Simple Machines
Traduzione Italiana a cura di SMItalia
XHTML 1.0 Valido! CSS Valido!