mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-06-03 00:58:13 -04:00
change Audio related code
This commit is contained in:
parent
d0486d855a
commit
9d505c8900
@ -1666,10 +1666,7 @@ namespace Unity_Studio
|
|||||||
result = FMOD.Factory.System_Create(out system);
|
result = FMOD.Factory.System_Create(out system);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
result = system.setOutput(FMOD.OUTPUTTYPE.NOSOUND_NRT);
|
result = system.init(1, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
|
||||||
|
|
||||||
result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
|
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
exinfo.cbsize = Marshal.SizeOf(exinfo);
|
exinfo.cbsize = Marshal.SizeOf(exinfo);
|
||||||
@ -1678,22 +1675,21 @@ namespace Unity_Studio
|
|||||||
result = system.createSound(m_AudioClip.m_AudioData, FMOD.MODE.OPENMEMORY, ref exinfo, out sound);
|
result = system.createSound(m_AudioClip.m_AudioData, FMOD.MODE.OPENMEMORY, ref exinfo, out sound);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
result = sound.getSubSound(0, out sound);
|
result = sound.getSubSound(0, out var subsound);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
result = sound.setMode(FMOD.MODE.LOOP_OFF);
|
result = subsound.getFormat(out var type, out var format, out int NumChannels, out int BitsPerSample);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
result = sound.setLoopCount(-1);
|
result = subsound.getDefaults(out var frequency, out int priority);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
uint length;
|
var SampleRate = (int)frequency;
|
||||||
result = sound.getLength(out length, FMOD.TIMEUNIT.PCMBYTES);
|
|
||||||
|
result = subsound.getLength(out var length, FMOD.TIMEUNIT.PCMBYTES);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
IntPtr ptr1, ptr2;
|
result = subsound.@lock(0, length, out var ptr1, out var ptr2, out var len1, out var len2);
|
||||||
uint len1, len2;
|
|
||||||
result = sound.@lock(0, length, out ptr1, out ptr2, out len1, out len2);
|
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
byte[] buffer = new byte[len1 + 44];
|
byte[] buffer = new byte[len1 + 44];
|
||||||
@ -1703,19 +1699,20 @@ namespace Unity_Studio
|
|||||||
Encoding.UTF8.GetBytes("WAVEfmt ").CopyTo(buffer, 8);
|
Encoding.UTF8.GetBytes("WAVEfmt ").CopyTo(buffer, 8);
|
||||||
BitConverter.GetBytes(16).CopyTo(buffer, 16);
|
BitConverter.GetBytes(16).CopyTo(buffer, 16);
|
||||||
BitConverter.GetBytes((short)1).CopyTo(buffer, 20);
|
BitConverter.GetBytes((short)1).CopyTo(buffer, 20);
|
||||||
BitConverter.GetBytes((short)m_AudioClip.m_Channels).CopyTo(buffer, 22);
|
BitConverter.GetBytes((short)NumChannels).CopyTo(buffer, 22);
|
||||||
BitConverter.GetBytes(m_AudioClip.m_Frequency).CopyTo(buffer, 24);
|
BitConverter.GetBytes(SampleRate).CopyTo(buffer, 24);
|
||||||
BitConverter.GetBytes(m_AudioClip.m_Frequency * m_AudioClip.m_Channels * m_AudioClip.m_BitsPerSample / 8).CopyTo(buffer, 28);
|
BitConverter.GetBytes(SampleRate * NumChannels * BitsPerSample / 8).CopyTo(buffer, 28);
|
||||||
BitConverter.GetBytes((short)(m_AudioClip.m_Channels * m_AudioClip.m_BitsPerSample / 8)).CopyTo(buffer, 32);
|
BitConverter.GetBytes((short)(NumChannels * BitsPerSample / 8)).CopyTo(buffer, 32);
|
||||||
BitConverter.GetBytes((short)m_AudioClip.m_BitsPerSample).CopyTo(buffer, 34);
|
BitConverter.GetBytes((short)BitsPerSample).CopyTo(buffer, 34);
|
||||||
Encoding.UTF8.GetBytes("data").CopyTo(buffer, 36);
|
Encoding.UTF8.GetBytes("data").CopyTo(buffer, 36);
|
||||||
BitConverter.GetBytes(len1).CopyTo(buffer, 40);
|
BitConverter.GetBytes(len1).CopyTo(buffer, 40);
|
||||||
Marshal.Copy(ptr1, buffer, 44, (int)len1);
|
Marshal.Copy(ptr1, buffer, 44, (int)len1);
|
||||||
File.WriteAllBytes(exportFullname, buffer);
|
File.WriteAllBytes(exportFullname, buffer);
|
||||||
|
|
||||||
result = sound.unlock(ptr1, ptr2, len1, len2);
|
result = subsound.unlock(ptr1, ptr2, len1, len2);
|
||||||
if (result != FMOD.RESULT.OK) { return false; }
|
if (result != FMOD.RESULT.OK) { return false; }
|
||||||
|
|
||||||
|
subsound.release();
|
||||||
sound.release();
|
sound.release();
|
||||||
system.release();
|
system.release();
|
||||||
}
|
}
|
||||||
|
9
Unity Studio/UnityStudioForm.Designer.cs
generated
9
Unity Studio/UnityStudioForm.Designer.cs
generated
@ -591,6 +591,7 @@
|
|||||||
//
|
//
|
||||||
// FMODinfoLabel
|
// FMODinfoLabel
|
||||||
//
|
//
|
||||||
|
this.FMODinfoLabel.AutoSize = true;
|
||||||
this.FMODinfoLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
this.FMODinfoLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
this.FMODinfoLabel.Location = new System.Drawing.Point(305, 271);
|
this.FMODinfoLabel.Location = new System.Drawing.Point(305, 271);
|
||||||
this.FMODinfoLabel.Name = "FMODinfoLabel";
|
this.FMODinfoLabel.Name = "FMODinfoLabel";
|
||||||
@ -600,9 +601,9 @@
|
|||||||
// FMODtimerLabel
|
// FMODtimerLabel
|
||||||
//
|
//
|
||||||
this.FMODtimerLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
this.FMODtimerLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
this.FMODtimerLabel.Location = new System.Drawing.Point(435, 271);
|
this.FMODtimerLabel.Location = new System.Drawing.Point(440, 271);
|
||||||
this.FMODtimerLabel.Name = "FMODtimerLabel";
|
this.FMODtimerLabel.Name = "FMODtimerLabel";
|
||||||
this.FMODtimerLabel.Size = new System.Drawing.Size(158, 13);
|
this.FMODtimerLabel.Size = new System.Drawing.Size(155, 13);
|
||||||
this.FMODtimerLabel.TabIndex = 7;
|
this.FMODtimerLabel.TabIndex = 7;
|
||||||
this.FMODtimerLabel.Text = "0:00.0 / 0:00.0";
|
this.FMODtimerLabel.Text = "0:00.0 / 0:00.0";
|
||||||
this.FMODtimerLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
this.FMODtimerLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||||
@ -619,10 +620,10 @@
|
|||||||
// FMODprogressBar
|
// FMODprogressBar
|
||||||
//
|
//
|
||||||
this.FMODprogressBar.AutoSize = false;
|
this.FMODprogressBar.AutoSize = false;
|
||||||
this.FMODprogressBar.Location = new System.Drawing.Point(252, 290);
|
this.FMODprogressBar.Location = new System.Drawing.Point(249, 290);
|
||||||
this.FMODprogressBar.Maximum = 1000;
|
this.FMODprogressBar.Maximum = 1000;
|
||||||
this.FMODprogressBar.Name = "FMODprogressBar";
|
this.FMODprogressBar.Name = "FMODprogressBar";
|
||||||
this.FMODprogressBar.Size = new System.Drawing.Size(348, 24);
|
this.FMODprogressBar.Size = new System.Drawing.Size(350, 24);
|
||||||
this.FMODprogressBar.TabIndex = 5;
|
this.FMODprogressBar.TabIndex = 5;
|
||||||
this.FMODprogressBar.TickStyle = System.Windows.Forms.TickStyle.None;
|
this.FMODprogressBar.TickStyle = System.Windows.Forms.TickStyle.None;
|
||||||
this.FMODprogressBar.Scroll += new System.EventHandler(this.FMODprogressBar_Scroll);
|
this.FMODprogressBar.Scroll += new System.EventHandler(this.FMODprogressBar_Scroll);
|
||||||
|
@ -1131,7 +1131,7 @@ namespace Unity_Studio
|
|||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
|
result = system.init(1, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
|
||||||
if (ERRCHECK(result)) { return; }
|
if (ERRCHECK(result)) { return; }
|
||||||
|
|
||||||
//result = system.getMasterChannelGroup(out channelGroup);
|
//result = system.getMasterChannelGroup(out channelGroup);
|
||||||
@ -1155,7 +1155,7 @@ namespace Unity_Studio
|
|||||||
if (sound != null)
|
if (sound != null)
|
||||||
{
|
{
|
||||||
var result = sound.release();
|
var result = sound.release();
|
||||||
if (result != FMOD.RESULT.OK) { StatusStripUpdate("FMOD error! " + result + " - " + FMOD.Error.String(result)); }
|
ERRCHECK(result);
|
||||||
sound = null;
|
sound = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user