Code Monkey home page Code Monkey logo

Comments (5)

mmitch avatar mmitch commented on August 15, 2024 1

The NOTE macro basically takes a sound generator frequency and calculates the corresponding note to it. The GameBoy has no notion of a note, a sound generator can be only set to a frequency which will then make a sound.
If you set the proper frequency, you can play a certain note.
If you add vibrato to your sound, the frequency will wobble up and down.

In order for the MIDI plugout or the on-screen display to detect a note, we can only take the current frequency, put it in the NOTE macro and see which note is nearest to that frequency. If the vibrato has a very high 'spread', the NOTE macro will oscillate between different notes. Because the algorithm is 'dumb', it will recognize this as different notes. (Also, if it were a trill instead of a vibrato, recognizing different notes would be correct.)

Other problems with note detection are:

  • As you have no notes, you also can't really detect where a note starts or ends. Currently we guess based on volume changes and envelope triggers. While that works surprisingly well, it is by no means perfect.
  • Sound effects: Nothing distinguishes sound effects from music. In the worst case we will try to map bleeps, blops and sweeps to notes because they also might be music.
  • If somebody would make a sound routine that is not pitch-perfect (eg every note is played a quarter-tone too low, which the casual listener probably wouldn't even notice), the NOTE macro would fail miserably.

I currently don't have enough time to look at the IO dumps (I'd have to relearn everything, last time I worked with that part was some years ago). I don't want to rule out that our detection can be made better, but I think all of the easy parts are already done ;-)

But I have had a look at the file. You mean track 1 of subsong 1, right? I think I can see the problem in the console output.
Perhaps this is indeed a case of an out-of-tune track? You could try to add an frequency offset to the NOTE macro and play around until it fits like this:

#define FREQUENCY_OFFSET 123
#define NOTE(x) ((long)((log(FREQ(x)+FREQUENCY_OFFSET)/LN2 - MAGIC)*12 + .2))

You could wrap this in a script that iterates over different offsets and rebuilds gbsplay with -DFREQUENCY_OFFSET=xyz as needed ;-)

from gbsplay.

ChrisEt avatar ChrisEt commented on August 15, 2024 1

Thank you very much for taking the time to write such an elaborate answer! I fully understand. In the meanwhile, I looked a bit into the topic of musical temperaments and realized, this is much more complicated than I thought.

So maybe, after some time, I will understand the magic NOTE() macro and can tell, if that track is out-of-tune, it is trill or just vibrato.

Let's close this issue for now and should I ever get to the bottom of the problem, I'll add it then :-)

Oh and btw: Thank you for creating this software, it is not trivial at all and I think you made some people very happy! πŸ‘

from gbsplay.

mmitch avatar mmitch commented on August 15, 2024

Have you tried the altmidi output plugin? It might give better results than the old midi plugout.

from gbsplay.

ChrisEt avatar ChrisEt commented on August 15, 2024

Yes I have, same result.

I believe the problem is with the NOTE() macro (which I don't understand unfortunately): It returns that a different note has started, while in reality it's the same note, just a little pitch-bend...

from gbsplay.

mmitch avatar mmitch commented on August 15, 2024

btw: I've just pushed 2a48a12, now there is only one NOTE macro (in common.h).
Up until now, the macro was defined in three different places…

from gbsplay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.