Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Musical MIDI game - is Qt right for my project?
Forum Updated to NodeBB v4.3 + New Features

Musical MIDI game - is Qt right for my project?

Scheduled Pinned Locked Moved Unsolved Game Development
9 Posts 4 Posters 2.0k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • BrunodB Offline
    BrunodB Offline
    Brunod
    wrote on last edited by
    #1

    Hello,

    I'm a beginner musician who tinkers with code in his spare time and I would like to write a little video game to help me make progress in music.

    The game simply plays a MIDI melody then pauses and waits for me to play the notes I recognised by ear. Then I use my MIDI keyboard to play the melody back to the game, and the game simply checks that I am playing the right notes in the right order, ignoring the rhythm.

    In other words, if the midi file contains the melody for "frère jacques", the game simply checks that I am indeed playing "do re mi do, do re mi do, mi fa sol, mi fa sol..."

    I have a little experience in coding, but not that much and none with audio. And I am new to the gaming world. I only coded a "pong" video game with Lua/Löve2d. The principle of the game is simple enough, so I fired up my text editor to try and code it in Löve... and... got stuck straight away... there is no simple way to play a MIDI melody in Löve, nor stream the MIDI input from a keyboard.

    I've done quite a bit of research, asked for help on the Löve forum, and someone answered "it's definitely not going to be easy using Löve"...

    So I'm wondering: maybe Lua/Löve is not the right choice for this project? I know MuseScore is written in Qt/C++ ? Is Qt a good choice? and then maybe musicXML is a better option then MIDI?

    I'm using windows for now. In time I would like my game to run on a dedicated raspberry pi, or my android phone, so I can play anywhere and share it with other beginner musicians.

    I enjoy learning and I don't mind putting in the effort, but I would like to put the effort in the right place.
    Can you help orient me in the right direction?

    Thanks for your time
    Regards
    Bruno

    Juan de DironneJ 1 Reply Last reply
    1
    • BrunodB Brunod

      Hello,

      I'm a beginner musician who tinkers with code in his spare time and I would like to write a little video game to help me make progress in music.

      The game simply plays a MIDI melody then pauses and waits for me to play the notes I recognised by ear. Then I use my MIDI keyboard to play the melody back to the game, and the game simply checks that I am playing the right notes in the right order, ignoring the rhythm.

      In other words, if the midi file contains the melody for "frère jacques", the game simply checks that I am indeed playing "do re mi do, do re mi do, mi fa sol, mi fa sol..."

      I have a little experience in coding, but not that much and none with audio. And I am new to the gaming world. I only coded a "pong" video game with Lua/Löve2d. The principle of the game is simple enough, so I fired up my text editor to try and code it in Löve... and... got stuck straight away... there is no simple way to play a MIDI melody in Löve, nor stream the MIDI input from a keyboard.

      I've done quite a bit of research, asked for help on the Löve forum, and someone answered "it's definitely not going to be easy using Löve"...

      So I'm wondering: maybe Lua/Löve is not the right choice for this project? I know MuseScore is written in Qt/C++ ? Is Qt a good choice? and then maybe musicXML is a better option then MIDI?

      I'm using windows for now. In time I would like my game to run on a dedicated raspberry pi, or my android phone, so I can play anywhere and share it with other beginner musicians.

      I enjoy learning and I don't mind putting in the effort, but I would like to put the effort in the right place.
      Can you help orient me in the right direction?

      Thanks for your time
      Regards
      Bruno

      Juan de DironneJ Offline
      Juan de DironneJ Offline
      Juan de Dironne
      wrote on last edited by
      #2

      @Brunod I haven't practiced QT for a long time but seeing your question and your future desire to share, I wondered if a solution was not possible via a web interface.
      With HTML and JavaScript or JQuery, isn't it possible to realize your project...? With Web MIDI API...?

      1 Reply Last reply
      0
      • BrunodB Offline
        BrunodB Offline
        Brunod
        wrote on last edited by
        #3

        @Juan-de-Dironne Thanks for your reply. I have spent some time exploring the html/javascript route... but gosh does that langage and it's clever multiple programming paradigms feel annoyingly confusing. I feel totally clueless about building an efficient and elegant software architecture in JS and there are so many people out there publishing tons and tons of very poorly written js code, it feels like a jungle to try and find something inspiring to learn from. I have yet to find inspiring learning sources for JS. I even purchased a few books and read some online o'reilly books... but even in the books, the coding does not feel elegant and efficient at all...

        So unless I find some inspiring learning material, I'd much rather stay far away from JS...

        Lua is a pleasure to read and write, it's elegant and readable, the only other language that felt as elegant to write was Ruby...
        So I'd rather spend my learning time exploring stuff based on C/C++ (or maybe go back to Ruby? or possibly Python?)

        Moreover, I'd like to play my game mostly offline... so I can cut off all external stimulation and concentrate on the music...

        1 Reply Last reply
        0
        • 8Observer88 Offline
          8Observer88 Offline
          8Observer8
          wrote on last edited by 8Observer8
          #4

          If you want to use C++ you can install FMOD Engine from here: https://www.fmod.com/ for working with audio files.

          754a6ede-cf35-49e6-8b54-67bbbc143342-image.png

          It is free:

          Note: Free Indie License available for developers with less than $200k revenue per year, on a small (under $500k) development budget.

          My simple examples for 2D and 3D sounds in Qt5 and FMOD:

          • 2D sound: https://github.com/8Observer8/FMOD_2D_Qt5Cpp
          • 3D sound: https://github.com/8Observer8/FMOD_3D_Qt5Cpp

          If you want to use Python and PyQt (or PySide) you can use OpenAL. Use this command to install: pip install PyOpenAL. You can see a simple example of its use here: https://pypi.org/project/PyOpenAL/ Use ThinMatrix video tutorials to study using OpenAL for 3D sounds.

          I have yet to find inspiring learning sources for JS

          I think Web Audio API is the best for JS. It works with 2D and 3D sounds.

          I prefer PyQt6/OpenGL and JS/WebGL for 2D/3D graphics.

          1 Reply Last reply
          1
          • KH-219DesignK Offline
            KH-219DesignK Offline
            KH-219Design
            wrote on last edited by
            #5

            Wow! I have already worked on almost exactly such a thing, and for my Android phone.

            Feel free to read/borrow/adapt/"steal"... whatever you like: https://github.com/pestophagous/heory

            I was only using this for myself. In other words, my user base is exactly size 1 and that is me.

            For that reason, sadly, I do not have any kind of wiki or even screenshots.

            However, my build scripts all succeeded on Linux (admittedly an old Ubuntu 18.04) the last time I compiled the app.

            There was a significant amount of work for me to figure out how to incorporate fluidsynth and Oboe and make it all work on Android. My scripts capture/document this (although they capture it, clearly, in "script" syntax not English prose).

            www.219design.com
            Software | Electrical | Mechanical | Product Design

            1 Reply Last reply
            0
            • KH-219DesignK Offline
              KH-219DesignK Offline
              KH-219Design
              wrote on last edited by
              #6

              Because of this thread, I have actually now been motivated today to push one small update in order to demonstrate that my project still builds (on Ubuntu 18.04) for android: https://github.com/pestophagous/heory/pull/47

              The build succeeded, but github is showing an ominous red X (which in the past always meant a compilation failure) because despite the build success, Github CodeQL scan found some C bugs in the fluidsynth code.

              I mentioned earlier that I went through non-trivial effort to get all the following to succeed:

              • integrate fluidsynth (for MIDI)
              • integrate Oboe (for Android audio)
              • compile everything successfully for Android

              I also mentioned that this work is essentially "documented" (at the very least: rendered repeatable) in scripts. A good starting point is this top-level script: https://github.com/pestophagous/heory/blob/main/build_android_app.sh

              GitHub only keeps the CI logs around for a short time (a week? a few days?). Therefore, I saved a successful (and very verbose) build log for safekeeping. If anyone is trying to replicate the successful build, here is a log to compare against: https://drive.google.com/file/d/1nfpcKp7rlVZ_Q1QAUXJwMpk6kNIWaI3V

              www.219design.com
              Software | Electrical | Mechanical | Product Design

              1 Reply Last reply
              0
              • BrunodB Offline
                BrunodB Offline
                Brunod
                wrote on last edited by
                #7

                Thanks for your time and your shared resources @8Observer8 and @KH-219Design :-)

                I've asked around and I decided to stick to my initial idea and code it with Lua. I already have invested sometime in learning lua, and I ended ip finding helpful resources in the lua community. And lua is good at binding external resources, so I can always use C++ or Qt librarie if I need to. And it saves me from starting from scratch learning a new language and a new programming paradigm.

                Right now, I'm working at writing my own MIDI to txt parser, inspired by this perl script:
                https://www.fourmilab.ch/webtools/midicsv/

                I feel writing it myself will give me a very important understanding of the underlying structures of a midi file. And that will be usefull later, when I get to playing around with chords and rhythm..

                @KH-219Design I'm happy to read you revived your project. Care to join forces? We could have a user base of exactly 2 ;-)

                1 Reply Last reply
                1
                • KH-219DesignK Offline
                  KH-219DesignK Offline
                  KH-219Design
                  wrote on last edited by
                  #8

                  @Brunod said in Musical MIDI game - is Qt right for my project?:

                  Care to join forces? We could have a user base of exactly 2 ;-)

                  User base of precisely 2. Sounds pretty excellent :)

                  I have next to zero free time these days. However, if your work is on github or gitlab (or similar), please share a link. I would definitely check it out and look in on it every couple weeks, and maybe share thoughts if anything strikes me.

                  Here is another MIDI project that I found useful recently, and it sounds like it might belong in your bookmarks, too:

                  https://github.com/markc/midicomp

                  www.219design.com
                  Software | Electrical | Mechanical | Product Design

                  BrunodB 1 Reply Last reply
                  1
                  • KH-219DesignK KH-219Design

                    @Brunod said in Musical MIDI game - is Qt right for my project?:

                    Care to join forces? We could have a user base of exactly 2 ;-)

                    User base of precisely 2. Sounds pretty excellent :)

                    I have next to zero free time these days. However, if your work is on github or gitlab (or similar), please share a link. I would definitely check it out and look in on it every couple weeks, and maybe share thoughts if anything strikes me.

                    Here is another MIDI project that I found useful recently, and it sounds like it might belong in your bookmarks, too:

                    https://github.com/markc/midicomp

                    BrunodB Offline
                    BrunodB Offline
                    Brunod
                    wrote on last edited by
                    #9

                    @KH-219Design said in Musical MIDI game - is Qt right for my project?:

                    User base of precisely 2. Sounds pretty excellent :)

                    ^^ indeed it does

                    I have next to zero free time these days. However, if your work is on github or gitlab (or similar), please share a link. I would definitely check it out and look in on it every couple weeks, and maybe share thoughts if anything strikes me.

                    When I have something to share, I will :-)

                    Here is another MIDI project that I found useful recently, and it sounds like it might belong in your bookmarks, too:

                    https://github.com/markc/midicomp

                    SWEET! I have plenty of stuff to learn from now. That should keep me busy for the foreseeable future. Thx

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved