Results 1 to 4 of 4

Thread: Visual Basic Customized Piano. I'm a Noob. So please tolerate my stupid questions

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2019
    Posts
    10

    Question Visual Basic Customized Piano. I'm a Noob. So please tolerate my stupid questions

    Hey There,

    First of all, I'm a beginner in Coding, So please tolerate my stupid questions.

    I want to create a customized Piano layout that plays only the notations based on the user's selection of the raga name. I want it to sustain the tune and continuous play while holding the keys set by case e.keycode.

    I want to change the Piano key's text and tone based on the user's scale selection, an example is given below

    I need to declare notes with numbers for automatic calculation i.e number for C=1, C#=2, D=3, D#=4, E=5, F=6, F#=7, G=8, G#=9, A=10, A#=11, B=12 suppose they want to play raga Kalyani the notation for the Kalyani raga - Arohanam is C D E F# G A B and Avarohanam is B A G F# E D C. which can be written as Arohanam is 1 3 5 7 8 10 12 or (1 2 2 2 1 2 2) and Avarohanam is 1 3 5 7 8 10 12 in reverse order (1 2 2 2 1 2 2), so it can calculate for any scales the starting key is considered as 1 and it adds according to the number defined by the notation.

    So the above is for the scale C, if they wish to play it on D scale then the notation would be D E F# G# A B C#. which can be written as 1 3 5 7 8 10 12 or (1 2 2 2 1 2 2)
    for the D scale, its third key is the next note for that raga i.e E likewise the next note.

    Some ragas don't have symmetric Arohanam and Avarohanam, for your better understanding "Arohanam is the sequence of swaras used in a raga in the ascending passages i.e. as the pitch goes up. Avarohanam is the sequence of swaras to be used in descent. The arohanam and avarohanam (or the scale) of a raga provide only a skeletal outline upon which the rest of the raga is formed."

    Raga Kamas is asymmetric raga Arohanam is C F E F G A A# C and Avarohanam is C A# A G F E D C so here D is missing in the Arohanam. For such ragas I want the piano to change the notes according to the keypress in real-time.

    I would really appreciate your help on this. I've already created my base form and the design part is done also the coding is done but I'm not able to play the keys continuously it sounds so odd since the playback is from the recorded file"wave", it looks artificial. I want to perform the piano just like a virtual piano ref to the link https://www.onlinepianist.com/virtual-piano, also I need to press two or three keys simultaneously and this is not possible with my setup please guide me.!Form1.txt

    My Project link is here : https://drive.google.com/file/d/1oVs...ew?usp=sharing

    Thanks in Advance.!

    Siddhusubbu
    Last edited by siddhusubbu; Jun 13th, 2021 at 04:15 AM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Basic Customized Piano. I'm a Noob. So please tolerate my stupid questions

    Questions in and of themselves aren't stupid. I understood nothing about programming when I first started. :-) I can't download your project. Could you attach it to a reply in this thread?
    Last edited by Peter Swinkels; Jun 14th, 2021 at 04:58 AM.

  3. #3
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Visual Basic Customized Piano. I'm a Noob. So please tolerate my stupid questions

    what events do you use to manage the keys ? key_down, key_up ? both?
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  4. #4
    New Member
    Join Date
    Oct 2020
    Location
    Europe
    Posts
    12

    Re: Visual Basic Customized Piano. I'm a Noob. So please tolerate my stupid questions

    Counldn't download your project, some error with 'terms of use' but it was possible to open Form1.txt

    Maybe you could reduce the complexity of the question by dividing it into a technical part and a musical part.

    Is it really necessary to do a calculation for the note numbers ? Maybe a conversion/mapping table would also do the job, means an array in VB. For example: Note number 0 corresponds to the element with index 0 in the array and holds the number of the note that will actually be played. This way you could map any note to wathever you want, like creating a table on paper.

    For the note numbers: I would recommend to use the MIDI Note numbers with the range of 0 to 127 where Note number 69 = A4 = 440 Hz. (instead of using an own note numbering system). When following the standard there is a chance to reuse parts of your work in the future, and having compatibility from the beginning with MIDI-Keyboards, Sound generators and so on.

    About the sound 1:
    Code:
    Select Case e.KeyCode
                Case Keys.Q
                    button1.PerformClick()
    This way you can play a sound one time, but you can't play different note-durations. A complete different playing function is needed and the use of MouseDown/MouseUp or KeyDown/KeyUp (where KeyDown starts the Sound, play it continuously (or play at least the decay until silence) and stops the sound whenever KeyUp occurs)

    About the sound 2: The documatation says:
    The My.Computer.Audio.Play method allows the application to play only one background sound at a time;..
    I don't think Audio.Play is usable for playing notes.
    There is maybe another way, but quite difficult for beginners. (had to learn that by myself as I begun programming VB .Net)

    On many PC's and Notebooks there is a Software-Synthesizer installed by default named like 'Microsoft GS Wavetable Synth' See also: Device Manger / Software Devices

    If the Device is present one have to start with 'midiOutGetNumDevs' 'midiOutGetDevCapsA' and so on
    to get the exact name of the device, then the device can be opened with 'midiOutOpen' and after that one can send NoteOn / NoteOff Messages to the device. (like: NoteOn, NoteNumber, Velocity)

    One of the difficulties is that these functions were never ported to .Net so one have to handle the functions from Winmm.dll written for C++ ...quite difficult and time consuming...
    But maybe you can find a Library (Midi I/O or similar, which provides functions like MidiOutOpen, MidiOutShortMsg and so on for you) on GitHub or elsewhere.

    And there is another downside: The Software Synthesizer has a little delay (0.1 - 0.5 Seconds) between pressing a key and hearing the tone. There is no markable delay anymore when using a MIDI (Hardware) sound generator.

    A complete other way would be using a Library (OpenSource Project) that is specialized to playing multiple sound at the same time with as little delay as possible.

    Anyway, I see a lot of work.
    Last edited by kensen; Jun 18th, 2021 at 02:17 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width