mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
Small fixes and additions
Fixed mesh name exporting for assimp. Fixed clearing models for bfres. Fixed limit skin count setting. Fixed material index breaking if a material is removed for bfres. Update the vertex data properly if a model is imported as new. Added AMTA editing for BARS. Added audio player for BARS.
This commit is contained in:
parent
419164c855
commit
e531a779ed
26 changed files with 1323 additions and 92 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
using Switch_Toolbox.Library.IO;
|
||||
using Switch_Toolbox.Library.Forms;
|
||||
using BarsLib;
|
||||
using VGAudio.Formats;
|
||||
using VGAudio;
|
||||
|
@ -43,6 +44,32 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeview)
|
||||
{
|
||||
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
|
||||
if (editor == null)
|
||||
{
|
||||
editor = new STPropertyGrid();
|
||||
LibraryGUI.Instance.LoadEditor(editor);
|
||||
}
|
||||
|
||||
var prop = new BarsProperty(bars);
|
||||
|
||||
editor.Text = Text;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
editor.LoadProperty(prop, null);
|
||||
}
|
||||
|
||||
public class BarsProperty
|
||||
{
|
||||
public int AudioCount { get; private set; }
|
||||
|
||||
public BarsProperty(BarsLib.BARS bars)
|
||||
{
|
||||
AudioCount = bars.AmtaList.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public class AudioEntry : TreeNodeCustom
|
||||
{
|
||||
public AudioType Type;
|
||||
|
@ -121,19 +148,75 @@ namespace FirstPlugin
|
|||
}
|
||||
public void UpdateEditor()
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case AudioType.Bfwav:
|
||||
// ShowHexView();
|
||||
ShowBfwavPlayer();
|
||||
break;
|
||||
default:
|
||||
ShowHexView();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowBfwavPlayer()
|
||||
{
|
||||
var audioFile = new VGAdudioFile();
|
||||
audioFile.LoadAudio(new MemoryStream(Data), new BFWAV());
|
||||
|
||||
AudioPlayerPanel editor = (AudioPlayerPanel)LibraryGUI.Instance.GetActiveContent(typeof(AudioPlayerPanel));
|
||||
if (editor == null)
|
||||
{
|
||||
editor = new AudioPlayerPanel();
|
||||
LibraryGUI.Instance.LoadEditor(editor);
|
||||
}
|
||||
editor.Text = Text;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
editor.LoadFile(audioFile.audioData, new BFWAV(), true);
|
||||
}
|
||||
|
||||
private void ShowHexView()
|
||||
{
|
||||
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
|
||||
if (editor == null)
|
||||
{
|
||||
editor = new HexEditor();
|
||||
LibraryGUI.Instance.LoadEditor(editor);
|
||||
}
|
||||
editor.Text = Text;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
editor.LoadData(Data);
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeview)
|
||||
{
|
||||
if (Type == AudioType.Bfwav)
|
||||
{
|
||||
// UpdateEditor();
|
||||
}
|
||||
|
||||
UpdateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
private class MetaDataNodeWrapper : TreeNodeCustom
|
||||
{
|
||||
public MetaDataNodeWrapper(AMTA amta) { MetaFile = amta; }
|
||||
|
||||
public AMTA MetaFile { get; set; }
|
||||
|
||||
public override void OnClick(TreeView treeview)
|
||||
{
|
||||
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
|
||||
if (editor == null)
|
||||
{
|
||||
editor = new STPropertyGrid();
|
||||
LibraryGUI.Instance.LoadEditor(editor);
|
||||
}
|
||||
editor.Text = Text;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
editor.LoadProperty(MetaFile.Data, OnPropertyChanged);
|
||||
}
|
||||
|
||||
private void OnPropertyChanged() { }
|
||||
}
|
||||
|
||||
public BarsLib.BARS bars;
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
|
@ -146,9 +229,12 @@ namespace FirstPlugin
|
|||
Nodes.Add("Audio");
|
||||
for (int i = 0; i < bars.AmtaList.Count; i++)
|
||||
{
|
||||
var amtaWrapper = new MetaDataNodeWrapper(bars.AmtaList[i]);
|
||||
string audioName = bars.AmtaList[i].Name;
|
||||
|
||||
Nodes[0].Nodes.Add(audioName + ".amta");
|
||||
amtaWrapper.Text = $"{audioName}.amta";
|
||||
Nodes[0].Nodes.Add(amtaWrapper);
|
||||
|
||||
BARSAudioFile audio = bars.audioList[i];
|
||||
|
||||
AudioEntry node = new AudioEntry();
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace FirstPlugin
|
|||
AudioPlayer form = new AudioPlayer();
|
||||
form.Text = FileName;
|
||||
form.Dock = DockStyle.Fill;
|
||||
form.LoadFile(waveSource, this, mp3Struct);
|
||||
form.LoadFile(waveSource, this, false, mp3Struct);
|
||||
|
||||
return form;
|
||||
}
|
||||
|
|
|
@ -844,8 +844,9 @@ namespace FirstPlugin
|
|||
{
|
||||
if (folder is BFRESGroupNode)
|
||||
{
|
||||
return (((BFRESGroupNode)folder).Type == BRESGroupType.Textures &&
|
||||
bool hasTextures = (((BFRESGroupNode)folder).Type == BRESGroupType.Textures &&
|
||||
folder.Nodes.Count > 0);
|
||||
if (hasTextures) return true;
|
||||
}
|
||||
if (folder is BNTX)
|
||||
{
|
||||
|
|
|
@ -280,6 +280,7 @@ namespace Bfres.Structs
|
|||
FMDL fmdl = NewModel(false);
|
||||
fmdl.Text = ResourceName;
|
||||
fmdl.Replace(FileName, resFileNX, resFileU);
|
||||
fmdl.UpdateVertexData();
|
||||
AddNode(fmdl);
|
||||
break;
|
||||
case BRESGroupType.SkeletalAnim:
|
||||
|
@ -448,9 +449,15 @@ namespace Bfres.Structs
|
|||
RemoveChild(((STGenericWrapper)node));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ResourceNodes.Clear();
|
||||
Nodes.Clear();
|
||||
|
||||
if (Type == BRESGroupType.Models)
|
||||
{
|
||||
((BFRES)Parent).BFRESRender.UpdateModelList();
|
||||
LibraryGUI.Instance.UpdateViewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -733,7 +733,7 @@ namespace Bfres.Structs
|
|||
return;
|
||||
|
||||
string[] shapeSortCheck = shapes.Select(o => o.Text).ToArray();
|
||||
assimp.objects = assimp.objects.SortBy(shapeSortCheck, c => c.ObjectName).ToList();
|
||||
// assimp.objects = assimp.objects.SortBy(shapeSortCheck, c => c.ObjectName).ToList();
|
||||
|
||||
if (assimp.objects.Count == 0)
|
||||
{
|
||||
|
@ -829,6 +829,11 @@ namespace Bfres.Structs
|
|||
Nodes["FmatFolder"].Nodes.Clear();
|
||||
MatStartIndex = 0;
|
||||
}
|
||||
else if (UseMats)
|
||||
MatStartIndex = materials.Count;
|
||||
else
|
||||
MatStartIndex = 0;
|
||||
|
||||
if (UseMats)
|
||||
{
|
||||
int curMat = 0;
|
||||
|
@ -1114,11 +1119,10 @@ namespace Bfres.Structs
|
|||
progressBar.Task = $"Generating Max Skin Influence. Mesh: {obj.ObjectName}";
|
||||
progressBar.Refresh();
|
||||
|
||||
if (!ForceSkinInfluence)
|
||||
shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
|
||||
else
|
||||
if (ForceSkinInfluence)
|
||||
shape.VertexSkinCount = (byte)ForceSkinInfluenceMax;
|
||||
|
||||
else
|
||||
shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
|
||||
|
||||
if (shape.VertexSkinCount == 1 && shape.BoneIndices.Count > 0)
|
||||
{
|
||||
|
@ -1163,7 +1167,6 @@ namespace Bfres.Structs
|
|||
progressBar.Close();
|
||||
|
||||
IsEdited = true;
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace Bfres.Structs
|
|||
foreach (var shape in model.shapes)
|
||||
{
|
||||
//If there are indices higher than this index, shift them
|
||||
if (shape.MaterialIndex >= CurrentIndex)
|
||||
if (shape.MaterialIndex > CurrentIndex)
|
||||
{
|
||||
shape.MaterialIndex -= 1;
|
||||
}
|
||||
|
|
|
@ -1391,7 +1391,7 @@ namespace Bfres.Structs
|
|||
|
||||
private void OptmizeIndicesWeights(VertexAttribute attribute)
|
||||
{
|
||||
/* if (VertexSkinCount == 1)
|
||||
if (VertexSkinCount == 1)
|
||||
{
|
||||
switch (attribute.Format)
|
||||
{
|
||||
|
@ -1507,7 +1507,7 @@ namespace Bfres.Structs
|
|||
attribute.Format = ResGFX.AttribFormat.Format_32_32_32_UInt;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVertices()
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace FirstPlugin
|
|||
{
|
||||
public class BFRESRender : AbstractGlDrawable
|
||||
{
|
||||
private bool Disposing = false;
|
||||
|
||||
public Matrix4 ModelTransform = Matrix4.Identity;
|
||||
Vector3 position = new Vector3(0);
|
||||
|
||||
|
@ -47,6 +49,7 @@ namespace FirstPlugin
|
|||
|
||||
public void UpdateModelList()
|
||||
{
|
||||
_models.Clear();
|
||||
foreach (var node in ResFileNode.Nodes)
|
||||
{
|
||||
if (node is BFRESGroupNode &&
|
||||
|
@ -84,6 +87,8 @@ namespace FirstPlugin
|
|||
|
||||
GL.DeleteBuffer(vbo_position);
|
||||
GL.DeleteBuffer(ibo_elements);
|
||||
|
||||
Disposing = true;
|
||||
}
|
||||
|
||||
private void TransformBones()
|
||||
|
@ -192,6 +197,8 @@ namespace FirstPlugin
|
|||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
if (Disposing) return;
|
||||
|
||||
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
GenerateBuffers();
|
||||
|
@ -287,7 +294,7 @@ namespace FirstPlugin
|
|||
|
||||
private void DrawBfres(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT)
|
||||
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT || Disposing)
|
||||
return;
|
||||
|
||||
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
|
||||
|
@ -577,8 +584,6 @@ namespace FirstPlugin
|
|||
public static int BindTexture(MatTexture tex, FMAT material, bool IsWiiU)
|
||||
{
|
||||
BFRES bfres = (BFRES)material.Parent.Parent.Parent.Parent;
|
||||
if (material.Parent == null || bfres == null) //Bfres disposed
|
||||
return -1;
|
||||
|
||||
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);
|
||||
|
|
|
@ -53,8 +53,7 @@ namespace FirstPlugin
|
|||
public bool ResetUVParams;
|
||||
public bool ResetColorParams;
|
||||
|
||||
public int SkinCountLimit;
|
||||
public bool LimitSkinCount;
|
||||
public bool LimitSkinCount => ogSkinCountChkBox.Checked;
|
||||
public bool MapOriginalMaterials => chkMapOriginalMaterials.Checked;
|
||||
public bool UseOriginalAttributes => chkOriginalAttributesFormats.Checked;
|
||||
public bool UseOriginalAttributeFormats => chkOriginalAttributesFormats.Checked;
|
||||
|
@ -406,11 +405,6 @@ namespace FirstPlugin
|
|||
GeneratePlaceholderTextures = chkPlaceHolderTextures.Checked;
|
||||
}
|
||||
|
||||
private void ogSkinCountChkBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
LimitSkinCount = ogSkinCountChkBox.Checked;
|
||||
}
|
||||
|
||||
private void assimpMeshListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (assimpMeshListView.SelectedIndices.Count == 0)
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -305,6 +305,7 @@ namespace Switch_Toolbox.Library
|
|||
mat.TextureMaps.Add(CreateTextureSlot(tex, TextureType.Normals));
|
||||
if (material.GetMaterialTexture(TextureType.Specular, 1, out tex))
|
||||
mat.TextureMaps.Add(CreateTextureSlot(tex, TextureType.Specular));
|
||||
|
||||
return mat;
|
||||
}
|
||||
private STGenericMatTexture CreateTextureSlot(TextureSlot tex, TextureType type)
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Switch_Toolbox.Library
|
|||
bool ExportSuccessScene = v.ExportFile(scene, FileName, formatID, PostProcessSteps.FlipUVs);
|
||||
if (ExportSuccessScene)
|
||||
{
|
||||
// WriteExtraSkinningInfo(FileName, scene, model);
|
||||
WriteExtraSkinningInfo(FileName, scene, model);
|
||||
MessageBox.Show($"Exported {FileName} Successfuly!");
|
||||
}
|
||||
else
|
||||
|
@ -83,7 +83,7 @@ namespace Switch_Toolbox.Library
|
|||
int MeshIndex = 0;
|
||||
foreach (var obj in model.Nodes[0].Nodes)
|
||||
{
|
||||
var mesh = SaveMesh((STGenericObject)obj, skeleton, NodeArray);
|
||||
var mesh = SaveMesh((STGenericObject)obj, MeshIndex, skeleton, NodeArray);
|
||||
scene.Meshes.Add(mesh);
|
||||
MeshIndex++;
|
||||
}
|
||||
|
@ -96,9 +96,10 @@ namespace Switch_Toolbox.Library
|
|||
scene.RootNode.Children.Add(geomNode);
|
||||
}
|
||||
|
||||
private Mesh SaveMesh(STGenericObject genericObj, STSkeleton skeleton, List<int> NodeArray)
|
||||
private Mesh SaveMesh(STGenericObject genericObj, int index, STSkeleton skeleton, List<int> NodeArray)
|
||||
{
|
||||
Mesh mesh = new Mesh(genericObj.Text, PrimitiveType.Triangle);
|
||||
//Assimp is weird so use mesh_# for the name. We'll change it back after save
|
||||
Mesh mesh = new Mesh($"mesh_{ index }", PrimitiveType.Triangle);
|
||||
mesh.MaterialIndex = genericObj.MaterialIndex;
|
||||
|
||||
List<Vector3D> textureCoords0 = new List<Vector3D>();
|
||||
|
@ -185,6 +186,7 @@ namespace Switch_Toolbox.Library
|
|||
StreamWriter test = new StreamWriter(FileName + ".tmp");
|
||||
StreamReader dae = File.OpenText(FileName);
|
||||
|
||||
int geomIndex = 0;
|
||||
while (!dae.EndOfStream)
|
||||
{
|
||||
string line = dae.ReadLine();
|
||||
|
@ -197,16 +199,18 @@ namespace Switch_Toolbox.Library
|
|||
}
|
||||
else if (line.Contains("<node"))
|
||||
{
|
||||
string[] testLn = line.Split('\"');
|
||||
string name = testLn[3];
|
||||
|
||||
string jointLine = line.Replace(">", $" sid=\"{ name }\" type=\"JOINT\">");
|
||||
test.WriteLine(jointLine);
|
||||
test.WriteLine(line);
|
||||
test.Flush();
|
||||
|
||||
/* string[] testLn = line.Split('\"');
|
||||
string name = testLn[3];
|
||||
|
||||
string jointLine = line.Replace(">", $" sid=\"{ name }\" type=\"JOINT\">");
|
||||
test.WriteLine(jointLine);
|
||||
test.Flush();*/
|
||||
}
|
||||
if (line.Contains("</visual_scene>"))
|
||||
else if (line.Contains("</visual_scene>"))
|
||||
{
|
||||
int index = 0;
|
||||
foreach (Mesh mesh in outScene.Meshes)
|
||||
{
|
||||
test.WriteLine($" <node id=\"{ mesh.Name }\" name=\"{ mesh.Name }\" type=\"NODE\">");
|
||||
|
@ -222,13 +226,19 @@ namespace Switch_Toolbox.Library
|
|||
|
||||
test.WriteLine(" </node>");
|
||||
test.Flush();
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
test.WriteLine(line);
|
||||
test.Flush();
|
||||
}
|
||||
else if (line.Contains("<geometry"))
|
||||
{
|
||||
string RealMeshName = Model.Nodes[0].Nodes[geomIndex].Text;
|
||||
test.WriteLine($" <geometry id=\"meshId{ geomIndex }\" name=\"{ RealMeshName }\" > ");
|
||||
test.Flush();
|
||||
|
||||
geomIndex++;
|
||||
}
|
||||
else if (line.Contains("<matrix"))
|
||||
{
|
||||
string matLine = line.Replace("<matrix>", "<matrix sid=\"matrix\">");
|
||||
|
@ -237,7 +247,7 @@ namespace Switch_Toolbox.Library
|
|||
}
|
||||
else
|
||||
{
|
||||
test.WriteLine(line);
|
||||
test.WriteLine(line);
|
||||
test.Flush();
|
||||
}
|
||||
}
|
||||
|
@ -507,55 +517,65 @@ namespace Switch_Toolbox.Library
|
|||
if (!File.Exists(path))
|
||||
continue;
|
||||
|
||||
TextureSlot slot = new TextureSlot();
|
||||
slot.FilePath = path;
|
||||
slot.UVIndex = 0;
|
||||
slot.Flags = 0;
|
||||
slot.TextureIndex = 0;
|
||||
slot.BlendFactor = 1.0f;
|
||||
slot.Mapping = TextureMapping.FromUV;
|
||||
slot.Operation = TextureOperation.Add;
|
||||
|
||||
if (tex.Type == STGenericMatTexture.TextureType.Diffuse)
|
||||
slot.TextureType = TextureType.Diffuse;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Normal)
|
||||
slot.TextureType = TextureType.Normals;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Specular)
|
||||
slot.TextureType = TextureType.Specular;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Emission)
|
||||
slot.TextureType = TextureType.Emissive;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Light)
|
||||
{
|
||||
slot.TextureType = TextureType.Lightmap;
|
||||
slot.UVIndex = 2;
|
||||
}
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Shadow)
|
||||
{
|
||||
slot.TextureType = TextureType.Ambient;
|
||||
slot.UVIndex = 1;
|
||||
}
|
||||
else
|
||||
slot.TextureType = TextureType.Unknown;
|
||||
TextureSlot slot2 = new TextureSlot(path, Assimp.TextureType.Diffuse, 0,
|
||||
Assimp.TextureMapping.FromUV, 0, 1.0f, Assimp.TextureOperation.Add,
|
||||
0, 0, 0);
|
||||
|
||||
if (tex.wrapModeS == 0)
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
else if (tex.wrapModeS == 1)
|
||||
slot.WrapModeU = TextureWrapMode.Mirror;
|
||||
else if (tex.wrapModeS == 2)
|
||||
slot.WrapModeU = TextureWrapMode.Clamp;
|
||||
else
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
|
||||
if (tex.wrapModeT == 0)
|
||||
slot.WrapModeV = TextureWrapMode.Wrap;
|
||||
else if (tex.wrapModeT == 1)
|
||||
slot.WrapModeV = TextureWrapMode.Mirror;
|
||||
else if (tex.wrapModeT == 2)
|
||||
slot.WrapModeV = TextureWrapMode.Clamp;
|
||||
else
|
||||
slot.WrapModeV = TextureWrapMode.Wrap;
|
||||
|
||||
material.AddMaterialTexture(ref slot);
|
||||
material.AddMaterialTexture(ref slot2);
|
||||
break;
|
||||
|
||||
TextureSlot slot = new TextureSlot();
|
||||
slot.FilePath = path;
|
||||
slot.UVIndex = 0;
|
||||
slot.Flags = 0;
|
||||
slot.TextureIndex = 0;
|
||||
slot.BlendFactor = 1.0f;
|
||||
slot.Mapping = TextureMapping.FromUV;
|
||||
slot.Operation = TextureOperation.Add;
|
||||
slot.TextureType = TextureType.Diffuse;
|
||||
|
||||
|
||||
if (tex.Type == STGenericMatTexture.TextureType.Diffuse)
|
||||
slot.TextureType = TextureType.Diffuse;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Normal)
|
||||
slot.TextureType = TextureType.Normals;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Specular)
|
||||
slot.TextureType = TextureType.Specular;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Emission)
|
||||
slot.TextureType = TextureType.Emissive;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Light)
|
||||
{
|
||||
slot.TextureType = TextureType.Lightmap;
|
||||
slot.UVIndex = 2;
|
||||
}
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Shadow)
|
||||
{
|
||||
slot.TextureType = TextureType.Ambient;
|
||||
slot.UVIndex = 1;
|
||||
}
|
||||
else
|
||||
slot.TextureType = TextureType.Unknown;
|
||||
|
||||
if (tex.wrapModeS == 0)
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
else if (tex.wrapModeS == 1)
|
||||
slot.WrapModeU = TextureWrapMode.Mirror;
|
||||
else if (tex.wrapModeS == 2)
|
||||
slot.WrapModeU = TextureWrapMode.Clamp;
|
||||
else
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
|
||||
if (tex.wrapModeT == 0)
|
||||
slot.WrapModeV = TextureWrapMode.Wrap;
|
||||
else if (tex.wrapModeT == 1)
|
||||
slot.WrapModeV = TextureWrapMode.Mirror;
|
||||
else if (tex.wrapModeT == 2)
|
||||
slot.WrapModeV = TextureWrapMode.Clamp;
|
||||
else
|
||||
slot.WrapModeV = TextureWrapMode.Wrap;
|
||||
}
|
||||
}
|
||||
scene.Materials.Add(material);
|
||||
}
|
||||
|
@ -567,7 +587,7 @@ namespace Switch_Toolbox.Library
|
|||
Scene scene = new Scene();
|
||||
scene.RootNode = new Node("Root");
|
||||
|
||||
var mesh = SaveMesh(genericObject, null, null);
|
||||
var mesh = SaveMesh(genericObject,0, null, null);
|
||||
mesh.MaterialIndex = 0;
|
||||
scene.Meshes.Add(mesh);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(50, 37);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pictureBox1.TabIndex = 7;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
|
|
|
@ -90,6 +90,7 @@ namespace Switch_Toolbox.Library.Forms
|
|||
{
|
||||
// Re-anchoring the controls so they stay in their place while the form is resized
|
||||
btnClose.Anchor = AnchorStyles.Top;
|
||||
stButton1.Anchor = AnchorStyles.Top;
|
||||
btnDetails.Anchor = AnchorStyles.Top;
|
||||
tbDetails.Anchor = AnchorStyles.Top;
|
||||
|
||||
|
|
|
@ -66,8 +66,11 @@ namespace Switch_Toolbox.Library.Forms
|
|||
|
||||
}
|
||||
|
||||
public void LoadFile(IWaveSource source, IFileFormat fileFormat, object AudioStruct = null)
|
||||
public void LoadFile(IWaveSource source, IFileFormat fileFormat, bool ClearPlaylist = false, object AudioStruct = null)
|
||||
{
|
||||
if (ClearPlaylist)
|
||||
audioListView.Items.Clear();
|
||||
|
||||
AudioFile file = new AudioFile();
|
||||
file.Title = fileFormat.FileName;
|
||||
|
||||
|
@ -102,8 +105,11 @@ namespace Switch_Toolbox.Library.Forms
|
|||
|
||||
}
|
||||
|
||||
public void LoadFile(AudioData audioData, IFileFormat fileFormat)
|
||||
public void LoadFile(AudioData audioData, IFileFormat fileFormat, bool ClearPlaylist = false)
|
||||
{
|
||||
if (ClearPlaylist)
|
||||
audioListView.Items.Clear();
|
||||
|
||||
AudioFileFormats.Add(fileFormat);
|
||||
|
||||
//Load Channel Info
|
||||
|
|
480
Switch_Toolbox_Library/Forms/Editors/Audio/AudioPlayerPanel.Designer.cs
generated
Normal file
480
Switch_Toolbox_Library/Forms/Editors/Audio/AudioPlayerPanel.Designer.cs
generated
Normal file
|
@ -0,0 +1,480 @@
|
|||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
partial class AudioPlayerPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.audioBarPanel = new Switch_Toolbox.Library.Forms.STPanel();
|
||||
this.trackbarVolume = new ColorSlider.ColorSlider();
|
||||
this.stPanel4 = new Switch_Toolbox.Library.Forms.STPanel();
|
||||
this.btnStop = new Switch_Toolbox.Library.Forms.STButton();
|
||||
this.btnForward1 = new Switch_Toolbox.Library.Forms.STButton();
|
||||
this.btnPlay = new Switch_Toolbox.Library.Forms.STButton();
|
||||
this.btnBackward1 = new Switch_Toolbox.Library.Forms.STButton();
|
||||
this.stLabel2 = new Switch_Toolbox.Library.Forms.STLabel();
|
||||
this.stLabel1 = new Switch_Toolbox.Library.Forms.STLabel();
|
||||
this.colorSlider1 = new ColorSlider.ColorSlider();
|
||||
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
|
||||
this.stPanel3 = new Switch_Toolbox.Library.Forms.STPanel();
|
||||
this.audioListView = new Switch_Toolbox.Library.Forms.STListView();
|
||||
this.olvColumn1 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
|
||||
this.olvColumn2 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
|
||||
this.olvColumn3 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
|
||||
this.olvColumn4 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
|
||||
this.splitter1 = new System.Windows.Forms.Splitter();
|
||||
this.stPanel2 = new Switch_Toolbox.Library.Forms.STPanel();
|
||||
this.audioDevice = new Switch_Toolbox.Library.Forms.STComboBox();
|
||||
this.channelCB = new Switch_Toolbox.Library.Forms.STComboBox();
|
||||
this.stContextMenuStrip1 = new Switch_Toolbox.Library.Forms.STMenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loopingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.chkLoopPlayer = new Switch_Toolbox.Library.Forms.STCheckBox();
|
||||
this.audioBarPanel.SuspendLayout();
|
||||
this.stPanel4.SuspendLayout();
|
||||
this.stPanel1.SuspendLayout();
|
||||
this.stPanel3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.audioListView)).BeginInit();
|
||||
this.stPanel2.SuspendLayout();
|
||||
this.stContextMenuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contentContainer
|
||||
//
|
||||
this.Controls.Add(this.stPanel1);
|
||||
this.Controls.Add(this.audioBarPanel);
|
||||
this.Size = new System.Drawing.Size(531, 441);
|
||||
this.Controls.SetChildIndex(this.audioBarPanel, 0);
|
||||
this.Controls.SetChildIndex(this.stPanel1, 0);
|
||||
//
|
||||
// audioBarPanel
|
||||
//
|
||||
this.audioBarPanel.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.audioBarPanel.Controls.Add(this.chkLoopPlayer);
|
||||
this.audioBarPanel.Controls.Add(this.trackbarVolume);
|
||||
this.audioBarPanel.Controls.Add(this.stPanel4);
|
||||
this.audioBarPanel.Controls.Add(this.stLabel2);
|
||||
this.audioBarPanel.Controls.Add(this.stLabel1);
|
||||
this.audioBarPanel.Controls.Add(this.colorSlider1);
|
||||
this.audioBarPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.audioBarPanel.Location = new System.Drawing.Point(0, 373);
|
||||
this.audioBarPanel.Name = "audioBarPanel";
|
||||
this.audioBarPanel.Size = new System.Drawing.Size(531, 68);
|
||||
this.audioBarPanel.TabIndex = 11;
|
||||
//
|
||||
// trackbarVolume
|
||||
//
|
||||
this.trackbarVolume.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.trackbarVolume.BackColor = System.Drawing.Color.Transparent;
|
||||
this.trackbarVolume.BarInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.trackbarVolume.BarPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.trackbarVolume.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.trackbarVolume.BorderRoundRectSize = new System.Drawing.Size(8, 8);
|
||||
this.trackbarVolume.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.trackbarVolume.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.trackbarVolume.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.trackbarVolume.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F);
|
||||
this.trackbarVolume.ForeColor = System.Drawing.Color.White;
|
||||
this.trackbarVolume.LargeChange = ((uint)(5u));
|
||||
this.trackbarVolume.Location = new System.Drawing.Point(437, 34);
|
||||
this.trackbarVolume.Maximum = 1000;
|
||||
this.trackbarVolume.MouseEffects = false;
|
||||
this.trackbarVolume.Name = "trackbarVolume";
|
||||
this.trackbarVolume.ScaleDivisions = 10;
|
||||
this.trackbarVolume.ScaleSubDivisions = 5;
|
||||
this.trackbarVolume.ShowDivisionsText = true;
|
||||
this.trackbarVolume.ShowSmallScale = false;
|
||||
this.trackbarVolume.Size = new System.Drawing.Size(85, 37);
|
||||
this.trackbarVolume.SmallChange = ((uint)(1u));
|
||||
this.trackbarVolume.TabIndex = 12;
|
||||
this.trackbarVolume.Text = "colorSlider2";
|
||||
this.trackbarVolume.ThumbInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.trackbarVolume.ThumbPenColor = System.Drawing.Color.Silver;
|
||||
this.trackbarVolume.ThumbRoundRectSize = new System.Drawing.Size(8, 8);
|
||||
this.trackbarVolume.ThumbSize = new System.Drawing.Size(8, 8);
|
||||
this.trackbarVolume.TickAdd = 0F;
|
||||
this.trackbarVolume.TickColor = System.Drawing.Color.White;
|
||||
this.trackbarVolume.TickDivide = 0F;
|
||||
this.trackbarVolume.TickStyle = System.Windows.Forms.TickStyle.None;
|
||||
this.trackbarVolume.ValueChanged += new System.EventHandler(this.trackbarVolume_ValueChanged);
|
||||
this.trackbarVolume.Scroll += new System.Windows.Forms.ScrollEventHandler(this.trackbarVolume_Scroll);
|
||||
//
|
||||
// stPanel4
|
||||
//
|
||||
this.stPanel4.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
|
||||
this.stPanel4.BackColor = System.Drawing.Color.Transparent;
|
||||
this.stPanel4.Controls.Add(this.btnStop);
|
||||
this.stPanel4.Controls.Add(this.btnForward1);
|
||||
this.stPanel4.Controls.Add(this.btnPlay);
|
||||
this.stPanel4.Controls.Add(this.btnBackward1);
|
||||
this.stPanel4.Location = new System.Drawing.Point(121, 3);
|
||||
this.stPanel4.Name = "stPanel4";
|
||||
this.stPanel4.Size = new System.Drawing.Size(195, 45);
|
||||
this.stPanel4.TabIndex = 11;
|
||||
//
|
||||
// btnStop
|
||||
//
|
||||
this.btnStop.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.btnStop.BackgroundImage = global::Switch_Toolbox.Library.Properties.Resources.StopBtn;
|
||||
this.btnStop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.btnStop.FlatAppearance.BorderSize = 0;
|
||||
this.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnStop.Location = new System.Drawing.Point(145, 7);
|
||||
this.btnStop.Name = "btnStop";
|
||||
this.btnStop.Size = new System.Drawing.Size(35, 35);
|
||||
this.btnStop.TabIndex = 3;
|
||||
this.btnStop.UseVisualStyleBackColor = false;
|
||||
this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
|
||||
//
|
||||
// btnForward1
|
||||
//
|
||||
this.btnForward1.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.btnForward1.BackgroundImage = global::Switch_Toolbox.Library.Properties.Resources.RewindArrows1R;
|
||||
this.btnForward1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.btnForward1.FlatAppearance.BorderSize = 0;
|
||||
this.btnForward1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnForward1.Location = new System.Drawing.Point(102, 15);
|
||||
this.btnForward1.Name = "btnForward1";
|
||||
this.btnForward1.Size = new System.Drawing.Size(23, 20);
|
||||
this.btnForward1.TabIndex = 2;
|
||||
this.btnForward1.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// btnPlay
|
||||
//
|
||||
this.btnPlay.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.btnPlay.BackgroundImage = global::Switch_Toolbox.Library.Properties.Resources.PlayArrowR;
|
||||
this.btnPlay.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.btnPlay.FlatAppearance.BorderSize = 0;
|
||||
this.btnPlay.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnPlay.Location = new System.Drawing.Point(50, 8);
|
||||
this.btnPlay.Name = "btnPlay";
|
||||
this.btnPlay.Size = new System.Drawing.Size(35, 35);
|
||||
this.btnPlay.TabIndex = 0;
|
||||
this.btnPlay.UseVisualStyleBackColor = false;
|
||||
this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click);
|
||||
//
|
||||
// btnBackward1
|
||||
//
|
||||
this.btnBackward1.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.btnBackward1.BackgroundImage = global::Switch_Toolbox.Library.Properties.Resources.RewindArrows1L;
|
||||
this.btnBackward1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.btnBackward1.FlatAppearance.BorderSize = 0;
|
||||
this.btnBackward1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnBackward1.Location = new System.Drawing.Point(11, 15);
|
||||
this.btnBackward1.Name = "btnBackward1";
|
||||
this.btnBackward1.Size = new System.Drawing.Size(20, 20);
|
||||
this.btnBackward1.TabIndex = 1;
|
||||
this.btnBackward1.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// stLabel2
|
||||
//
|
||||
this.stLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stLabel2.AutoSize = true;
|
||||
this.stLabel2.Location = new System.Drawing.Point(397, 46);
|
||||
this.stLabel2.Name = "stLabel2";
|
||||
this.stLabel2.Size = new System.Drawing.Size(34, 13);
|
||||
this.stLabel2.TabIndex = 10;
|
||||
this.stLabel2.Text = "0 : 00";
|
||||
//
|
||||
// stLabel1
|
||||
//
|
||||
this.stLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.stLabel1.AutoSize = true;
|
||||
this.stLabel1.Location = new System.Drawing.Point(5, 46);
|
||||
this.stLabel1.Name = "stLabel1";
|
||||
this.stLabel1.Size = new System.Drawing.Size(34, 13);
|
||||
this.stLabel1.TabIndex = 9;
|
||||
this.stLabel1.Text = "0 : 00";
|
||||
//
|
||||
// colorSlider1
|
||||
//
|
||||
this.colorSlider1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.colorSlider1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.colorSlider1.BarInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.colorSlider1.BarPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.colorSlider1.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.colorSlider1.BorderRoundRectSize = new System.Drawing.Size(8, 8);
|
||||
this.colorSlider1.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.colorSlider1.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.colorSlider1.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.colorSlider1.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F);
|
||||
this.colorSlider1.ForeColor = System.Drawing.Color.White;
|
||||
this.colorSlider1.LargeChange = ((uint)(5u));
|
||||
this.colorSlider1.Location = new System.Drawing.Point(47, 34);
|
||||
this.colorSlider1.Maximum = 1000;
|
||||
this.colorSlider1.MouseEffects = false;
|
||||
this.colorSlider1.Name = "colorSlider1";
|
||||
this.colorSlider1.ScaleDivisions = 10;
|
||||
this.colorSlider1.ScaleSubDivisions = 5;
|
||||
this.colorSlider1.ShowDivisionsText = true;
|
||||
this.colorSlider1.ShowSmallScale = false;
|
||||
this.colorSlider1.Size = new System.Drawing.Size(333, 37);
|
||||
this.colorSlider1.SmallChange = ((uint)(1u));
|
||||
this.colorSlider1.TabIndex = 8;
|
||||
this.colorSlider1.Text = "colorSlider1";
|
||||
this.colorSlider1.ThumbInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.colorSlider1.ThumbPenColor = System.Drawing.Color.Silver;
|
||||
this.colorSlider1.ThumbRoundRectSize = new System.Drawing.Size(8, 8);
|
||||
this.colorSlider1.ThumbSize = new System.Drawing.Size(8, 8);
|
||||
this.colorSlider1.TickAdd = 0F;
|
||||
this.colorSlider1.TickColor = System.Drawing.Color.White;
|
||||
this.colorSlider1.TickDivide = 0F;
|
||||
this.colorSlider1.TickStyle = System.Windows.Forms.TickStyle.None;
|
||||
this.colorSlider1.ValueChanged += new System.EventHandler(this.colorSlider1_ValueChanged);
|
||||
this.colorSlider1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.colorSlider1_MouseDown);
|
||||
//
|
||||
// stPanel1
|
||||
//
|
||||
this.stPanel1.Controls.Add(this.stPanel3);
|
||||
this.stPanel1.Controls.Add(this.splitter1);
|
||||
this.stPanel1.Controls.Add(this.stPanel2);
|
||||
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPanel1.Location = new System.Drawing.Point(0, 25);
|
||||
this.stPanel1.Name = "stPanel1";
|
||||
this.stPanel1.Size = new System.Drawing.Size(531, 348);
|
||||
this.stPanel1.TabIndex = 12;
|
||||
//
|
||||
// stPanel3
|
||||
//
|
||||
this.stPanel3.Controls.Add(this.audioListView);
|
||||
this.stPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPanel3.Location = new System.Drawing.Point(0, 117);
|
||||
this.stPanel3.Name = "stPanel3";
|
||||
this.stPanel3.Size = new System.Drawing.Size(531, 231);
|
||||
this.stPanel3.TabIndex = 3;
|
||||
//
|
||||
// audioListView
|
||||
//
|
||||
this.audioListView.AllColumns.Add(this.olvColumn1);
|
||||
this.audioListView.AllColumns.Add(this.olvColumn2);
|
||||
this.audioListView.AllColumns.Add(this.olvColumn3);
|
||||
this.audioListView.AllColumns.Add(this.olvColumn4);
|
||||
this.audioListView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.audioListView.CellEditUseWholeCell = false;
|
||||
this.audioListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.olvColumn1,
|
||||
this.olvColumn2,
|
||||
this.olvColumn3,
|
||||
this.olvColumn4});
|
||||
this.audioListView.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.audioListView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.audioListView.Location = new System.Drawing.Point(0, 0);
|
||||
this.audioListView.Name = "audioListView";
|
||||
this.audioListView.Scrollable = false;
|
||||
this.audioListView.ShowGroups = false;
|
||||
this.audioListView.Size = new System.Drawing.Size(531, 231);
|
||||
this.audioListView.TabIndex = 0;
|
||||
this.audioListView.UseCompatibleStateImageBehavior = false;
|
||||
this.audioListView.View = System.Windows.Forms.View.Details;
|
||||
this.audioListView.SelectedIndexChanged += new System.EventHandler(this.audioListView_SelectedIndexChanged);
|
||||
//
|
||||
// olvColumn1
|
||||
//
|
||||
this.olvColumn1.AspectName = "Status";
|
||||
this.olvColumn1.Text = "Status";
|
||||
this.olvColumn1.Width = 71;
|
||||
//
|
||||
// olvColumn2
|
||||
//
|
||||
this.olvColumn2.AspectName = "Title";
|
||||
this.olvColumn2.Text = "Title";
|
||||
this.olvColumn2.Width = 122;
|
||||
//
|
||||
// olvColumn3
|
||||
//
|
||||
this.olvColumn3.AspectName = "Artist";
|
||||
this.olvColumn3.Text = "Artist";
|
||||
this.olvColumn3.Width = 132;
|
||||
//
|
||||
// olvColumn4
|
||||
//
|
||||
this.olvColumn4.AspectName = "Duration";
|
||||
this.olvColumn4.Text = "Duration";
|
||||
this.olvColumn4.Width = 206;
|
||||
//
|
||||
// splitter1
|
||||
//
|
||||
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.splitter1.Location = new System.Drawing.Point(0, 114);
|
||||
this.splitter1.Name = "splitter1";
|
||||
this.splitter1.Size = new System.Drawing.Size(531, 3);
|
||||
this.splitter1.TabIndex = 2;
|
||||
this.splitter1.TabStop = false;
|
||||
//
|
||||
// stPanel2
|
||||
//
|
||||
this.stPanel2.Controls.Add(this.audioDevice);
|
||||
this.stPanel2.Controls.Add(this.channelCB);
|
||||
this.stPanel2.Controls.Add(this.stContextMenuStrip1);
|
||||
this.stPanel2.Controls.Add(this.pictureBox1);
|
||||
this.stPanel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.stPanel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.stPanel2.Name = "stPanel2";
|
||||
this.stPanel2.Size = new System.Drawing.Size(531, 114);
|
||||
this.stPanel2.TabIndex = 1;
|
||||
//
|
||||
// audioDevice
|
||||
//
|
||||
this.audioDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.audioDevice.FormattingEnabled = true;
|
||||
this.audioDevice.Location = new System.Drawing.Point(214, 3);
|
||||
this.audioDevice.Name = "audioDevice";
|
||||
this.audioDevice.Size = new System.Drawing.Size(151, 21);
|
||||
this.audioDevice.TabIndex = 20;
|
||||
this.audioDevice.SelectedIndexChanged += new System.EventHandler(this.audioDevice_SelectedIndexChanged);
|
||||
//
|
||||
// channelCB
|
||||
//
|
||||
this.channelCB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.channelCB.FormattingEnabled = true;
|
||||
this.channelCB.Location = new System.Drawing.Point(371, 3);
|
||||
this.channelCB.Name = "channelCB";
|
||||
this.channelCB.Size = new System.Drawing.Size(151, 21);
|
||||
this.channelCB.TabIndex = 19;
|
||||
this.channelCB.SelectedIndexChanged += new System.EventHandler(this.channelCB_SelectedIndexChanged);
|
||||
//
|
||||
// stContextMenuStrip1
|
||||
//
|
||||
this.stContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.editToolStripMenuItem});
|
||||
this.stContextMenuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stContextMenuStrip1.Name = "stContextMenuStrip1";
|
||||
this.stContextMenuStrip1.Size = new System.Drawing.Size(531, 24);
|
||||
this.stContextMenuStrip1.TabIndex = 18;
|
||||
this.stContextMenuStrip1.Text = "stContextMenuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.loopingToolStripMenuItem});
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
|
||||
this.editToolStripMenuItem.Text = "Edit";
|
||||
//
|
||||
// loopingToolStripMenuItem
|
||||
//
|
||||
this.loopingToolStripMenuItem.Name = "loopingToolStripMenuItem";
|
||||
this.loopingToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
|
||||
this.loopingToolStripMenuItem.Text = "Loop Editor";
|
||||
this.loopingToolStripMenuItem.Click += new System.EventHandler(this.loopingToolStripMenuItem_Click);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(0, 27);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(531, 84);
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Enabled = true;
|
||||
this.timer1.Interval = 40;
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// chkLoopPlayer
|
||||
//
|
||||
this.chkLoopPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.chkLoopPlayer.AutoSize = true;
|
||||
this.chkLoopPlayer.Checked = true;
|
||||
this.chkLoopPlayer.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkLoopPlayer.Location = new System.Drawing.Point(400, 18);
|
||||
this.chkLoopPlayer.Name = "chkLoopPlayer";
|
||||
this.chkLoopPlayer.Size = new System.Drawing.Size(82, 17);
|
||||
this.chkLoopPlayer.TabIndex = 13;
|
||||
this.chkLoopPlayer.Text = "Loop Player";
|
||||
this.chkLoopPlayer.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// AudioPlayer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(537, 446);
|
||||
this.Name = "AudioPlayer";
|
||||
this.Text = "AudioPlayer";
|
||||
this.audioBarPanel.ResumeLayout(false);
|
||||
this.audioBarPanel.PerformLayout();
|
||||
this.stPanel4.ResumeLayout(false);
|
||||
this.stPanel1.ResumeLayout(false);
|
||||
this.stPanel3.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.audioListView)).EndInit();
|
||||
this.stPanel2.ResumeLayout(false);
|
||||
this.stPanel2.PerformLayout();
|
||||
this.stContextMenuStrip1.ResumeLayout(false);
|
||||
this.stContextMenuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private STPanel audioBarPanel;
|
||||
private STPanel stPanel1;
|
||||
private STListView audioListView;
|
||||
private System.Windows.Forms.Splitter splitter1;
|
||||
private STPanel stPanel2;
|
||||
private BrightIdeasSoftware.OLVColumn olvColumn1;
|
||||
private BrightIdeasSoftware.OLVColumn olvColumn2;
|
||||
private BrightIdeasSoftware.OLVColumn olvColumn3;
|
||||
private STPanel stPanel3;
|
||||
private BrightIdeasSoftware.OLVColumn olvColumn4;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private ColorSlider.ColorSlider trackbarVolume;
|
||||
private STPanel stPanel4;
|
||||
private STButton btnForward1;
|
||||
private STButton btnPlay;
|
||||
private STButton btnBackward1;
|
||||
private STLabel stLabel2;
|
||||
private STLabel stLabel1;
|
||||
private ColorSlider.ColorSlider colorSlider1;
|
||||
private STComboBox audioDevice;
|
||||
private STComboBox channelCB;
|
||||
private STMenuStrip stContextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem loopingToolStripMenuItem;
|
||||
private STButton btnStop;
|
||||
private Switch_Toolbox.Library.Forms.STCheckBox chkLoopPlayer;
|
||||
}
|
||||
}
|
489
Switch_Toolbox_Library/Forms/Editors/Audio/AudioPlayerPanel.cs
Normal file
489
Switch_Toolbox_Library/Forms/Editors/Audio/AudioPlayerPanel.cs
Normal file
|
@ -0,0 +1,489 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using VGAudio.Containers.Wave;
|
||||
using VGAudio.Formats;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WinformsVisualization.Visualization;
|
||||
using CSCore.DSP;
|
||||
using CSCore.Streams.Effects;
|
||||
using CSCore;
|
||||
using CSCore.SoundOut;
|
||||
using CSCore.CoreAudioAPI;
|
||||
using CSCore.Tags.ID3;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public partial class AudioPlayerPanel : STUserControl
|
||||
{
|
||||
private LineSpectrum lineSpectrum;
|
||||
private PitchShifter _pitchShifter;
|
||||
private bool stopSliderUpdate;
|
||||
private MMDevice activeDevice;
|
||||
|
||||
public AudioFile selectedFile;
|
||||
|
||||
public VisualSetting visualSetting = VisualSetting.WaveSpectum;
|
||||
|
||||
public List<IFileFormat> AudioFileFormats = new List<IFileFormat>();
|
||||
|
||||
public enum VisualSetting
|
||||
{
|
||||
Artwork,
|
||||
WaveSpectum,
|
||||
}
|
||||
|
||||
private AudioChannel GetActiveAudio()
|
||||
{
|
||||
if (selectedFile == null)
|
||||
return null;
|
||||
|
||||
return selectedFile.GetCurrentChannel();
|
||||
}
|
||||
|
||||
public AudioPlayerPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetTheme();
|
||||
SetDevices();
|
||||
audioListView.FillLastColumnSpace(true);
|
||||
}
|
||||
|
||||
#region File Open
|
||||
|
||||
public void LoadFile(string AudioFileName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void LoadFile(byte[] AudioData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void LoadFile(IWaveSource source, IFileFormat fileFormat, bool ClearPlaylist = false, object AudioStruct = null)
|
||||
{
|
||||
if (ClearPlaylist)
|
||||
audioListView.Items.Clear();
|
||||
|
||||
AudioFile file = new AudioFile();
|
||||
file.Title = fileFormat.FileName;
|
||||
|
||||
if (AudioStruct is ID3v1)
|
||||
{
|
||||
var mp3 = (ID3v1)AudioStruct;
|
||||
|
||||
file.Title = mp3.Title;
|
||||
file.Artist = mp3.Artist;
|
||||
}
|
||||
|
||||
AudioFileFormats.Add(fileFormat);
|
||||
|
||||
|
||||
audioListView.AddObject(file);
|
||||
|
||||
AudioChannel audioChannel = new AudioChannel();
|
||||
audioChannel.Name = $"Channel [0]";
|
||||
file.Channels.Add(audioChannel);
|
||||
audioChannel.audioPlayer.Open(source, activeDevice);
|
||||
|
||||
audioChannel.audioPlayer.PlaybackStopped += (s, args) =>
|
||||
{
|
||||
//WasapiOut uses SynchronizationContext.Post to raise the event
|
||||
//There might be already a new WasapiOut-instance in the background when the async Post method brings the PlaybackStopped-Event to us.
|
||||
if (audioChannel.audioPlayer.PlaybackState != PlaybackState.Stopped)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
audioListView.UpdateObject(file);
|
||||
|
||||
}
|
||||
|
||||
public void LoadFile(AudioData audioData, IFileFormat fileFormat, bool ClearPlaylist = false)
|
||||
{
|
||||
if (ClearPlaylist)
|
||||
audioListView.Items.Clear();
|
||||
|
||||
AudioFileFormats.Add(fileFormat);
|
||||
|
||||
//Load Channel Info
|
||||
AudioFile file = new AudioFile();
|
||||
file.Title = fileFormat.FileName;
|
||||
if (fileFormat is VGAdudioFile)
|
||||
file.vgAdudioFile = (VGAdudioFile)fileFormat;
|
||||
|
||||
//Loop through each channel and set it's own
|
||||
var format = audioData.GetAllFormats().ToArray()[0];
|
||||
for (int c = 0; c < format.ChannelCount; c++)
|
||||
{
|
||||
using (var memWav = new MemoryStream())
|
||||
{
|
||||
AudioChannel audioChannel = new AudioChannel();
|
||||
audioChannel.Name = $"Channel [{c}]";
|
||||
file.Channels.Add(audioChannel);
|
||||
|
||||
//Load data and write to stream
|
||||
var audio = format.GetChannels(c).ToPcm16();
|
||||
var writer = new WaveWriter();
|
||||
writer.WriteToStream(audio, memWav);
|
||||
audioChannel.Data = memWav.ToArray();
|
||||
|
||||
memWav.Position = 0;
|
||||
|
||||
//Load the player
|
||||
audioChannel.audioPlayer.Open(new MemoryStream(audioChannel.Data),"test.wav", activeDevice);
|
||||
|
||||
/* OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
audioChannel.audioPlayer.Open(openFileDialog.FileName, activeDevice);
|
||||
}*/
|
||||
|
||||
|
||||
audioChannel.audioPlayer.PlaybackStopped += (s, args) =>
|
||||
{
|
||||
//WasapiOut uses SynchronizationContext.Post to raise the event
|
||||
//There might be already a new WasapiOut-instance in the background when the async Post method brings the PlaybackStopped-Event to us.
|
||||
if (audioChannel.audioPlayer.PlaybackState != PlaybackState.Stopped)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
audioListView.AddObject(file);
|
||||
|
||||
if (audioListView.Items.Count != 0)
|
||||
audioListView.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region GUI
|
||||
|
||||
private void UpdateAudioData()
|
||||
{
|
||||
foreach (var audio in audioListView.Objects)
|
||||
audioListView.RefreshObject(audio);
|
||||
}
|
||||
|
||||
private void FillArtPanel()
|
||||
{
|
||||
switch (visualSetting)
|
||||
{
|
||||
case VisualSetting.Artwork:
|
||||
break;
|
||||
case VisualSetting.WaveSpectum:
|
||||
GenerateLineSpectrum();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void FillForm()
|
||||
{
|
||||
if (selectedFile == null)
|
||||
{
|
||||
editToolStripMenuItem.Enabled = false;
|
||||
return;
|
||||
}
|
||||
editToolStripMenuItem.Enabled = true;
|
||||
|
||||
//Load channel data
|
||||
channelCB.Items.Clear();
|
||||
channelCB.Items.Add("Channel [All]");
|
||||
for (int i = 0; i < selectedFile.Channels.Count; i++)
|
||||
{
|
||||
channelCB.Items.Add(selectedFile.Channels[i].Name);
|
||||
}
|
||||
channelCB.SelectedIndex = selectedFile.SelectedChannelIndex;
|
||||
|
||||
//Setup a sample source for spectum data
|
||||
lineSpectrum = (selectedFile.GetCurrentChannel().audioPlayer._lineSpectrum);
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
var channel = GetActiveAudio();
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
TimeSpan position = channel.audioPlayer.Position;
|
||||
TimeSpan length = channel.audioPlayer.Length;
|
||||
if (position > length)
|
||||
{
|
||||
length = position;
|
||||
}
|
||||
if (position >= length)
|
||||
{
|
||||
if (chkLoopPlayer.Checked)
|
||||
{
|
||||
channel.audioPlayer.Position = TimeSpan.Zero;
|
||||
colorSlider1.Value = 0;
|
||||
channel.audioPlayer.Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stLabel1.Text = String.Format(@"{0:mm\:ss}", position);
|
||||
stLabel2.Text = String.Format(@"{0:mm\:ss}", length);
|
||||
|
||||
FillArtPanel();
|
||||
|
||||
if (!stopSliderUpdate &&
|
||||
length != TimeSpan.Zero && position != TimeSpan.Zero)
|
||||
{
|
||||
double perc = position.TotalMilliseconds / length.TotalMilliseconds * colorSlider1.Maximum;
|
||||
colorSlider1.Value = (int)perc;
|
||||
}
|
||||
audioListView.RefreshObject(selectedFile);
|
||||
}
|
||||
|
||||
private void btnPlay_Click(object sender, EventArgs e)
|
||||
{
|
||||
var channel = GetActiveAudio();
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
|
||||
UpdateAudioData();
|
||||
|
||||
//Pause if being played, or vice versa
|
||||
if (channel.audioPlayer.PlaybackState == PlaybackState.Playing)
|
||||
{
|
||||
channel.audioPlayer.Pause();
|
||||
btnPlay.BackgroundImage = Properties.Resources.PlayArrowR;
|
||||
}
|
||||
else
|
||||
{
|
||||
channel.audioPlayer.Play();
|
||||
btnPlay.BackgroundImage = Properties.Resources.PauseBtn;
|
||||
}
|
||||
|
||||
//Set the status in the list and update it
|
||||
selectedFile.Status = channel.audioPlayer.PlaybackState.ToString();
|
||||
}
|
||||
|
||||
private void audioListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (audioListView.SelectedObject != null)
|
||||
{
|
||||
if ((AudioFile)audioListView.SelectedObject == selectedFile)
|
||||
return;
|
||||
|
||||
selectedFile = (AudioFile)audioListView.SelectedObject;
|
||||
stLabel2.Text = selectedFile.Duration;
|
||||
|
||||
FillForm();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SpectumBar
|
||||
|
||||
|
||||
private void GenerateLineSpectrum()
|
||||
{
|
||||
if (lineSpectrum == null)
|
||||
return;
|
||||
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
|
||||
Image image = pictureBox1.Image;
|
||||
var newImage = lineSpectrum.CreateSpectrumLine(pictureBox1.Size, Color.Green, Color.Red, Color.Black, true);
|
||||
if (newImage != null)
|
||||
{
|
||||
pictureBox1.Image = newImage;
|
||||
if (image != null)
|
||||
image.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Themes
|
||||
private void SetTheme()
|
||||
{
|
||||
foreach (BrightIdeasSoftware.OLVColumn column in audioListView.Columns)
|
||||
{
|
||||
var headerstyle = new BrightIdeasSoftware.HeaderFormatStyle();
|
||||
headerstyle.SetBackColor(FormThemes.BaseTheme.FormBackColor);
|
||||
headerstyle.SetForeColor(FormThemes.BaseTheme.FormForeColor);
|
||||
column.HeaderFormatStyle = headerstyle;
|
||||
}
|
||||
|
||||
stPanel1.BackColor = FormThemes.BaseTheme.ObjectEditorBackColor;
|
||||
|
||||
btnPlay.BackColor = stPanel1.BackColor;
|
||||
btnBackward1.BackColor = stPanel1.BackColor;
|
||||
btnForward1.BackColor = stPanel1.BackColor;
|
||||
audioListView.BackColor = FormThemes.BaseTheme.TextEditorBackColor;
|
||||
audioListView.FullRowSelect = true;
|
||||
audioBarPanel.BackColor = stPanel1.BackColor;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Audio Devices
|
||||
|
||||
//Get audio devices to play audio out
|
||||
private void SetDevices()
|
||||
{
|
||||
using (var mmdeviceEnumerator = new MMDeviceEnumerator())
|
||||
{
|
||||
using (
|
||||
var mmdeviceCollection = mmdeviceEnumerator.EnumAudioEndpoints(DataFlow.Render, DeviceState.Active))
|
||||
{
|
||||
foreach (var device in mmdeviceCollection)
|
||||
{
|
||||
audioDevice.Items.Add(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (audioDevice.Items.Count <= 0)
|
||||
throw new Exception("No audio devices found!");
|
||||
|
||||
audioDevice.SelectedIndex = 0;
|
||||
|
||||
activeDevice = (MMDevice)audioDevice.SelectedItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ResetPlayers()
|
||||
{
|
||||
foreach (var channel in selectedFile.Channels)
|
||||
{
|
||||
channel.audioPlayer.Stop();
|
||||
channel.audioPlayer.Position = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private void colorSlider1_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
var channel = GetActiveAudio();
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
if (stopSliderUpdate)
|
||||
{
|
||||
double perc = colorSlider1.Value / (double)colorSlider1.Maximum;
|
||||
TimeSpan position = TimeSpan.FromMilliseconds(channel.audioPlayer.Length.TotalMilliseconds * perc);
|
||||
channel.audioPlayer.Position = position;
|
||||
}
|
||||
}
|
||||
|
||||
private void colorSlider1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
stopSliderUpdate = true;
|
||||
}
|
||||
|
||||
private void colorSlider1_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
stopSliderUpdate = false;
|
||||
}
|
||||
|
||||
private void trackbarVolume_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
var channel = GetActiveAudio();
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
channel.audioPlayer.Volume = trackbarVolume.Value;
|
||||
}
|
||||
|
||||
|
||||
private void AudioPlayer_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
channelCB.Items.Clear();
|
||||
|
||||
foreach (var obj in audioListView.Objects)
|
||||
{
|
||||
((AudioFile)obj).Dispose();
|
||||
}
|
||||
audioListView.ClearObjects();
|
||||
}
|
||||
|
||||
private void loopingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (selectedFile != null && selectedFile.vgAdudioFile != null )
|
||||
{
|
||||
LoopEditor editor = new LoopEditor();
|
||||
editor.chkCanLoop.Checked = selectedFile.vgAdudioFile.audioWithConfig.AudioFormat.Looping;
|
||||
editor.startLoopUD.Value = (decimal)selectedFile.vgAdudioFile.audioWithConfig.AudioFormat.LoopStart;
|
||||
editor.endLoopUD.Value = (decimal)selectedFile.vgAdudioFile.audioWithConfig.AudioFormat.LoopEnd;
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectedFile.vgAdudioFile.audioData.SetLoop(
|
||||
editor.chkCanLoop.Checked,
|
||||
(int)editor.startLoopUD.Value,
|
||||
(int)editor.endLoopUD.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void audioDevice_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void channelCB_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (selectedFile == null)
|
||||
return;
|
||||
|
||||
ResetPlayers();
|
||||
if (channelCB.SelectedIndex >= 1)
|
||||
{
|
||||
var prevChannel = selectedFile.GetCurrentChannel();
|
||||
|
||||
switch (prevChannel.audioPlayer.PlaybackState)
|
||||
{
|
||||
case PlaybackState.Playing:
|
||||
selectedFile.GetCurrentChannel().audioPlayer.Play();
|
||||
break;
|
||||
case PlaybackState.Stopped:
|
||||
selectedFile.GetCurrentChannel().audioPlayer.Stop();
|
||||
break;
|
||||
case PlaybackState.Paused:
|
||||
selectedFile.GetCurrentChannel().audioPlayer.Pause();
|
||||
break;
|
||||
}
|
||||
|
||||
selectedFile.SelectedChannelIndex = channelCB.SelectedIndex - 1;
|
||||
selectedFile.GetCurrentChannel().audioPlayer.Position = prevChannel.audioPlayer.Position;
|
||||
trackbarVolume.Value = selectedFile.GetCurrentChannel().audioPlayer.Volume;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
var channel = GetActiveAudio();
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
if (channel.audioPlayer.PlaybackState != PlaybackState.Stopped)
|
||||
{
|
||||
channel.audioPlayer.Stop();
|
||||
channel.audioPlayer.Position = TimeSpan.Zero;
|
||||
colorSlider1.Value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void trackbarVolume_Scroll(object sender, ScrollEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
129
Switch_Toolbox_Library/Forms/Editors/Audio/AudioPlayerPanel.resx
Normal file
129
Switch_Toolbox_Library/Forms/Editors/Audio/AudioPlayerPanel.resx
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>184, 17</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -272,6 +272,12 @@
|
|||
<Compile Include="Forms\Dialogs\STOptionsDialog.Designer.cs">
|
||||
<DependentUpon>STOptionsDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Editors\Audio\AudioPlayerPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Editors\Audio\AudioPlayerPanel.Designer.cs">
|
||||
<DependentUpon>AudioPlayerPanel.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Editors\Audio\LoopEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -730,6 +736,9 @@
|
|||
<EmbeddedResource Include="Forms\Editors\AssimpMeshSelector.resx">
|
||||
<DependentUpon>AssimpMeshSelector.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\Editors\Audio\AudioPlayerPanel.resx">
|
||||
<DependentUpon>AudioPlayerPanel.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\Editors\Audio\AudioPlayer.resx">
|
||||
<DependentUpon>AudioPlayer.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue