Announcement

Collapse
No announcement yet.

MIDI-like Music?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    MIDI-like Music?

    Hello there.

    I would like to have MIDI-like music in my game. What I mean with this is, that the Game should have predefined Tracks (MIDI files?) and the Game plays Samples according to these tracks.
    Similar to 8/16 bit games.

    Zelda: Ocarina of Time uses this technique for example, too.

    Is this somewhat possible with UE? THe Synth Components don't seem to be what I want.
    I already tried the Procedural Midi Plugin from the Marketplace, but this does not allow custom Samples :/

    #2
    You could use the MIDI file player in the Procedural MIDI Plugin to trigger sample playback (or a sample synth in the new audio engine) according to the pitch and duration of each note, separated by channels. You could even make it a bit more complex and support multisamples, though this might defeat the aesthetic point of replicating 16-bit era single sample soundfont-like playback...

    I haven't actually used the PMP's MIDI file playback yet, but plan to use it this week... I'm expecting to have to map MIDI note pitch to playback rate/frequency, but that might just happen anyway - I forget what kind of inputs the sample synth component has.

    Comment


      #3
      So I just went and checked, because I suddenly thought that maybe I'd imagined the sample synth component...but no, it's there! Add component -> Synth Sample Player. You can do a SetSoundWave from asset .WAVs, and maybe you'd want to do this dynamically to cut down on sample player instances (though I imagine they're much lighter on the CPU than the modular/granular synths).

      What it doesn't have is stuff like NoteOn/NoteOff, but you could build that logic yourself by checking isLoaded, current position, finished, etc. I guess you'd have to double/triple up on per-MIDI-channel instances if you wanted tails rather than cutouts when new notes are triggered, or polyphony, but that stuff also starts to go beyond the limits of the 8/16bit aesthetic

      Good luck - keen to hear how you get on!

      Comment


        #4
        I already tried the Synth Sample Player, but I didn't get any result. They simply don't make a sound.



        The Midi Component from the Procedural Plugin are fired. But the Synth Player doesn't make any sound
        Attached Files
        Last edited by Raildex_; 06-26-2017, 12:38 PM.

        Comment


          #5
          Hmm. Can you get Synth Sample Player to produce sound by any other means? I'm using MIDI keyboard input as detailed in Dan Reynold's guide elsewhere on the forum, rather than the PMP plugin, but I'm able to play notes by doing SetSoundWave on EventBeginPlay, then using the MIDI Note On outlet to do trigger SeekToTime (resets playback from 0s, otherwise SynthSamplePlayer will just play from wherever it left off), then SetPitch much like you're doing in the screenshot, then finally Start. Note Off goes to a Stop. I haven't got any envelope logic set up, but it maps to notes fine.

          Are you sure MIDI note values are coming out of Event Data 1? If for some reason the frequency going to SetPitch is zero, or out of range, then that might explain it. The only other thing I can think of is that if you're using a very short WAV (32btes, 64bytes, etc) to loop and pitch as you would in a module tracker, the engine might have some difficulties with that. I've not tested it yet.
          Last edited by echolevel; 06-26-2017, 06:14 PM.

          Comment


            #6
            I got it to work!

            The Components had to be added in Construction Script instead of BeginPlay(or added at compile time)
            https://cdn.discordapp.com/attachmen...akers_Test.mp3

            However, my Samples are looped when played, which means the Sample is repeated all over, if there is no Note Off.
            We need a configuration to loop the samples in a specific position, something like NOTE START - LOOP - NOTE OFF


            Here's another Test:
            https://cdn.discordapp.com/attachmen...ction_Test.mp3
            I had to manually stop the Samples though if they are too long, else they would repeat automatically.
            To avoid this, I checked if the Sample Position > Sample End (I made the WAV Sample longer with silence to have a threshold) in Event Tick.
            Last edited by Raildex_; 06-27-2017, 01:44 AM.

            Comment


              #7
              Good stuff!

              As well as logic for NoteOff, you should explore fast volume ramps for the beginnings and ends of one-shot samples (e.g. 10ms; you might get away with even less) to avoid clicking. Unless you want the clicking

              Comment

              Working...
              X