New Csound User - Trying to use different instruments - Help Needed
Date | 2017-07-10 23:30 |
From | Dan Farr-Smith |
Subject | New Csound User - Trying to use different instruments - Help Needed |
Hi,
This is my first post to the forum, I'm very new to Csound. I'm doing a
University project to sonify data in an Excel table so that visually
impaired people can listen to the sound of the values in the table.
I would like to use 3 different instruments to represent:
1, numerical values
2, blank values
3, string values
For the numerical values I'm interpolating the frequency between 41 and
100Hz based on the minimum and maximum values in the range.
I'm having difficulty in getting the different instruments to play at the
correct time. I thought instrument 2 would play when i2 is stated in the
CsScore and instrument 3 would play for i3. Unfortunately, this is not
what's happening. The instruments are not playing when I thought they would.
I believe it's something to do with the setting up of the instruments, as I
simply expanded my code from one that worked for a single instrument.
By the way, I'm use a shell command to execute the csound.exe and .csd.
If someone could help me out, it'd be much appreciated.
Thanks,
Dan
Code:
<CsoundSynthesizer>
<CsOptions>
-Q0 -o dac --midioutfile=C:\Sonification\midiout.mid dm6
</CsOptions>
<CsInstruments>
sr=44100
kr=4410
ksmps = 10
nchnls = 1
instr 1
ichn = 1 ; channel
midiout 192, 1, 1, 1
outic ichn,10,p7, 0 , 8
noteondur2 ichn, p4, p5, p3
endin
instr 2
ichn = 2 ; channel
midiout 192, 2, 125, 1
outic ichn,10,p7, 0 , 8
noteondur2 ichn, p4, p5, p3
endin
instr 3
ichn = 3 ; channel
midiout 192, 3, 110, 1
outic ichn,10,p7, 0 , 8
noteondur2 ichn, p4, p5, p3
endin
</CsInstruments>
<CsScore>
;P1 P2 P3 P4 P5 P6 P7 ; Original Value
i1 0 0.5 93.36 127 1 1 ; 81
i1 0.75 0.5 97.05 127 1 2 ; 86
i2 1.5 0.5 127 127 1 3 ; blank
i1 2.25 0.5 66.81 127 1 4 ; 45
i3 3 0.5 70 127 1 5 ; text
i3 3.75 0.5 70 127 1 6 ; text
i1 4.5 0.5 41 127 1 7 ; 10
i1 5.25 0.5 100 127 1 8 ; 90
e
</CsScore>
</CsoundSynthesizer>
|
Date | 2017-07-11 04:41 |
From | Forrest Curo |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
Um, what's generating sounds from the midi signals? Every 3/4 second this is sending out a message to change the 'patch' being used by some midi instrument. Then the note to be played at that setting is sent, to run for 1/2 a second... ? On Mon, Jul 10, 2017 at 3:30 PM, Dan Farr-Smith <danf_21@hotmail.com> wrote:
|
Date | 2017-07-12 00:38 |
From | danf_21 |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
Hi Forrest, Thanks for replying. As some background to my issue, this is part of a University project. I'm building an application for Visually Impaired people to help them navigate Microsoft Excel spreadsheets. One of the functions is to "sonify" a range of data. This will help the user to understand if any patterns exist in the data or there exists text / blank values. An Excel macro parses the data range, creates the .csd file and performs a shell command to CSound.exe. The data range used in this example is as follows: 81 86 *blank* 45 text text 10 90 I would like a note to be played every 3/4 second to run for 1/2 second. The value for the numerical values is scaled based on the minimum / maximum of the range. I'm use a base min of 41 and a base max of 100. So in this example the value of 81 produces 93.36 (41 * (90 - 81) + 100 * (81 - 10)) / (90 - 10). My hope is to play a different instrument for numerical values, another for blanks and a third for text. Unfortunately, when I execute the .csd file. The instruments don't play when I would hope them to. It sounds as though the bagpipe (instrument 110) plays for the 6th element only, whereas I'm trying to get it to play for both the 5th and 6th, as these are both text values. There's obviously be something wrong with my code. I sourced the code my University tutor based on a single instrument. I then tried to enhance it to 3 instruments. Unfortunately, it's not producing the desired effect. Can you please advise how I should change my code in order for it to play the correct instrument based on the example range? Thanks very much, Dan -- View this message in context: http://csound.1045644.n5.nabble.com/Csnd-New-Csound-User-Trying-to-use-different-instruments-Help-Needed-tp5757127p5757131.html Sent from the Csound - General mailing list archive at Nabble.com. 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 |
Date | 2017-07-12 02:05 |
From | Forrest Curo |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
Eliminate the midi signals and use these opcodes:
to let csound produce the sounds of any soundfont directly; then you don't need to worry about when your program change is being acted upon because (for one thing) you shouldn't need to send program changes; each csound instrument would use whichever particular soundfont patch you'd given it initially, every time. Just to run fluidEngine and fluidLoad for a start. Um, some of what I was using: ---------
label: ; Here you'd want to use fluidProgramSelect to assign a definite preset to each ; channel and later, each instrument would be using fluidNote with the 2nd ; argument ('ichannelnum') set to produce sound from whichever preset ; you'd already assigned to that channel.
[Feel free to ask for clarification as needed; this stuff is hard to get used to at first!] The above sets it up so that (say) any subsequent instrument with a line like fluidNote giengine, 1, ikey, ivel On Tue, Jul 11, 2017 at 4:38 PM, danf_21 <danf_21@hotmail.com> wrote: Hi Forrest, |
Date | 2017-07-12 02:21 |
From | Steven Yi |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
I just ran the CSD here on Windows 10 and it produced a sound every 0.75 seconds using the built-in Microsoft MIDI synth. On Mon, Jul 10, 2017 at 6:30 PM, Dan Farr-Smith |
Date | 2017-07-12 02:24 |
From | Forrest Curo |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
Was it using the sound the guy wanted for each csound instrument? (& hadn't he just as well stop resetting the sounds every time he calls an instrument?) On Tue, Jul 11, 2017 at 6:21 PM, Steven Yi <stevenyi@gmail.com> wrote: I just ran the CSD here on Windows 10 and it produced a sound every |
Date | 2017-07-12 02:31 |
From | Steven Yi |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
I don't remember the GM MIDI instrument numbers but it played 3 different timbres to my ear. On Tue, Jul 11, 2017 at 9:24 PM, Forrest Curo |
Date | 2017-07-12 04:07 |
From | Forrest Curo |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
What was bothering him was that the 5th & 6th lines below were supposed to be the same timbre, but weren't: i1 0 0.5 93.36 127 1 1 ; 81
i1 0.75 0.5 97.05 127 1 2 ; 86
i2 1.5 0.5 127 127 1 3 ; blank
i1 2.25 0.5 66.81 127 1 4 ; 45
i3 3 0.5 70 127 1 5 ; text <--------------- i3
i3 3.75 0.5 70 127 1 6 ; text <-------- also i3
i1 4.5 0.5 41 127 1 7 ; 10
i1 5.25 0.5 100 127 1 8 ; 90 (?) On Tue, Jul 11, 2017 at 6:31 PM, Steven Yi <stevenyi@gmail.com> wrote: I don't remember the GM MIDI instrument numbers but it played 3 |
Date | 2017-07-12 05:16 |
From | Steven Yi |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
I looked into it further and I'm also not getting i3 until the 2nd one. The problem is related to the code but it's deceptive. The issue is that midiout runs at perf-time, outic at init-time, and noteondur2 turns the note on at init-time and detects for note-off during perf-time. Because of the order of operations, the noteondur2 will send it's note-on during init time, but the program change message from midiout happens afterwards at perf-time. This explains why note 5 (the first i3) does not sound as a bagpipe, but the second one does, since the second one runs the note on the channel with the program change already in effect from the previous note. Looking through code I did not see any opcodes that function like midiout at init-time. A workaround: create an instrument that does the program changes and run it at the start of the project (duration could be 0.01, or code within the instrument could turn the instrument off after running once at perf-time). Then, offset the generated notes start at 0.01 instead of starting from zero. For users/developers: should we add a midiouti opcode that runs only at init-time? On Tue, Jul 11, 2017 at 11:07 PM, Forrest Curo |
Date | 2017-07-12 05:43 |
From | Forrest Curo |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
Could just generate the general midi sounds directly in csound via the fluid opcodes? (I know there are many ways to do things, but it seems like a much simpler approach.) On Tue, Jul 11, 2017 at 9:16 PM, Steven Yi <stevenyi@gmail.com> wrote: I looked into it further and I'm also not getting i3 until the 2nd |
Date | 2017-07-12 16:26 |
From | Steven Yi |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
That's possible but fluid introduces a bit of load time for the SF2. If that's okay for the requirements, then it's a fine solution. But the midiout issues should still be sorted out, IMO. On Wed, Jul 12, 2017 at 12:43 AM, Forrest Curo |
Date | 2017-07-13 02:28 |
From | danf_21 |
Subject | Re: New Csound User - Trying to use different instruments - Help Needed |
Hi Steven & Forrest, Thanks for all your help, it's been very informative. I've implemented the workaround that Steven suggested and the instruments play at the expected time. Thanks again. For reference, my updated code is below: |