Author Topic: Piano program  (Read 2835 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Piano program
« on: February 15, 2021, 05:23:09 pm »
Hello ! I want to make a piano program that uses the windows midi. Programming midi used to take a lot of time to become usable with qb64, but it finally works and I understand. Now, however, I get stuck wanting a keyboard wizard in the program. Everyone can calibrate their own keyboard for the piano. But here I get into total chaos. Try it. Shift, ctrl, stick. Still, what should I measure? I also tried it with Qb 1.5, unfortunately the same problem. What do I need to read to find out what button is pressed? No shift, ctrl, I just want a simple assignment. I can't assign it to _keydown because it's chaotic.

Code: QB64: [Select]
  1.     Locate 1, 1
  2.     For t = 1 To 255
  3.         a = _KeyDown(t)
  4.         If a Then Print t
  5.     Next t
  6.     _Display
  7.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Piano program
« Reply #1 on: February 15, 2021, 05:26:25 pm »
_KEYHIT, instead of _KEYDOWN
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Piano program
« Reply #2 on: February 15, 2021, 06:45:41 pm »
Wouldn't _keydown help with holding a note for awhile?

demo: your bottom row of letters on keyboard are now notes on piano abcdefgA,  A an octave higher than a
Code: QB64: [Select]
  1. For i = 1 To 80
  2.     If _KeyDown(122) Then Locate 1, i: Print "a";
  3.     If _KeyDown(120) Then Locate 2, i: Print "b";
  4.     If _KeyDown(99) Then Locate 3, i: Print "c";
  5.     If _KeyDown(118) Then Locate 4, i: Print "d";
  6.     If _KeyDown(98) Then Locate 5, i: Print "e";
  7.     If _KeyDown(110) Then Locate 6, i: Print "f";
  8.     If _KeyDown(109) Then Locate 7, i: Print "g";
  9.     If _KeyDown(44) Then Locate 8, i: Print "A";
  10.     _Limit 1 'once per second
  11.  
Each sec records a hole for your piano player tape
« Last Edit: February 15, 2021, 07:05:37 pm by bplus »