为此,我需要在 if 语句内使用 while 循环吗?
我需要在 Applescript 中编写一些我从未使用过的东西,但这更多的是针对这个特定问题的一般编程问题。
问题:我正在使用 Midipipe 接收来自两个不同设备的 MIDI 输入。
我想使用第一个设备的输入来调制第二个设备的输出。问题是第一个设备将发送一个 MIDI 音符,然后第二个设备将发送任意数量的音符,所有这些音符都需要调制。苹果脚本需要不断地调制这些音符,但是一旦第一个设备发送另一个音符,它就会改变调制。
所以我想我需要这样的东西:
设备一将从通道 1 上的注释 1-16
发送 设备二将从通道 2 上的注释 1-7 发送
Device one = x
Device two = y
if x = 1
while x = 1
return y
end while
end if
if x = 2
while x = 2
y = y + 12 --moving y notes up one octave
end while
end if
if x = 3
while x = 3
y = y + 24 --moving y notes up one octave
end while
end if
etc
事情尚未正常工作,我不确定是否可以我的逻辑有问题吗?我收到错误“预期为其他但发现同时”。我试图放入 else 语句并得到一个不同的错误......
I'm needing to program something in Applescript which I've never used, but this is more of a general programming question for this specific issue.
The problem: I'm using Midipipe to receive midi input from two different devices.
I want to use the input of the first device to modulate the second device output. The thing is the first device will send one midi note, and then the second device will send an arbitrary number of notes that all need to be modulated. The apple script needs to be continually modulating those notes, but then as soon as the first device sends another note, it changes the modulation.
So I'm thinking I need something like this:
Device one will send from notes 1-16 on channel 1
Device two will send from notes 1-7 on channel 2
Device one = x
Device two = y
if x = 1
while x = 1
return y
end while
end if
if x = 2
while x = 2
y = y + 12 --moving y notes up one octave
end while
end if
if x = 3
while x = 3
y = y + 24 --moving y notes up one octave
end while
end if
etc
Things aren't working yet, and I'm not sure if it's a problem with my logic? I'm getting the error "expected else but found while". I tried to put in an else statement and got a different error...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少
if x = 1
和其他 if 之后的then
。第一个 if 中的 while 是不必要的:
相同
这与循环开始时返回 y
,这会停止循环。在第二个和第三个 while 时,您将陷入无限循环。这是因为您的循环正在监视 x 变量,但您只更改 y。因此,x 将永远为 3,并且脚本将永远不会跳出循环。
You're missing the
then
afterif x = 1
and the other ifs.The while at the first if is unnecessary:
This is tha same as
because you will return y when the loop begins, and this stops the loop.
At the second and third whiles, you'll get an infinite loop. This is because your loop is monitoring the x variable, but you are changing only the y. So, x will be 3 forever, and the script will never get out of the loop.