| View previous topic :: View next topic |
| Author |
Message |
US of Anarchy

Joined: 13 Dec 2006 Posts: 41
Digg It |
Posted: Wed Jan 10, 2007 2:15 am Post subject: Using variable names in variable calling |
|
|
Hey. I was wondering if there was a way to use variables to name or call other variables, somewhat like arrays
ex:
if I have
var.a = C
var.b = 5
and I want to play the midi note C5, how do I do that using a and b?
something like this:
midi.[var.a][var.b]
I dunno if this is even possible... |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Wed Jan 10, 2007 7:32 am Post subject: |
|
|
Not possible.
But you can do it the hard way:
| Code: |
var.note = var.b * 12
if var.a ~= "CSharp" then
var.note = var.note+1
elseif var.a ~= "D" then
var.note = var.note+2
elseif var.a ~= "DSharp" then
var.note = var.note+3
elseif var.a ~= "E" then
var.note = var.note+4
elseif var.a ~= "F" then
var.note = var.note+5
elseif var.a ~= "FSharp" then
var.note = var.note+6
elseif var.a ~= "G" then
var.note = var.note+7
elseif var.a ~= "GSharp" then
var.note = var.note+8
elseif var.a ~= "A" then
var.note = var.note+9
elseif var.a ~= "ASharp" then
var.note = var.note+10
elseif var.a ~= "B" then
var.note = var.note+11
end if
midi.firstnote = var.note
|
|
|
| Back to top |
|
 |
togikun

Joined: 03 Jan 2007 Posts: 63
Digg It |
Posted: Wed Jan 10, 2007 8:23 am Post subject: |
|
|
| pretty much the way i did it. Except i hardcoded each note, than added/substracted to reach the tone i wanted (check my midi ocarina script, it's on the forum) |
|
| Back to top |
|
 |
US of Anarchy

Joined: 13 Dec 2006 Posts: 41
Digg It |
Posted: Wed Jan 10, 2007 7:18 pm Post subject: |
|
|
| Yea but firstnote doesn't work for me. It just plays it for a second, then stops. When I set it to -1 it makes a really low bass sound constantly. Any help? |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Wed Jan 10, 2007 8:08 pm Post subject: |
|
|
Of course it plays for a second and then stops. What did you expect a musical instrument to do when you keep holding down the key?
As for -1 not working, I don't know why. |
|
| Back to top |
|
 |
ZW
Joined: 11 Jan 2007 Posts: 18
Digg It |
Posted: Mon Jan 15, 2007 5:46 pm Post subject: |
|
|
| US of Anarchy wrote: | | Yea but firstnote doesn't work for me. It just plays it for a second, then stops. When I set it to -1 it makes a really low bass sound constantly. Any help? |
the low bass sound happens to me as well. no clue why though. |
|
| Back to top |
|
 |
|