joachim
(joachim heintz)
December 21, 2023, 9:21am
1
hi all -
i am working on some examples for javascript csound GUI (in particular in Csound for Android).
i have some issues to show a csound control channel continuously in the html GUI.
this is my csound instrument:
kTest = randomh:k(0,100,1,3)
chnset(kTest,"bla")
i tried this as html body:
<script>
function displayChn() {
document.getElementById("display").innerHTML = csound.getControlChannel("bla");
}
</script>
<button onclick='displayChn()'>Get Value!</button>
<p id="display"></p>
when i click on the button, i get this output:
[object Promise]
i tried this code instead which is adapted from steven's and hlodver's tutorial (Tutorial 2 - Interacting with Csound | WebAudio Csound ):
<script>
const blaReader = () => {
csound.getControlChannel('bla').then(v => {
document.getElementById("display").innerHTML = v;
})
setTimeout(blaReader, 1000 / 10)
}
blaReader();
</script>
<p id="display"></p>
unfortunately, i do not get an output here at all.
thanks for any hints or examples -
joachim
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here
ST_Music
(ST Music)
December 22, 2023, 7:57am
2
Hi Joaquim. HTML/js are not my strong suit so excuse the crude formatting & display.
This works fine for me in Csound for Android ver 39, so I’m not sure why you might be experiencing issues:
-odac
sr = 48000
ksmps = 32
nchnls = 1
0dbfs = 1
instr 1
kTest = randomh:k(0,100,1,3)
chnset(kTest,“bla”)
endin
i1 0 z
Get Value!
See attached as well.
Best,
Scott
html_test.csd (499 Bytes)
joachim
(joachim heintz)
December 22, 2023, 8:16am
3
hi scott -
thanks for you feedback! i am looking for a CONTINUOUS output of a csound control channel in an html element. but in your code, i need to click on the button, right?
last night i found a solution in javascript's setInterval method:
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
i have to figure out how to use this properly but i guess this is what can be used to show control signals say ten times a second in the user interface.
cheers -
joachim
ST_Music
(ST Music)
December 22, 2023, 9:30am
4
Ok, now I get it, sorry for the confusion. Yes, setInterval works fine and is quite straightforward.
setInterval(displayChn, 100)
function displayChn() {
document.getElementById(“display”).innerHTML =
csound.getControlChannel(“bla”);
}
Handy! Thanks for the tip, nice alternative to the console print method.
Best,
Scott