snestracker icon indicating copy to clipboard operation
snestracker copied to clipboard

[tracker] Note Playback

Open bazz1tv opened this issue 4 years ago • 0 comments

Have sound played by the emulator when the user plays notes on a supported input device. This has already been implemented in the debugger midi tab. It can now be converted to the tracker.

  • playback mode : The emulator simply plays sound from the voice that is highlighted by the pattern editor cursor, with the instrument currently selected in the Instrument Panel.
  • record mode : same as playback, but the note gets recorded

Unlike in the debugger instrument tab, It should not be necessary to override the PC (program counter) in tracker mode to create this feature. You'll have to change the way song playback and stopping works to allow the emulator to stay running.

Playback over a chan that's already playing

Of course, if the user is doing playback over a channel during song playback, his input should be highest priority and therefore override any conflicts with the pattern data being played. This would require a set of bitflags in the APU driver (musicianPlayback) which when set, let's the relevant voice know to refrain from actually playing back the current row's data.

Well, maybe in a perfect world this would work. ❄️ On the other hand, I expect that channel will be processing effects parameters and doing wild things to the DSP settings. It's not difficult to imagine wonky sounds happening from this conflict of the voice channel. And sure there are ways around it, but they seem unwise given we're on a 64KB RAM system. It might be a good idea to simply warn the user when they conflict with a channel, that they should migrate to a free voice. This kind of warning should be the kind mentioned in #44

I wouldn't want the voice automatically chosen by software either, but I won't go into why

WatchDog Timer

Consider using a watchdog timer at the following events:

  • song playback has stopped. user-triggered.
  • musician released a piano key

pseudo code

StopEmu:
  SDL_RemoveTimer(emuWatchdog) // remove the old timer (sanity check)
  emuWatchdog = SDL_AddTimer(10000)

NoteON:
  SDL_RemoveTimer(emuWatchdog) // cancel the watchdog

// trigger watchdog timer after the musician releases a piano key
NoteOFF:
  SDL_RemoveTimer(emuWatchdog) // remove the old timer (sanity check)
  emuWatchdog = SDL_AddTimer(10000) // add the new timer

Stay on Track

First support the keyboard commands to play instrument notes. Basically combining the midi instrument tab from Debugger, with the WatchDog (a new member of Tracker), and the PatternEditor module keyboard note event handler.

Edge Cases

  1. Playing a note in playback mode, and holding it while going into recording mode. What do you expect to happen?
  2. Playing a note in playback mode, and starting songplayback while the note is held. In this case song playback start should gracefully cancel all currently playing input notes by fading them out quickly and then starting song. The tracker ignores the note that was held down until it is released and pressed again.
  3. Playing a note during song playback, and then stopping song playback. The note should continue to resonate on its own.
  4. Others?

Other Criteria

Once that's working, go in and attach MIDI input.

bazz1tv avatar Jun 07 '20 14:06 bazz1tv