Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Piano
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Harblkipz




PostPosted: 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!
Sponsor
Sponsor
Sponsor
sponsor
pavol




PostPosted: 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
Harblkipz




PostPosted: 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.
Insectoid




PostPosted: Thu Nov 06, 2008 6:06 pm   Post subject: RE:Piano

Is Turing even capable of playing more than one note at a time?
S_Grimm




PostPosted: 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.
Harblkipz




PostPosted: Thu Nov 06, 2008 9:09 pm   Post subject: RE:Piano

I hope so, if not then we can scrap this thread.
S_Grimm




PostPosted: 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.)
Harblkipz




PostPosted: 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. :]
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: 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.
sriyegna




PostPosted: 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 Smile

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?
Turing_Gamer




PostPosted: 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
SNIPERDUDE




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: