js-dos
js-dos copied to clipboard
Support Cuesheet for imgmount
https://github.com/js-dos/emulators/blob/3f4d6b44c0969328c8e5ded834e7b33331bdfe15/native/dosbox/config.h#L98
#define C_SDL_SOUND 1 to enable dosbox cuesheet support
See also https://www.dosbox.com/wiki/Cuesheet
Maybe need other work to do instead of just simply set SDL_SOUND to 1.
Can't use SDL_SOUND=1 cause js-dos build didn't use sdl at all. So need to look how to add cue support without SDL
SDL_SOUND is only used in https://github.com/js-dos/emulators/blob/c06afe5682fcec1c409cf3725520970aba6310fb/native/dosbox/src/dos/cdrom.h and have nothing to do with display.
Could we just import SDL_SOUND without importing SDL?
From dosbox INSTALL file: SDL_Sound (optional) For compressed audio on diskimages (cue sheets) support. This is for cue/bin cdrom images with compressed (mp3/ogg) audio tracks. Get it from http://icculus.org/SDL_sound Licence: LGPLv2+
It seems that SDL_sound and SDL are two different libs with similar name.
Yeah looks so, if SDL_sound is not hardcoupled with SDL maybe we can add it by simply defining SDL_SOUND 1 as you say. Will check this later, or you can chek by yourself
SDL_sound depends on SDL. We need to implement class AudioFile without SDL.
P.S. Can we just import SDL but treat it just a dep of SDL_sound? (not a display backend)
More specific, this part.
#if defined(C_SDL_SOUND)
CDROM_Interface_Image::AudioFile::AudioFile(const char *filename, bool &error)
{
Sound_AudioInfo desired = {AUDIO_S16, 2, 44100};
sample = Sound_NewSampleFromFile(filename, &desired, RAW_SECTOR_SIZE);
lastCount = RAW_SECTOR_SIZE;
lastSeek = 0;
error = (sample == NULL);
}
CDROM_Interface_Image::AudioFile::~AudioFile()
{
Sound_FreeSample(sample);
}
bool CDROM_Interface_Image::AudioFile::read(Bit8u *buffer, int seek, int count)
{
if (lastCount != count) {
int success = Sound_SetBufferSize(sample, count);
if (!success) return false;
}
if (lastSeek != (seek - count)) {
int success = Sound_Seek(sample, (int)((double)(seek) / 176.4f));
if (!success) return false;
}
lastSeek = seek;
int bytes = Sound_Decode(sample);
if (bytes < count) {
memcpy(buffer, sample->buffer, bytes);
memset(buffer + bytes, 0, count - bytes);
} else {
memcpy(buffer, sample->buffer, count);
}
return !(sample->flags & SOUND_SAMPLEFLAG_ERROR);
}
int CDROM_Interface_Image::AudioFile::getLength()
{
int time = 1;
int shift = 0;
if (!(sample->flags & SOUND_SAMPLEFLAG_CANSEEK)) return -1;
while (true) {
int success = Sound_Seek(sample, (unsigned int)(shift + time));
if (!success) {
if (time == 1) return lround((double)shift * 176.4f);
shift += time >> 1;
time = 1;
} else {
if (time > ((numeric_limits<int>::max() - shift) / 2)) return -1;
time = time << 1;
}
}
}
#endif
Data Structures
Sound_AudioInfoSDL_AudioSpec.format
Enumerations
Sound_SampleFlags
Functions
Sound_NewSampleFromFileSound_FreeSampleSound_SetBufferSizeSound_SeekSound_Decode
Wow, thanks for this investigation! I am on vacations until 11th of January, so I can look after that
Anything I can help with?
Unfortunately IPX feature takes all my time. Hope to finish it soon, and then I will take some other task, maybe this one. You can only try to do it :)
I think we can easily add support for OGG track using minivorbis instead of SDL_sound
I think we can easily add support for OGG track using minivorbis instead of SDL_sound
minivorbis only supports Vorbis codec. However, Cuesheet support multi codec including MP3
See https://www.dosbox.com/wiki/Cuesheet#Compressed_audio_tracks
Yes, but i think it's not a big deal to convert mp3 to ogg. I think because we have full control over bundle creation we can create cue with ogg. At least it will be a good start.
Yes. It is a good start. But I think nearly full compatibility with DosBox is also important since DOS.Zone Studio is provided for user and reconvert audio is very confusing and frustrating for user.
P.S. OGG is a container format and may contain different codec. Convert MP3 to Vorbis is a more accurate term.
Okay, not sure that we can add mp3 decoder, is it free?
The MP3 technology became patent-free in the United States on 16 April 2017 when U.S. Patent 6,009,399, held by and administered by Technicolor, expired.
SDL_sound is licensed zlib license. They use of LGPL'd code from mpg123 to decode MP3.
mackron/dr_libs claims mp3 decode in public domain.
How to build with cue support:
1. Get SDL_sound 2 from https://github.com/icculus/SDL_sound (use latest git version)
Extract to native\dosbox\3rdparty\SDL_sound
2. Edit native\dosbox\3rdparty\SDL_sound\src\SDL_sound.h
Change #include "SDL.h" to #include <SDL2/SDL.h>
3. Edit native\dosbox\3rdparty\SDL_sound\src\SDL_sound_internal.h leave support for vorbis only(or other formats)
4. Edit native\dosbox\src\dos\dos_programs.cpp Line: 1501
Comment out MSCDEX_SetCDInterface(CDROM_USE_SDL, -1);
5. Edit DOSBOX config.h
Add #define C_SDL_SOUND 1
6. Edit native\dosbox-jsdos\dosbox-jsdos.cmake
Add "${CMAKE_CURRENT_LIST_DIR}/../dosbox/3rdparty/SDL_sound/src" to include_directories
7. Edit native\dosbox-jsdos\dosbox-jsdos.cmake
Add following lines(or other c files depand on formats you want):
set(SOURCES_JSDOS_SDL_SOUND
${CMAKE_CURRENT_LIST_DIR}/../dosbox/3rdparty/SDL_sound/src/SDL_sound.c
${CMAKE_CURRENT_LIST_DIR}/../dosbox/3rdparty/SDL_sound/src/SDL_sound_vorbis.c
)
Modify SOURCES_SERVER_CORE to add SDL_sound files:
set(SOURCES_SERVER_CORE ${SOURCES_JSDOS_SDL_SOUND} ${SOURCES_CORE_CXX11} ${SOURCES_CORE_CXX03})
8. Edit src\dos\dosbox\dosbox.cmake add -sUSE_SDL=2 for SDL2 support:
set_target_properties(wdosbox PROPERTIES LINK_FLAGS "${WORKER_LINK_FLAGS} -sUSE_SDL=2 -s WASM=1 -s ASYNCIFY=1 -s 'ASYNCIFY_IMPORTS=[\"syncSleep\"]' -s ASYNCIFY_WHITELIST=@${CMAKE_CURRENT_LIST_DIR}/../../../native/dosbox-jsdos/asyncify.txt -s EXPORT_NAME='WDOSBOX'")
set_target_properties(wdosbox.shared PROPERTIES LINK_FLAGS "${WORKER_LINK_FLAGS} -sSHARED_MEMORY=1 -sUSE_SDL=2 -Wl,--shared-memory,--no-check-features -sUSE_PTHREADS=1 -s WASM=1 -s ASYNCIFY=1 -s 'ASYNCIFY_IMPORTS=[\"syncSleep\"]' -s ASYNCIFY_WHITELIST=@${CMAKE_CURRENT_LIST_DIR}/../../../native/dosbox-jsdos/asyncify.txt -s EXPORT_NAME='WDOSBOX'")