Ejemplo n.º 1
0
        //Gets the size of an RWSD Sound node
        //Doesn't include the header, so it's probably off by a little
        public void updateSize()
        {
            if (wavID == -1)
            {
                return;
            }

            BrawlLib.SSBB.ResourceNodes.RWSDSoundNode sound = brsar.GetNode(groupID, collectionID, wavID) as BrawlLib.SSBB.ResourceNodes.RWSDSoundNode;

            unsafe
            {
                int samples = sound.Header->NumSamples;
                if ((samples / 2 * 2) == samples)
                {
                    fileSize = samples / 2;
                }
                else
                {
                    fileSize = samples / 2 + 1;
                }
            }
            MappingItem p = this;

            brsar.CloseRSAR();
            this.TreeView.Invalidate();
        }
Ejemplo n.º 2
0
        public unsafe System.Audio.IAudioStream CreateStream()
        {
            //If this isn't connected to an RWSD SoundNode then return null
            if (wavID == -1)
            {
                return(null);
            }

            BrawlLib.SSBB.ResourceNodes.RWSDSoundNode sound = brsar.GetNode(groupID, collectionID, wavID) as BrawlLib.SSBB.ResourceNodes.RWSDSoundNode;
            BrawlLib.Wii.Audio.ADPCMStream            stream;
            BrawlLib.SSBBTypes.RWSD_WAVEEntry         header = new BrawlLib.SSBBTypes.RWSD_WAVEEntry();
            header = *sound.Header;
            if (header.NumSamples > soundBufferSize)
            {
                int breakpoint = 324;
                System.Windows.Forms.MessageBox.Show("Sound file is too big for playback: " + header.NumSamples.ToString() + "b / " + soundBufferSize.ToString() + "b");
                sound.Dispose();
                return(null);
            }
            //Copy the sound data
            Memory.Copy(sound._dataAddr, soundData, header.NumSamples);
            stream = new BrawlLib.Wii.Audio.ADPCMStream(&header, soundData);
            brsar.CloseRSAR();
            return(stream);
        }
Ejemplo n.º 3
0
        //Populates a treeView with MappingItem nodes from the current rsar
        public static void LoadTreeView(TreeView treeView)
        {
            //Only used to count the number of nodes added, no actual function in the program
            int nodeCount = 0;

            StringBuilder sb = new StringBuilder();

            BrawlLib.SSBB.ResourceNodes.RSARNode       rsar   = GetRSAR();
            BrawlLib.SSBB.ResourceNodes.RSARFolderNode folder = (BrawlLib.SSBB.ResourceNodes.RSARFolderNode)rsar.FindChild("Info/snd/group", false);
            BrawlLib.SSBB.ResourceNodes.ResourceNode[] groups = folder.FindChildrenByType("", BrawlLib.SSBB.ResourceNodes.ResourceType.RSARGroup);

            //Create root node and add all nodes to it.
            //Adding to the treeView collection directly will raise events, causing super slowdown when setting Text property.
            TreeNode           root  = new TreeNode();
            TreeNodeCollection nodes = root.Nodes;

            foreach (BrawlLib.SSBB.ResourceNodes.RSARGroupNode group in groups)
            {
                string name = group.Name;

                int         groupID  = group.Id;
                MappingItem groupMap = new MappingItem(name, groupID);
                nodes.Add(groupMap);
                nodeCount++;

                foreach (BrawlLib.SSBB.ResourceNodes.RSARFileNode file in group.Files)
                {
                    string fName        = file.Name;
                    int    collectionID = file.FileNodeIndex;
                    BrawlLib.SSBB.ResourceNodes.RWSDGroupNode audioFolder = (BrawlLib.SSBB.ResourceNodes.RWSDGroupNode)file.FindChild("audio", false);

                    if (audioFolder == null || audioFolder.Children.Count == 0)
                    {
                        continue;
                    }

                    MappingItem colMap = new MappingItem(fName, groupID, collectionID);
                    groupMap.Nodes.Add(colMap);
                    nodeCount++;

                    if (audioFolder == null)
                    {
                        continue;
                    }

                    //Same as nodeCount, used to track total size of sounds in collection. No actual function.
                    int addUpSoundSize = 0;

                    for (int i = 0; i < audioFolder.Children.Count; i++)
                    {
                        if (!(audioFolder.Children[i] is BrawlLib.SSBB.ResourceNodes.RWSDSoundNode))
                        {
                            continue;
                        }
                        BrawlLib.SSBB.ResourceNodes.RWSDSoundNode sound = (BrawlLib.SSBB.ResourceNodes.RWSDSoundNode)audioFolder.Children[i];
                        int soundSize = 0;
                        unsafe
                        {
                            int samples = sound.Header->NumSamples;
                            if ((samples / 2 * 2) == samples)
                            {
                                soundSize = samples / 2;
                            }
                            else
                            {
                                soundSize = samples / 2 + 1;
                            }
                        }
                        addUpSoundSize += soundSize;

                        MappingItem soundMap = new MappingItem(sound.Name, groupID, collectionID, i);

                        colMap.Nodes.Add(soundMap);
                        nodeCount++;
                        //child node must have a parent in order for size to propogate correctly.
                        soundMap.fileSize = soundSize;
                    }
                }

                //If the group doesn't have any collections then it doesn't have any sounds, remove it
                if (groupMap.Nodes.Count == 0)
                {
                    nodes.Remove(groupMap);
                    nodeCount -= 2;
                    continue;
                }
            }

            //Add the top level nodes to the treeview collection now that we're done.
            foreach (TreeNode node in nodes)
            {
                treeView.Nodes.Add(node);
            }
            CloseRSAR();
        }