added snes_spc library
This commit is contained in:
@@ -53,6 +53,7 @@ add_executable(
|
||||
${YAZE_APP_ZELDA3_SRC}
|
||||
${YAZE_GUI_SRC}
|
||||
${ASAR_STATIC_SRC}
|
||||
${SNES_SPC_SOURCES}
|
||||
${IMGUI_SRC}
|
||||
)
|
||||
|
||||
@@ -67,6 +68,7 @@ target_include_directories(
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${GLEW_INCLUDE_DIRS}
|
||||
lib/asar/src/asar/
|
||||
lib/snes_spc/snes_spc/
|
||||
)
|
||||
|
||||
set(SDL_TARGETS SDL2::SDL2)
|
||||
@@ -87,6 +89,7 @@ target_link_libraries(
|
||||
${OPENGL_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
asar-static
|
||||
snes_spc
|
||||
ImGui
|
||||
)
|
||||
|
||||
|
||||
@@ -1,13 +1,68 @@
|
||||
#include "music_editor.h"
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/assembly_editor.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "imgui.h"
|
||||
#include "snes_spc/demo/demo_util.h"
|
||||
#include "snes_spc/demo/wave_writer.h"
|
||||
#include "snes_spc/snes_spc/spc.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
namespace {
|
||||
|
||||
void PlaySPC() {
|
||||
/* Create emulator and filter */
|
||||
SNES_SPC* snes_spc = spc_new();
|
||||
SPC_Filter* filter = spc_filter_new();
|
||||
if (!snes_spc || !filter) error("Out of memory");
|
||||
|
||||
/* Load SPC */
|
||||
{
|
||||
/* Load file into memory */
|
||||
long spc_size;
|
||||
void* spc = load_file("assets/music/hyrule_field.spc", &spc_size);
|
||||
|
||||
/* Load SPC data into emulator */
|
||||
error(spc_load_spc(snes_spc, spc, spc_size));
|
||||
free(spc); /* emulator makes copy of data */
|
||||
|
||||
/* Most SPC files have garbage data in the echo buffer, so clear that */
|
||||
spc_clear_echo(snes_spc);
|
||||
|
||||
/* Clear filter before playing */
|
||||
spc_filter_clear(filter);
|
||||
}
|
||||
|
||||
/* Record 20 seconds to wave file */
|
||||
wave_open(spc_sample_rate, "out.wav");
|
||||
wave_enable_stereo();
|
||||
while (wave_sample_count() < 20 * spc_sample_rate * 2) {
|
||||
/* Play into buffer */
|
||||
#define BUF_SIZE 2048
|
||||
short buf[BUF_SIZE];
|
||||
error(spc_play(snes_spc, BUF_SIZE, buf));
|
||||
|
||||
/* Filter samples */
|
||||
spc_filter_run(filter, buf, BUF_SIZE);
|
||||
|
||||
wave_write(buf, BUF_SIZE);
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
spc_filter_delete(filter);
|
||||
spc_delete(snes_spc);
|
||||
wave_close();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void MusicEditor::Update() {
|
||||
if (ImGui::BeginTable("MusicEditorColumns", 2, music_editor_flags_,
|
||||
ImVec2(0, 0))) {
|
||||
@@ -162,6 +217,12 @@ void MusicEditor::DrawToolset() {
|
||||
static int selected_option = 0;
|
||||
static int current_volume = 0;
|
||||
const int MAX_VOLUME = 100;
|
||||
|
||||
|
||||
if (is_playing) {
|
||||
PlaySPC();
|
||||
}
|
||||
|
||||
gui::ItemLabel("Select a song to edit: ", gui::ItemLabelFlags::Left);
|
||||
ImGui::Combo("#songs_in_game", &selected_option, kGameSongs, 30);
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "snes_spc/demo/demo_util.h"
|
||||
#include "snes_spc/demo/wave_writer.h"
|
||||
#include "snes_spc/snes_spc/spc.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -479,6 +479,7 @@ absl::StatusOr<Bytes> ROM::Compress(const int start, const int length, int mode,
|
||||
absl::StatusOr<Bytes> ROM::CompressGraphics(const int pos, const int length) {
|
||||
return Compress(pos, length, kNintendoMode2);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> ROM::CompressOverworld(const int pos, const int length) {
|
||||
return Compress(pos, length, kNintendoMode1);
|
||||
}
|
||||
|
||||
26
src/app/spc700/spc700.def
Normal file
26
src/app/spc700/spc700.def
Normal file
@@ -0,0 +1,26 @@
|
||||
LIBRARY snes_spc
|
||||
DESCRIPTION "snes_spc 0.9.0"
|
||||
EXPORTS
|
||||
spc_new @1
|
||||
spc_delete @2
|
||||
spc_init_rom @3
|
||||
spc_set_output @4
|
||||
spc_sample_count @5
|
||||
spc_reset @6
|
||||
spc_soft_reset @7
|
||||
spc_read_port @8
|
||||
spc_write_port @9
|
||||
spc_end_frame @10
|
||||
spc_mute_voices @11
|
||||
spc_disable_surround @12
|
||||
spc_set_tempo @13
|
||||
spc_load_spc @14
|
||||
spc_clear_echo @15
|
||||
spc_play @16
|
||||
spc_skip @17
|
||||
spc_filter_new @18
|
||||
spc_filter_delete @19
|
||||
spc_filter_run @20
|
||||
spc_filter_clear @21
|
||||
spc_filter_set_gain @22
|
||||
spc_filter_set_bass @23
|
||||
Submodule src/lib/snes-spc-arm deleted from 609c02b008
Reference in New Issue
Block a user