-
Notifications
You must be signed in to change notification settings - Fork 3
SEQ sample (Sega MIDI-style music playback) for SRL #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Heavely inspired by the Jo Engine sample made by jfsantos (João Felipe Santos) https://github.com/jfsantos/mid2seq
ReyeMe
left a comment
There was a problem hiding this 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?
Samples/Sound - SEQ/src/main.cxx
Outdated
|
|
||
| void Initialize_SoundSystem_SEQ_SaturnMIDI(void) | ||
| { | ||
| slInitSound(sddrvstsk, sizeof(sddrvstsk), (uint8_t *)mechs_map, sizeof(mechs_map) ); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Samples/Sound - SEQ/src/main.cxx
Outdated
| uint8_t seqVolume = 127; | ||
|
|
||
| // Auto-Play the SEQ music track | ||
| slBGMOn((1 << 8) + 0, 0, seqVolume, 0); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Samples/Sound - SEQ/src/main.cxx
Outdated
| @@ -0,0 +1,138 @@ | |||
| #include "SDDRVS.DAT" | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is where the init will happen https://github.com/ReyeMe/SaturnRingLib/blob/main/saturnringlib/srl_sound.hpp#L50
| tonFILE.LoadBytes(0, tonFILE.Size.Bytes, tonBuf); | ||
|
|
||
| // SEQ data | ||
| slDMACopy(seqBuf, (void *)((uint8_t*)SoundMem + 0x21fdc), seqFILE.Size.Bytes); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
Samples/Sound - SEQ/src/main.cxx
Outdated
| SRL::Debug::Print(1,9, "Press Left/Right to change the Tempo"); | ||
| if (pad.WasPressed(SRL::Input::Digital::Button::Left)) | ||
| { | ||
| if (musicTempo > -32768+16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic number again?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Samples/Sound - SEQ/src/main.cxx
Outdated
| } | ||
| else if (pad.WasPressed(SRL::Input::Digital::Button::Right)) | ||
| { | ||
| if (musicTempo < 32767-16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic number
There was a problem hiding this comment.
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
|
Updated:
|
saturnringlib/srl_sound.hpp
Outdated
| } | ||
|
|
||
| #if SRL_ENABLE_AUDIO_SEQ_SUPPORT == 1 | ||
| uint8_t audio_map_seq[] = { |
There was a problem hiding this comment.
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
saturnringlib/srl_sound.hpp
Outdated
| #include <sega_pcm.h> | ||
| } | ||
|
|
||
| #if SRL_ENABLE_AUDIO_SEQ_SUPPORT == 1 |
There was a problem hiding this comment.
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
saturnringlib/srl_sound.hpp
Outdated
| SND_ChgMap(0); | ||
|
|
||
| slInitSound(programBuffer, program.Size.Bytes, areaMapBuffer, areaMap.Size.Bytes); | ||
| #if SRL_ENABLE_AUDIO_SEQ_SUPPORT == 1 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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
Samples/Sound - SEQ/src/main.cxx
Outdated
| SRL::Core::Initialize(SRL::Types::HighColor::Colors::Black); | ||
|
|
||
| // Load and initialize a Saturn SEQ music track (Sega MIDI-style music playback) | ||
| Load_SEQ_SaturnMIDI(); |
There was a problem hiding this comment.
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
Heavely inspired by the Jo Engine sample made by jfsantos (João Felipe Santos) https://github.com/jfsantos/mid2seq