Cabbage Logo
Back to Cabbage Site

Unity 3D music sequencer project - advice on options

okay, i put the print statement around line 60, which means that when a cube is enabled it prints the amplitude/velocity values at each index value. and it reads exactly as my PosIntensity array is set up in my Unity script. if i enable every cube in a line the result reads like my PosIntensity array.

but i still get no sound until i hit index 5 AND row 5 (for testing i’m enabling 0, 5 first). i’m also trying to print p5 value which always comes up as zero no matter what. it compiled so i think it should be right, but here’s the two lines:

printks "amps %d, %d, %d, %d, %d, %d, %d, %d", 0, kNotesAmps[0],kNotesAmps[1],kNotesAmps[2],kNotesAmps[3],kNotesAmps[4],kNotesAmps[5],kNotesAmps[6],kNotesAmps[7]
printks "p5 value: %d",0,p5

there is not an explicit p5 value set beforehand unless the event call is somehow sending it. but i don’t think so. honestly i get so confused on parameter operations. regardless, whether a note plays or not, that p5 print statement always shows 0. so i think although the formatting is right p5 is somehow problematic, or my print statement isn’t calling it quite right.

and just to test, switching the order of operations in Unity on the EnableCubeToPlaySound makes no difference either. i get the same result either way.

The printing of p5 needs to go into the soundfont instrument. It will always be 0 there because that instrument wasn’t started with a p5 parameter. Just add

print p5

to the sf instrument and see what it prints when you have all cubes enabled.

okay, it appears that there’s definitely a lack of amplitude value for the SF2 instrument until the diagonal value is enabled. enabling 0,4 cube p5 comes up as 0.00. enable 4,4 and p5 changes to the assigned value. here’s a few screens:


notice i’ve enabled row 4 (the fifth row) except the fifth position. and the result is that p5 stays at 0.0, but the amp array is clearly showing the desired velocity values for all positions.

so if i enable that fifth position then the whole row plays BUT it only uses the velocity for that fifth position (in this case, 64). so clearly our amp values are NOT being transferred to the instruments for sure, except for diagonal positions. and then once that position is enabled the other dynamic values on those positions are ignored and it only uses that velocity/intensity value for all elements in the row.

so p5 looks like our culprit here - it’s not being updated except in a very strange way. also, at least at first glance it seems like the Unity side of the pipeline is working correctly, it terms of sending the values in the inspector to Csound. but the velocities are not getting to the instruments.

I won’t have a chance to look into this until Monday. I’ve a music festival to attend from tomorrow until then :wink:

no worries - hope you’re enjoying the music!

one thing to add to the aforementioned issues - i transferred the test sequencer project to my Windows laptop and i installed the Windows package for CsoundUnity. running the sequencer scene there it works exactly the same, though the Console seems to tell me that that all amps as well as p5 are at zero. i check the same scene on my Mac and it shows correctly. on the PC i think it’s a slightly newer version of CsoundUnity as well. wondering if this issue is perhaps because i installed the PC package over the mac libraries that were there already.

i’m definitely focused on fixing the p5 velocity issue for sure, though. don’t worry about he Mac/PC issue for now.

I don’t think I have the correct scripts? Or at least I don’t think I have the most recent ones? Can you repackage the project for me? Not much point in spending time looking over old scripts…

okay - here’s the whole shebang as of sept 2. haven’t touched it until now.

i’ve disabled all the rest of the layers except one, and most of the instruments have been set up for p5 velocity. theres a parameter called layer instrument where you can switch between instruments. inst 0, 2 or 3 is a good example of the misbehavior (though note the differences in the CSD script as i tried to set up a velocity and ignore p5 on inst 3) while inst 1 is a sinewave based instrument ignoring velocity which works fine.

Just a few general comments:

instr inst0
	prints "instr0"
	a1 expon .1, p5/100, 0.001
	aOut oscili a1, cpsmidinn(p4)
	outs aOut, aOut
endin

The above instrument doesn’t use p5 to set the amplitude, instead it sets the duration of the envelope. Which may or may not be longer than the note duration…

Regarding the issue you’re having, I’m finding it hard to follow. When I start this project, and I select inst2 to perform everything works as I would expect? If I enable a cube it plays when it’s hit? I thought the problem was some cubes weren’t playing? Looks like I misunderstood?

the main issue on my end (using scene3, the latest) is that i want to be able to both enable a cube AND give it a velocity value that will control its amplitude. if you selected inst2 for the Layer Inst and started the scene playback (you can’t change instruments on the fly once started, only before you start the scene), and then picked a note not directly on a diagonal line from lower left corner to upper right corner (matching vertical row and horizontal position), you will get no sound.

on Inst2 selected in scene3 try selecting the fifth row, first note. nothing should play. if it plays fine that is welcome news and only means my Unity project is somehow wonky. but if you switch to inst3 where the p5/velocity is disabled, everything works fine.

what’s really weird is that IF a note is enabled on a diagonal (say you picked row 4, position 4 (fifth row, fifth position)) than other notes on that row WILL sound. but if you disable that same cube, none of the notes on that row will sound.

i did a screencap for you on this behavior ignoring inst0 and inst1 and concentrating on inst3(with no velocity) and inst2 (with the problem) . hopefully this will clarify:https://www.dropbox.com/s/jmu22bwe5ps1n5t/rorytest.mp4?dl=0

bottom line is i want to be able to do both things. i want to be able to enable and disable a cube AND be able to have each index position for all rows, have a velocity value - basically you can think of it as a vertical column value, governed by the PosIntensity array, so every note in a column gets the same velocity, but each columns velocity can differ. as it is now, even when the p5 instrument plays a note, it just uses one velocity value. it doesn’t seem to vary.

i’m sure its something i’ve mistakenly set up but since i can’t seem to explain it properly and don’t know csound worth much at all, i’m handicapped. and running out of time as well, since i have to have a working version finished in about two weeks. it seems to work fine if i ignore velocity - i was just hoping to do be able to do that to add some musicality.

That video helped, thanks. So from quickly looking through the Csound code I see some strange things. No doubt unintended artifacts of the simpler system we started with. So when you print the info to the console everything look right, i.e.;

	kChanged changed kCubeState, kCubeIndex
	if changed(kChanged) > 0 then
		kNotesAmps[kCubeIndex] = kCubeState
		kNoteValues[kCubeIndex] = kCubeNote
		printks "Updating row %d - index: %d - value: %d - note: %d - inst: %d",0, p4, kCubeIndex,kNotesAmps[kCubeIndex],kNoteValues[kCubeIndex],kInst
	endif

Now if you compare this with the info you are sending to the instruments, it’s no the same:

elseif kInst == 2 then
	event "i", "inst2", 0, kDur, kNoteValues[p4-1]+kOffset,kNotesAmps[p4-1]

In this case you are always sending kNoteAmps[p4-1]. Shouldn’t you be passed kBeat or kCubeIndex or something?

excellent! :smile: that did the trick. i’m not sure why i didn’t see it before. i was stuck in an outmoded thinking pattern. i think i was believing that p4 was the same p4 as defined in the instruments. at any rate, only the parameter in the p5 position conveying velocity needed to change to kBeat. changing both parameters to kBeat resulted in horizontal scales. i wanted each row to play the same note. so by only changing the last one i got what i needed! very happy and grateful.

also solved the velocity issue for inst0 and 1 finally! :sunglasses: the thing that was tripping me up was expon modulating the amp of oscili. i realized finally i could multiply the expon output via p5, once i did some math on it beforehand.

so i now have everything i need. i even figured out controlling a layer’s parameters using the intensity value from another layer - which was a big reason why i wanted an intensity value in the first place.

so thank you immensely for your time and effort here. i’m sure i’ll have other issues, but if you fix the Audio Source panning, that will help make this project be a bit more spatially exciting.

That’s the next thing but it might not be till early next week as I’ve a lot on at work at the moment.

no worries. i’ll have plenty to work on in the meantime. but it’s finally taking some nice shape with the ability of layers to modulate other ones. cheers!