Skip to content

Conversation

@Frogbull
Copy link

Heavely inspired by the Jo Engine sample made by jfsantos (João Felipe Santos) https://github.com/jfsantos/mid2seq

Heavely inspired by the Jo Engine sample made by jfsantos (João Felipe Santos) https://github.com/jfsantos/mid2seq
Copy link
Owner

@ReyeMe ReyeMe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked through the sample, and the SEQ playback loks simple enough.

But, as is now I cannot let it pass, since it cannot be used properly with other parts of SRL, especially PCM playback.

SRL already includes the sound driver, so there is no need to duplicate that. I would also prefer the backround music functions to be wrapped nicely and available through the Sound class, simmilar to CDDA and PCM.

I guess there is no way to change SEQ without reinitializing sound?


void Initialize_SoundSystem_SEQ_SaturnMIDI(void)
{
slInitSound(sddrvstsk, sizeof(sddrvstsk), (uint8_t *)mechs_map, sizeof(mechs_map) );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since slInitSound is already called within SRL, woudn't it be better to implement this as a propper API instead of this hack?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, way better and it will avoid conflict with PCM/CDDA

uint8_t seqVolume = 127;

// Auto-Play the SEQ music track
slBGMOn((1 << 8) + 0, 0, seqVolume, 0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with direct SGL calls, but again, woudn't it be better to implement this as proper API?

Also: Magic numbers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, (1 << 8) + 0 for the track index looks weird. And totaly agreed to make proper API to handle all this properly.

slBGMOn(SongIndex, Priority, Volume, Rate);

SongIndex: Uint16 for SEQ Track Index
Priority: Uint8 for Priority (range only from 0 to 31. The larger the value, the higher the priority)
Volume: Uint8 for Track Volume (range only from 0 to 127)
Rate: Uint8 for Track Rate (range from 0 to 255)

https://www.jo-engine.org/upload/files/SEGA/ST-238-R1-051795.pdf

@@ -0,0 +1,138 @@
#include "SDDRVS.DAT"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sound driver is already included with SRL, and is loaded when initialize is called

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I don't know well your code, if we can track when it's loaded we could set a proper SoundMem Address 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tonFILE.LoadBytes(0, tonFILE.Size.Bytes, tonBuf);

// SEQ data
slDMACopy(seqBuf, (void *)((uint8_t*)SoundMem + 0x21fdc), seqFILE.Size.Bytes);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this magic number means?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The driver has probably an allocated buffer for SEQ data starting at +0x21fdc (but I'm not sure)

slDMACopy(seqBuf, (void *)((uint8_t*)SoundMem + 0x21fdc), seqFILE.Size.Bytes);

// TON data
slDMACopy(tonBuf, (void *)((uint8_t*)SoundMem + 0x2737c), tonFILE.Size.Bytes);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this magic number means?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The driver has probably an allocated buffer for TON data starting at +0x2737c (but I'm not sure)

SRL::Debug::Print(1,9, "Press Left/Right to change the Tempo");
if (pad.WasPressed(SRL::Input::Digital::Button::Left))
{
if (musicTempo > -32768+16)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number again?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slBGMTempo(Tempo)

Tempo: Sint16 (range from -32768 to 32767)

https://www.jo-engine.org/upload/files/SEGA/ST-238-R1-051795.pdf

Do you have -32768 or 32767 defined as max value for a Sint16?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use INT16_MAX, and INT16_MIN

}
else if (pad.WasPressed(SRL::Input::Digital::Button::Right))
{
if (musicTempo < 32767-16)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

Copy link
Author

@Frogbull Frogbull Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as -32768 (Sint16 max positive value)

Integrated SEQ Support (optional)
With better integration in SRL
SRL_USE_SGL_SOUND_DRIVER = 1
@Frogbull
Copy link
Author

Updated:

  • Way better Integration with SRL
  • Less magic numbers
  • No more ugly audio driver init
  • PCM integrated in the sample to show PCM played over SEQ music

}

#if SRL_ENABLE_AUDIO_SEQ_SUPPORT == 1
uint8_t audio_map_seq[] = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be defined here?

  • constant defined outside of namespace
  • constant naming does not follow style quideline

#include <sega_pcm.h>
}

#if SRL_ENABLE_AUDIO_SEQ_SUPPORT == 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special define should not be needed, the way you have done it now is a hack that will work with that sample, its not generic

SND_ChgMap(0);

slInitSound(programBuffer, program.Size.Bytes, areaMapBuffer, areaMap.Size.Bytes);
#if SRL_ENABLE_AUDIO_SEQ_SUPPORT == 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a generic solution, and will not allow to load different map during runtime

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've a new solution that allow CUSTOM.MAP (no more MAP array in the C)

@@ -0,0 +1,144 @@
#define SRL_ENABLE_AUDIO_SEQ_SUPPORT 1
#define SoundMem 0x25a0b000 // The playback data is stored starting from address 0xB000 in the MC68000 memory area (0x25A0B000 in the program) https://antime.kapsi.fi/sega/files/ST-237-R1-051795.pdf
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be handled within a wrapper, not used by sample directly

SRL::Core::Initialize(SRL::Types::HighColor::Colors::Black);

// Load and initialize a Saturn SEQ music track (Sega MIDI-style music playback)
Load_SEQ_SaturnMIDI();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function name does not follow style quidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants