2023-10-26 09:46:22 +00:00
|
|
|
package funkin.ui.debug.charting.handlers;
|
2023-09-26 03:24:07 +00:00
|
|
|
|
|
|
|
import flixel.system.FlxAssets.FlxSoundAsset;
|
2024-02-06 00:46:11 +00:00
|
|
|
import flixel.sound.FlxSound;
|
2023-10-17 04:38:28 +00:00
|
|
|
import funkin.audio.VoicesGroup;
|
2023-12-06 20:04:24 +00:00
|
|
|
import funkin.audio.FunkinSound;
|
2023-10-17 04:38:28 +00:00
|
|
|
import funkin.play.character.BaseCharacter.CharacterType;
|
|
|
|
import funkin.util.FileUtil;
|
2023-10-26 09:46:22 +00:00
|
|
|
import funkin.util.assets.SoundUtil;
|
2024-01-24 04:24:05 +00:00
|
|
|
import funkin.audio.waveform.WaveformData;
|
|
|
|
import funkin.audio.waveform.WaveformDataParser;
|
|
|
|
import funkin.audio.waveform.WaveformSprite;
|
|
|
|
import flixel.util.FlxColor;
|
2023-10-17 04:38:28 +00:00
|
|
|
import haxe.io.Bytes;
|
2023-09-26 03:24:07 +00:00
|
|
|
import haxe.io.Path;
|
2023-10-17 04:38:28 +00:00
|
|
|
import openfl.utils.Assets;
|
2023-09-26 03:24:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions for loading audio for the chart editor.
|
2023-10-26 09:46:22 +00:00
|
|
|
* Handlers split up the functionality of the Chart Editor into different classes based on focus to limit the amount of code in each class.
|
2023-09-26 03:24:07 +00:00
|
|
|
*/
|
|
|
|
@:nullSafety
|
2023-10-26 09:46:22 +00:00
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
2023-09-26 03:24:07 +00:00
|
|
|
class ChartEditorAudioHandler
|
|
|
|
{
|
|
|
|
/**
|
2023-10-17 04:38:28 +00:00
|
|
|
* Loads and stores byte data for a vocal track from an absolute file path
|
|
|
|
*
|
2023-09-26 03:24:07 +00:00
|
|
|
* @param path The absolute path to the audio file.
|
2023-10-17 04:38:28 +00:00
|
|
|
* @param charId The character this vocal track will be for.
|
|
|
|
* @param instId The instrumental this vocal track will be for.
|
2023-09-26 03:24:07 +00:00
|
|
|
* @return Success or failure.
|
|
|
|
*/
|
2023-12-19 06:26:26 +00:00
|
|
|
public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
|
|
|
#if sys
|
2023-10-17 04:38:28 +00:00
|
|
|
var fileBytes:Bytes = sys.io.File.getBytes(path.toString());
|
2023-12-19 06:26:26 +00:00
|
|
|
return loadVocalsFromBytes(state, fileBytes, charId, instId, wipeFirst);
|
2023-09-26 03:24:07 +00:00
|
|
|
#else
|
|
|
|
trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way.");
|
|
|
|
return false;
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-17 04:38:28 +00:00
|
|
|
* Loads and stores byte data for a vocal track from an asset
|
2023-09-26 03:24:07 +00:00
|
|
|
*
|
2023-10-17 04:38:28 +00:00
|
|
|
* @param path The path to the asset. Use `Paths` to build this.
|
|
|
|
* @param charId The character this vocal track will be for.
|
|
|
|
* @param instId The instrumental this vocal track will be for.
|
2023-09-26 03:24:07 +00:00
|
|
|
* @return Success or failure.
|
|
|
|
*/
|
2023-12-19 06:26:26 +00:00
|
|
|
public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
var trackData:Null<Bytes> = Assets.getBytes(path);
|
|
|
|
if (trackData != null)
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
2023-12-19 06:26:26 +00:00
|
|
|
return loadVocalsFromBytes(state, trackData, charId, instId, wipeFirst);
|
2023-09-26 03:24:07 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-17 04:38:28 +00:00
|
|
|
* Loads and stores byte data for a vocal track
|
|
|
|
*
|
|
|
|
* @param bytes The audio byte data.
|
|
|
|
* @param charId The character this vocal track will be for.
|
|
|
|
* @param instId The instrumental this vocal track will be for.
|
2023-12-19 06:26:26 +00:00
|
|
|
* @param wipeFirst Whether to wipe the existing vocal data before loading.
|
2023-09-26 03:24:07 +00:00
|
|
|
*/
|
2023-12-19 06:26:26 +00:00
|
|
|
public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}';
|
2023-12-19 06:26:26 +00:00
|
|
|
if (wipeFirst) wipeVocalData(state);
|
2023-10-17 04:38:28 +00:00
|
|
|
state.audioVocalTrackData.set(trackId, bytes);
|
2023-09-26 03:24:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-17 04:38:28 +00:00
|
|
|
* Loads and stores byte data for an instrumental track from an absolute file path
|
2023-09-26 03:24:07 +00:00
|
|
|
*
|
|
|
|
* @param path The absolute path to the audio file.
|
2023-10-17 04:38:28 +00:00
|
|
|
* @param instId The instrumental this vocal track will be for.
|
2023-09-26 03:24:07 +00:00
|
|
|
* @return Success or failure.
|
|
|
|
*/
|
2023-12-19 06:26:26 +00:00
|
|
|
public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = '', wipeFirst:Bool = false):Bool
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
|
|
|
#if sys
|
2023-10-17 04:38:28 +00:00
|
|
|
var fileBytes:Bytes = sys.io.File.getBytes(path.toString());
|
2023-12-19 06:26:26 +00:00
|
|
|
return loadInstFromBytes(state, fileBytes, instId, wipeFirst);
|
2023-09-26 03:24:07 +00:00
|
|
|
#else
|
|
|
|
trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way.");
|
|
|
|
return false;
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-17 04:38:28 +00:00
|
|
|
* Loads and stores byte data for an instrumental track from an asset
|
|
|
|
*
|
|
|
|
* @param path The path to the asset. Use `Paths` to build this.
|
|
|
|
* @param instId The instrumental this vocal track will be for.
|
2023-09-26 03:24:07 +00:00
|
|
|
* @return Success or failure.
|
|
|
|
*/
|
2023-12-19 06:26:26 +00:00
|
|
|
public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = '', wipeFirst:Bool = false):Bool
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
var trackData:Null<Bytes> = Assets.getBytes(path);
|
|
|
|
if (trackData != null)
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
2023-12-19 06:26:26 +00:00
|
|
|
return loadInstFromBytes(state, trackData, instId, wipeFirst);
|
2023-09-26 03:24:07 +00:00
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
/**
|
|
|
|
* Loads and stores byte data for a vocal track
|
|
|
|
*
|
|
|
|
* @param bytes The audio byte data.
|
|
|
|
* @param charId The character this vocal track will be for.
|
|
|
|
* @param instId The instrumental this vocal track will be for.
|
|
|
|
*/
|
2023-12-19 06:26:26 +00:00
|
|
|
public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = '', wipeFirst:Bool = false):Bool
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
|
|
|
if (instId == '') instId = 'default';
|
2023-12-19 06:26:26 +00:00
|
|
|
if (wipeFirst) wipeInstrumentalData(state);
|
2023-10-17 04:38:28 +00:00
|
|
|
state.audioInstTrackData.set(instId, bytes);
|
|
|
|
return true;
|
|
|
|
}
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
public static function switchToInstrumental(state:ChartEditorState, instId:String = '', playerId:String, opponentId:String):Bool
|
|
|
|
{
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfA = haxe.Timer.stamp();
|
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
var result:Bool = playInstrumental(state, instId);
|
|
|
|
if (!result) return false;
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfB = haxe.Timer.stamp();
|
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
stopExistingVocals(state);
|
2024-02-09 19:58:57 +00:00
|
|
|
|
|
|
|
var perfC = haxe.Timer.stamp();
|
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
result = playVocals(state, BF, playerId, instId);
|
2024-02-09 19:58:57 +00:00
|
|
|
|
|
|
|
var perfD = haxe.Timer.stamp();
|
|
|
|
|
2023-12-19 06:26:26 +00:00
|
|
|
// if (!result) return false;
|
2023-10-17 04:38:28 +00:00
|
|
|
result = playVocals(state, DAD, opponentId, instId);
|
2023-12-19 06:26:26 +00:00
|
|
|
// if (!result) return false;
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfE = haxe.Timer.stamp();
|
|
|
|
|
2024-02-03 02:53:45 +00:00
|
|
|
state.hardRefreshOffsetsToolbox();
|
|
|
|
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfF = haxe.Timer.stamp();
|
|
|
|
|
|
|
|
state.hardRefreshFreeplayToolbox();
|
|
|
|
|
|
|
|
var perfG = haxe.Timer.stamp();
|
|
|
|
|
|
|
|
trace('Switched to instrumental in ${perfB - perfA} seconds.');
|
|
|
|
trace('Stopped existing vocals in ${perfC - perfB} seconds.');
|
|
|
|
trace('Played BF vocals in ${perfD - perfC} seconds.');
|
|
|
|
trace('Played DAD vocals in ${perfE - perfD} seconds.');
|
|
|
|
trace('Hard refreshed offsets toolbox in ${perfF - perfE} seconds.');
|
|
|
|
trace('Hard refreshed freeplay toolbox in ${perfG - perfF} seconds.');
|
|
|
|
|
2023-09-26 03:24:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-17 04:38:28 +00:00
|
|
|
* Tell the Chart Editor to select a specific instrumental track, that is already loaded.
|
2023-09-26 03:24:07 +00:00
|
|
|
*/
|
2023-10-26 09:46:22 +00:00
|
|
|
public static function playInstrumental(state:ChartEditorState, instId:String = ''):Bool
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
if (instId == '') instId = 'default';
|
|
|
|
var instTrackData:Null<Bytes> = state.audioInstTrackData.get(instId);
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfA = haxe.Timer.stamp();
|
2023-12-08 06:15:22 +00:00
|
|
|
var instTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(instTrackData);
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfB = haxe.Timer.stamp();
|
|
|
|
trace('Built instrumental track in ${perfB - perfA} seconds.');
|
2023-10-17 04:38:28 +00:00
|
|
|
if (instTrack == null) return false;
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
stopExistingInstrumental(state);
|
|
|
|
state.audioInstTrack = instTrack;
|
|
|
|
state.postLoadInstrumental();
|
2023-12-08 06:15:22 +00:00
|
|
|
// Workaround for a bug where FlxG.sound.music.update() was being called twice.
|
|
|
|
FlxG.sound.list.remove(instTrack);
|
2023-10-17 04:38:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
public static function stopExistingInstrumental(state:ChartEditorState):Void
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
|
|
|
if (state.audioInstTrack != null)
|
|
|
|
{
|
|
|
|
state.audioInstTrack.stop();
|
|
|
|
state.audioInstTrack.destroy();
|
|
|
|
state.audioInstTrack = null;
|
2023-09-26 03:24:07 +00:00
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tell the Chart Editor to select a specific vocal track, that is already loaded.
|
|
|
|
*/
|
2023-10-26 09:46:22 +00:00
|
|
|
public static function playVocals(state:ChartEditorState, charType:CharacterType, charId:String, instId:String = ''):Bool
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
|
|
|
var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}';
|
|
|
|
var vocalTrackData:Null<Bytes> = state.audioVocalTrackData.get(trackId);
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfStart = haxe.Timer.stamp();
|
2023-12-06 20:04:24 +00:00
|
|
|
var vocalTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(vocalTrackData);
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfEnd = haxe.Timer.stamp();
|
|
|
|
trace('Built vocal track in ${perfEnd - perfStart} seconds.');
|
2023-09-26 03:24:07 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
if (state.audioVocalTrackGroup == null) state.audioVocalTrackGroup = new VoicesGroup();
|
|
|
|
|
|
|
|
if (vocalTrack != null)
|
|
|
|
{
|
|
|
|
switch (charType)
|
|
|
|
{
|
|
|
|
case BF:
|
|
|
|
state.audioVocalTrackGroup.addPlayerVoice(vocalTrack);
|
2024-01-24 04:24:05 +00:00
|
|
|
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfStart = haxe.Timer.stamp();
|
|
|
|
var waveformData:Null<WaveformData> = vocalTrack.waveformData;
|
|
|
|
var perfEnd = haxe.Timer.stamp();
|
|
|
|
trace('Interpreted waveform data in ${perfEnd - perfStart} seconds.');
|
|
|
|
|
2024-01-24 04:24:05 +00:00
|
|
|
if (waveformData != null)
|
|
|
|
{
|
|
|
|
var duration:Float = Conductor.instance.getStepTimeInMs(16) * 0.001;
|
|
|
|
var waveformSprite:WaveformSprite = new WaveformSprite(waveformData, VERTICAL, FlxColor.WHITE);
|
|
|
|
waveformSprite.x = 840;
|
|
|
|
waveformSprite.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
|
|
|
waveformSprite.height = (ChartEditorState.GRID_SIZE) * 16;
|
|
|
|
waveformSprite.width = (ChartEditorState.GRID_SIZE) * 2;
|
|
|
|
waveformSprite.time = 0;
|
|
|
|
waveformSprite.duration = duration;
|
|
|
|
state.audioWaveforms.add(waveformSprite);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('[WARN] Failed to parse waveform data for vocal track.');
|
|
|
|
}
|
2023-12-09 00:28:16 +00:00
|
|
|
|
2024-01-27 08:24:49 +00:00
|
|
|
state.audioVocalTrackGroup.playerVoicesOffset = state.currentVocalOffsetPlayer;
|
2023-10-17 04:38:28 +00:00
|
|
|
return true;
|
|
|
|
case DAD:
|
|
|
|
state.audioVocalTrackGroup.addOpponentVoice(vocalTrack);
|
2023-12-08 23:44:45 +00:00
|
|
|
|
2024-02-09 19:58:57 +00:00
|
|
|
var perfStart = haxe.Timer.stamp();
|
|
|
|
var waveformData:Null<WaveformData> = vocalTrack.waveformData;
|
|
|
|
var perfEnd = haxe.Timer.stamp();
|
|
|
|
trace('Interpreted waveform data in ${perfEnd - perfStart} seconds.');
|
|
|
|
|
2024-01-24 04:24:05 +00:00
|
|
|
if (waveformData != null)
|
|
|
|
{
|
|
|
|
var duration:Float = Conductor.instance.getStepTimeInMs(16) * 0.001;
|
|
|
|
var waveformSprite:WaveformSprite = new WaveformSprite(waveformData, VERTICAL, FlxColor.WHITE);
|
|
|
|
waveformSprite.x = 360;
|
|
|
|
waveformSprite.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
|
|
|
waveformSprite.height = (ChartEditorState.GRID_SIZE) * 16;
|
|
|
|
waveformSprite.width = (ChartEditorState.GRID_SIZE) * 2;
|
|
|
|
waveformSprite.time = 0;
|
|
|
|
waveformSprite.duration = duration;
|
|
|
|
state.audioWaveforms.add(waveformSprite);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('[WARN] Failed to parse waveform data for vocal track.');
|
|
|
|
}
|
2023-12-08 23:44:45 +00:00
|
|
|
|
2024-01-27 08:24:49 +00:00
|
|
|
state.audioVocalTrackGroup.opponentVoicesOffset = state.currentVocalOffsetOpponent;
|
2023-12-09 00:28:16 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
return true;
|
|
|
|
case OTHER:
|
|
|
|
state.audioVocalTrackGroup.add(vocalTrack);
|
2023-12-08 06:15:22 +00:00
|
|
|
// TODO: Add offset for other characters.
|
2023-10-17 04:38:28 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
}
|
2023-12-08 06:15:22 +00:00
|
|
|
|
2023-09-26 03:24:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
public static function stopExistingVocals(state:ChartEditorState):Void
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
2024-02-03 02:53:45 +00:00
|
|
|
state.audioVocalTrackGroup.clear();
|
2024-01-27 08:24:49 +00:00
|
|
|
if (state.audioWaveforms != null)
|
2024-01-19 03:28:25 +00:00
|
|
|
{
|
2024-01-27 08:24:49 +00:00
|
|
|
state.audioWaveforms.clear();
|
2024-01-19 03:28:25 +00:00
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
}
|
|
|
|
|
2023-09-26 03:24:07 +00:00
|
|
|
/**
|
|
|
|
* Play a sound effect.
|
|
|
|
* Automatically cleans up after itself and recycles previous FlxSound instances if available, for performance.
|
2023-10-17 04:38:28 +00:00
|
|
|
* @param path The path to the sound effect. Use `Paths` to build this.
|
2023-09-26 03:24:07 +00:00
|
|
|
*/
|
2023-12-01 22:14:48 +00:00
|
|
|
public static function playSound(_state:ChartEditorState, path:String, volume:Float = 1.0):Void
|
2023-09-26 03:24:07 +00:00
|
|
|
{
|
|
|
|
var snd:FlxSound = FlxG.sound.list.recycle(FlxSound) ?? new FlxSound();
|
|
|
|
var asset:Null<FlxSoundAsset> = FlxG.sound.cache(path);
|
|
|
|
if (asset == null)
|
|
|
|
{
|
|
|
|
trace('WARN: Failed to play sound $path, asset not found.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
snd.loadEmbedded(asset);
|
|
|
|
snd.autoDestroy = true;
|
|
|
|
FlxG.sound.list.add(snd);
|
2023-12-01 22:14:48 +00:00
|
|
|
snd.volume = volume;
|
2023-09-26 03:24:07 +00:00
|
|
|
snd.play();
|
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
|
2023-10-24 19:50:02 +00:00
|
|
|
public static function wipeInstrumentalData(state:ChartEditorState):Void
|
|
|
|
{
|
|
|
|
state.audioInstTrackData.clear();
|
|
|
|
stopExistingInstrumental(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function wipeVocalData(state:ChartEditorState):Void
|
|
|
|
{
|
|
|
|
state.audioVocalTrackData.clear();
|
|
|
|
stopExistingVocals(state);
|
|
|
|
}
|
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
/**
|
2023-10-26 09:46:22 +00:00
|
|
|
* Create a list of ZIP file entries from the current loaded instrumental tracks in the chart eidtor.
|
|
|
|
* @param state The chart editor state.
|
|
|
|
* @return `Array<haxe.zip.Entry>`
|
2023-10-17 04:38:28 +00:00
|
|
|
*/
|
2023-10-26 09:46:22 +00:00
|
|
|
public static function makeZIPEntriesFromInstrumentals(state:ChartEditorState):Array<haxe.zip.Entry>
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
|
|
|
var zipEntries = [];
|
|
|
|
|
2023-10-24 19:50:02 +00:00
|
|
|
var instTrackIds = state.audioInstTrackData.keys().array();
|
|
|
|
for (key in instTrackIds)
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
|
|
|
if (key == 'default')
|
|
|
|
{
|
|
|
|
var data:Null<Bytes> = state.audioInstTrackData.get('default');
|
2023-10-24 19:50:02 +00:00
|
|
|
if (data == null)
|
|
|
|
{
|
|
|
|
trace('[WARN] Failed to access inst track ($key)');
|
|
|
|
continue;
|
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
zipEntries.push(FileUtil.makeZIPEntryFromBytes('Inst.ogg', data));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var data:Null<Bytes> = state.audioInstTrackData.get(key);
|
2023-10-24 19:50:02 +00:00
|
|
|
if (data == null)
|
|
|
|
{
|
|
|
|
trace('[WARN] Failed to access inst track ($key)');
|
|
|
|
continue;
|
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
zipEntries.push(FileUtil.makeZIPEntryFromBytes('Inst-${key}.ogg', data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return zipEntries;
|
|
|
|
}
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
/**
|
|
|
|
* Create a list of ZIP file entries from the current loaded vocal tracks in the chart eidtor.
|
|
|
|
* @param state The chart editor state.
|
|
|
|
* @return `Array<haxe.zip.Entry>`
|
|
|
|
*/
|
|
|
|
public static function makeZIPEntriesFromVocals(state:ChartEditorState):Array<haxe.zip.Entry>
|
2023-10-17 04:38:28 +00:00
|
|
|
{
|
|
|
|
var zipEntries = [];
|
|
|
|
|
2023-10-24 19:50:02 +00:00
|
|
|
var vocalTrackIds = state.audioVocalTrackData.keys().array();
|
2023-10-17 04:38:28 +00:00
|
|
|
for (key in state.audioVocalTrackData.keys())
|
|
|
|
{
|
|
|
|
var data:Null<Bytes> = state.audioVocalTrackData.get(key);
|
2023-10-24 19:50:02 +00:00
|
|
|
if (data == null)
|
|
|
|
{
|
|
|
|
trace('[WARN] Failed to access vocal track ($key)');
|
|
|
|
continue;
|
|
|
|
}
|
2023-10-21 05:04:50 +00:00
|
|
|
zipEntries.push(FileUtil.makeZIPEntryFromBytes('Voices-${key}.ogg', data));
|
2023-10-17 04:38:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return zipEntries;
|
|
|
|
}
|
2023-09-26 03:24:07 +00:00
|
|
|
}
|