Author |
Message |
Harblkipz
![](http://compsci.ca/v3/uploads/user_avatars/922448393491350042658c.gif)
|
Posted: Thu Nov 06, 2008 4:38 pm Post subject: Piano |
|
|
Hello Compsci,
I want to make a piano program in Turing. I have the base for my program, I just need help with one thing.
Here's my code, just as a start.
code: |
var chars : array char of boolean
loop
Input.KeyDown (chars)
if chars ('a') then
Music.Play ( "2c" )
else
put "" ..
end if
if chars ('s') then
Music.Play ( "2e" )
else
put "" ..
end if
if chars ('d') then
Music.Play ( "2d" )
else
put "" ..
end if
if chars ('f') then
Music.Play ( "2f" )
else
put "" ..
end if
end loop
|
When I hit a note, then another, there is this huge delay, is there any way to fix that? Thanks! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
pavol
|
Posted: Thu Nov 06, 2008 4:51 pm Post subject: RE:Piano |
|
|
Vertico is right, you don't need the put "" part, as a matter of fact you don't even need the else clause of your if statements.
What I think is that simply calling Music.Play() alone takes a while to execute and that's what is causing the delays in your program.
...strange Vertico's post no longer exists lol ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
Harblkipz
![](http://compsci.ca/v3/uploads/user_avatars/922448393491350042658c.gif)
|
Posted: Thu Nov 06, 2008 5:58 pm Post subject: RE:Piano |
|
|
Still doesn't stop the delay, i should of been more specific.
What I want it to do is, when i hit one note, if I hit another right after it either plays both, or the newly hit note. What ever is easier. |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Thu Nov 06, 2008 6:06 pm Post subject: RE:Piano |
|
|
Is Turing even capable of playing more than one note at a time? |
|
|
|
|
![](images/spacer.gif) |
S_Grimm
![](http://compsci.ca/v3/uploads/user_avatars/18926424384e6d86e5cf4d6.jpg)
|
Posted: Thu Nov 06, 2008 9:09 pm Post subject: RE:Piano |
|
|
nope. at least not to my knowledge. when i tried to write this program myself, i couldn't get it to play more than one note at a time. |
|
|
|
|
![](images/spacer.gif) |
Harblkipz
![](http://compsci.ca/v3/uploads/user_avatars/922448393491350042658c.gif)
|
Posted: Thu Nov 06, 2008 9:09 pm Post subject: RE:Piano |
|
|
I hope so, if not then we can scrap this thread. |
|
|
|
|
![](images/spacer.gif) |
S_Grimm
![](http://compsci.ca/v3/uploads/user_avatars/18926424384e6d86e5cf4d6.jpg)
|
Posted: Thu Nov 06, 2008 9:11 pm Post subject: RE:Piano |
|
|
like i said, (and if someone can prove me wrong, please do) I couldn't get this program to play more than one note at a time when i tried (that was almost a year ago.) |
|
|
|
|
![](images/spacer.gif) |
Harblkipz
![](http://compsci.ca/v3/uploads/user_avatars/922448393491350042658c.gif)
|
Posted: Fri Nov 07, 2008 9:46 pm Post subject: RE:Piano |
|
|
That sucks. I remember I did this in my engineering class last year with a breadboard. I thought it would be neat with just a keyboard but I guess I forgot Turing couldn't do that. Thanks anyways guys. :] |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
SNIPERDUDE
![](http://compsci.ca/v3/uploads/user_avatars/16932914504cbd0ad6ceaf1.jpg)
|
Posted: Sun Nov 09, 2008 7:35 pm Post subject: RE:Piano |
|
|
You can, using a process. But I wouldn't because of the unreliability of these (the timing is not reliable) and should be avoided whenever possible. |
|
|
|
|
![](images/spacer.gif) |
sriyegna
|
Posted: Tue Mar 09, 2010 4:48 pm Post subject: RE:Piano |
|
|
could you please elaborate sniperdude?
im building a similar program, cept with more keys
and its very annoying to have to wait for the whole delay. id like to make it smooth. So, could you please elaborate on your process theory? |
|
|
|
|
![](images/spacer.gif) |
Turing_Gamer
![](http://compsci.ca/v3/uploads/user_avatars/8617055374bcc8b48c6d4f.png)
|
Posted: Tue Mar 09, 2010 6:11 pm Post subject: Re: Piano |
|
|
You can do it easily by using frequencies but not so much piano. It is practically impossible. You can use intstr but the max it can do is a whole note and the least it can do is I believe 8. Not much variety so sorry cant help you |
|
|
|
|
![](images/spacer.gif) |
SNIPERDUDE
![](http://compsci.ca/v3/uploads/user_avatars/16932914504cbd0ad6ceaf1.jpg)
|
Posted: Sat Mar 13, 2010 11:18 pm Post subject: RE:Piano |
|
|
processes are similar to procedures, but when called will run alongside the rest of your program (where in a procedure it will finish executing the contents before moving on). This means if you put a part you want to play alongside your current melody, you would put one of them in a process.
But like I said the problem with using a process in Turing is the timings of when it will execute is very hard to manage, especially with varying computer speeds. Try it out anyway for this purpose, but keep in mind you should use procs whenever possible. |
|
|
|
|
![](images/spacer.gif) |
|