public WaveFile(String inFilepath) { m_Filepath = inFilepath; m_FileInfo = new FileInfo(inFilepath); m_FileStream = m_FileInfo.OpenRead(); m_Riff = new Riff(); m_Fmt = new Fmt(); m_Data = new Data(); }
/// <summary> /// Toggles an effect on or off. /// </summary> public void Toggle <TEffect> () where TEffect : Behaviour { Riff riff = RiffEditor.CurrentRiff; Instrument inst = riff.Instrument; AudioSource source = MusicManager.Instance.GetAudioSource(inst); // Toggle effect TEffect effect = source.GetComponent <TEffect>(); effect.enabled = !effect.enabled; // Update riff Type effectType = typeof(TEffect); if (effectType == typeof(AudioDistortionFilter)) { riff.DistortionEnabled = effect.enabled; } else if (effectType == typeof(AudioEchoFilter)) { riff.EchoEnabled = effect.enabled; } else if (effectType == typeof(AudioReverbFilter)) { riff.ReverbEnabled = effect.enabled; } else if (effectType == typeof(AudioTremoloFilter)) { riff.TremoloEnabled = effect.enabled; } else if (effectType == typeof(AudioChorusFilter)) { riff.ChorusEnabled = effect.enabled; } else if (effectType == typeof(AudioFlangerFilter)) { riff.FlangerEnabled = effect.enabled; } // Update button art _image.sprite = (effect.enabled ? UIManager.Instance.FilledPercussionNoteIcon : UIManager.Instance.EmptyPercussionNoteIcon); // Play sound if (effect.enabled) { UIManager.Instance.PlayEnableEffectSound(); } else { UIManager.Instance.PlayDisableEffectSound(); } }
public ResultViewModel Insert([FromBody] Riff riff) { try { _context.Add(riff); _context.SaveChanges(); return(new ResultViewModel(Result.Success, riff.Name + " was successfully created.")); } catch (Exception ex) { return(new ResultViewModel(Result.Error, "Could not create " + riff.Name + ". Try again later.", ex)); } }
/// <summary> /// Refreshes a column. /// </summary> /// <param name="column">Column to refresh.</param> /// <param name="songpiece">Song piece to use for column.</param> void RefreshColumn(GameObject column, SongPiece songpiece) { Song song = MusicManager.Instance.CurrentSong; RectTransform column_tr = column.GetComponent <RectTransform>(); // Clear all chuldren from column foreach (RectTransform child in column_tr) { Destroy(child.gameObject); } int i = 0; float height = _columnHeight / Instrument.AllInstruments.Count; Measure measure = song.Measures[songpiece.MeasureIndices[0]]; foreach (int r in measure.RiffIndices) { Riff riff = song.Riffs[r]; float y = (float)(Instrument.AllInstruments.Count - 1 - i); // Riff name label GameObject label = UIHelpers.MakeText(riff.Name); RectTransform label_tr = label.GetComponent <RectTransform>(); label.SetParent(column_tr); label_tr.sizeDelta = new Vector2(_columnWidth, height); label_tr.AnchorAtPoint(0f, 0f); label_tr.anchoredPosition3D = new Vector3(2f * height, height * y, 0f); label_tr.ResetScaleRot(); // Instrument icon GameObject icon = UIHelpers.MakeImage(riff.Name + "Icon", riff.Instrument.Icon); RectTransform icon_tr = icon.GetComponent <RectTransform>(); icon_tr.SetParent(column_tr); icon_tr.SetSideWidth(height); icon_tr.AnchorAtPoint(0f, 0f); icon_tr.anchoredPosition3D = new Vector3(height, height * y, 0f); icon_tr.ResetScaleRot(); Text label_text = label.GetComponent <Text>(); label_text.text = riff.Name; label_text.color = Color.white; label_text.fontStyle = FontStyle.Normal; label_text.fontSize = 4; label_text.font = UIManager.Instance.Font; label_text.alignment = TextAnchor.MiddleCenter; i++; } }
/// <summary> /// Adds a riff from the prompt. /// </summary> public void AddRiff() { // Create riff Riff temp = new Riff(_dropdown.value); // Name riff temp.Name = _inputField.text; // Register riff with song MusicManager.Instance.CurrentSong.RegisterRiff(temp); // Go to riff editor RiffEditor.CurrentRiff = temp; SongArrangeMenu.Instance.SelectedRiffIndex = temp.Index; SongArrangeMenu.Instance.SetValue(temp.Index); SongArrangeMenu.Instance.Refresh(); }
public WaveFile(String inFilepath) { m_Filepath = inFilepath; m_FileInfo = new FileInfo(inFilepath); try { m_FileStream = m_FileInfo.OpenRead(); } catch (Exception ex) { MessageBox.Show(ex.Message); } m_Riff = new Riff( ); m_Fmt = new Fmt( ); m_Data = new Data(); }
public void UpdateSetting <TEffect>(ref float effectSetting, ref float riffSetting, Slider slider) where TEffect : Behaviour { Riff riff = RiffEditor.CurrentRiff; Instrument inst = riff.Instrument; AudioSource source = MusicManager.Instance.GetAudioSource(inst); // Update setting on both effect and riff riffSetting = effectSetting = slider.value; // Turn on effect if not already TEffect effect = source.GetComponent <TEffect>(); if (!effect.enabled) { Toggle <TEffect>(); } }
public ResultViewModel Update([FromBody] Riff newRiff) { var oldRiff = _context.Riffs.SingleOrDefault(s => s.Id == newRiff.Id); if (oldRiff != null) { try { oldRiff.Name = newRiff.Name; oldRiff.FilePath = newRiff.FilePath; _context.SaveChanges(); return(new ResultViewModel(Result.Success, newRiff.Name + " was successfully updated.")); } catch (Exception ex) { return(new ResultViewModel(Result.Error, "Could not update " + newRiff.Name + ". Try again later.", ex)); } } else { return(new ResultViewModel(Result.Error, "Could not find " + newRiff.Name + ". Try again later.")); } }
public override void OnMouseDown() { _targetRiff = RiffEditor.CurrentRiff; _oldVolume = _targetRiff.Volume; }
private void Init() { m_FileStream = m_FileInfo.OpenRead(); m_Riff = new Riff(); m_Fmt = new Fmt(); m_Data = new Data(); }
public void TestRiffHeader() { var riffHeader = new Riff().GetRiffHeader(new NAudio.Wave.WaveFormat(48000, 2)); Assert.AreEqual(58, riffHeader.Length); }
private void ParseData(Riff.RiffReader reader) { DataOffset = reader.Offset; DataLength = reader.Length; }
private void ParseFmt(Riff.RiffReader reader) { Ibasa.IO.BinaryReader binreader = new IO.BinaryReader(reader.Data); FormatTag tag; int channels, bytesPerSecond, blockAlignment,bitsPerSample, size; if (reader.Length < 16) { throw new System.IO.InvalidDataException("Invalid fmt chunk."); } else { tag = (FormatTag)binreader.ReadInt16(); channels = binreader.ReadInt16(); Frequency = binreader.ReadInt32(); bytesPerSecond = binreader.ReadInt32(); blockAlignment = binreader.ReadInt16(); bitsPerSample = binreader.ReadInt16(); } if (reader.Length >= 18) { size = binreader.ReadInt16(); } if (tag == FormatTag.Pcm) { if (bitsPerSample == 8) { Format = new Ibasa.SharpAL.Formats.Pcm8(channels); } else if (bitsPerSample == 16) { Format = new Ibasa.SharpAL.Formats.Pcm16(channels); } else { throw new NotSupportedException(string.Format("PCM {0} bit data is not supported.", bitsPerSample)); } } else { throw new NotSupportedException(string.Format("{0} is not supported.", tag)); } }
private void TagTestWithSave (ref Riff.InfoTag tag, TagTestFunc testFunc) { testFunc (tag, "Before Save"); //Extras.DumpHex (tag.Render ().Data); tag = new Riff.InfoTag (tag.Render ()); testFunc (tag, "After Save"); }
public CprFileFormat(string filename) { using var reader = new RiffReader(filename); _content = reader.Read(); }
/// <summary> /// Inits all song piece columns on the timeline. /// </summary> public void MakeColumns() { Song song = MusicManager.Instance.CurrentSong; int numSongPieces = MusicManager.Instance.CurrentSong.SongPieceIndices.Count; // Clear current columns _columns.Clear(); // Resize timeline _timeline_tr.sizeDelta = new Vector2( (numSongPieces + 1) * _columnWidth, _columnHeight ); // Make columns for (int i = 0; i < numSongPieces; i++) { GameObject column = new GameObject("Column" + i, typeof(RectTransform), typeof(CanvasRenderer), typeof(Button), typeof(Image) ); RectTransform tr = column.GetComponent <RectTransform>(); column.SetParent(_timeline_tr); tr.sizeDelta = new Vector2(_columnWidth, _columnHeight); tr.AnchorAtPoint(0f, 0f); tr.anchoredPosition3D = new Vector3((i + 0.5f) * _columnWidth, _columnHeight / 2f, 0f); tr.ResetScaleRot(); int num = i; // avoid pointer problems // Setup column button properties column.GetComponent <Button>().onClick.AddListener(() => { SongArrangeMenu.Instance.UpdateValue(); Riff riff = MusicManager.Instance.CurrentSong.Riffs[SongArrangeMenu.Instance.SelectedRiffIndex]; song.ToggleRiff(riff, num); RefreshColumn(column, song.SongPieces[song.SongPieceIndices[num]]); }); column.GetComponent <Image>().sprite = UIManager.Instance.FillSprite; Color color = Color.white; color.a = (i % 2 == 1) ? 0.2f : 0.4f; column.GetComponent <Image>().color = color; _columns.Add(column); } // Refresh all columns for (int i = 0; i < _columns.Count; i++) { RefreshColumn(_columns[i], song.SongPieces[song.SongPieceIndices[i]]); } // Create add columns button GameObject addColumnButton = new GameObject("AddColumnButton", typeof(RectTransform), typeof(CanvasRenderer), typeof(Button), typeof(Image) ); RectTransform atr = addColumnButton.GetComponent <RectTransform>(); addColumnButton.SetParent(gameObject.GetComponent <RectTransform>()); float width = Mathf.Min(_columnWidth, _columnHeight) / 3f; atr.SetSideWidth(width); atr.AnchorAtPoint(1f, 0f); atr.anchoredPosition3D = new Vector3(-_columnWidth / 2f, _columnHeight / 2f, 0f); atr.ResetScaleRot(); addColumnButton.GetComponent <Button>().onClick.AddListener(() => { MusicManager.Instance.CurrentSong.NewSongPiece(); RefreshTimeline(); }); addColumnButton.GetComponent <Image>().sprite = UIManager.Instance.AddIcon; _columns.Add(addColumnButton); }
public void Read() { Riff.Read(FileStream); Format.Read(FileStream); Data.ReadData(FileStream); }
/** Creates new Tags from riffInput's input stream. * Note that riffInput is not a parent since the RIFF file * doesn't actually have a separate chunk which is the tags. * Rather the tags are a section at the end of an existing chunk. * This reads from riffInput until its bytesRemaining is zero. * Also, after bytesRemaining is zero, this also calls * riffInput.skipRemaining() to skip the possible pad byte. * Upon return, the "getter" functions height(), width() etc. return * the tag or null if there was no such tag. */ static public Tags newInstance(Riff riffInput) { Tags tags = new Tags(); while (riffInput.getBytesRemaining() > 0) { int tag = riffInput.readTag(); if (tag == 0x01) { tags = tags.cloneWithAbsolutePlacement (new Placement (riffInput.tagShortAt(0), riffInput.tagShortAt(2))); } else if (tag == 0x02) { tags = tags.cloneWithAlternateEnding (riffInput.tagByteAt(0)); } else if (tag == 0x03) { tags = tags.cloneWithAnchorOverride (riffInput.tagDataString()); } else if (tag == 0x04) { tags = tags.cloneWithArticulationDirection (convertArticulationDirection(riffInput.tagByteAt(0))); } else if (tag == 0x05) { tags = tags.cloneWithBezierIncoming (new Placement (riffInput.tagShortAt(0), riffInput.tagShortAt(2))); } else if (tag == 0x06) { tags = tags.cloneWithBezierOutgoing (new Placement (riffInput.tagShortAt(0), riffInput.tagShortAt(2))); } else if (tag == 0x07) { tags = tags.cloneWithChordSymbolOffset (riffInput.tagShortAt(0)); } // debug: add custom font character else if (tag == 0x09) { tags = tags.cloneWithCustomGraphic (riffInput.tagShortAt(0)); } else if (tag == 0x0a) { tags = tags.cloneWithEndOfSystem(true); } else if (tag == 0x0b) { tags = tags.cloneWithFannedBeam (convertFannedBeam(riffInput.tagShortAt(0))); } else if (tag == 0x0c) { tags = tags.cloneWithFiguredBass (riffInput.tagShortAt(0)); } // debug: add font ID else if (tag == 0x0e) { tags = tags.cloneWithGraceNote (new Rational (riffInput.tagShortAt(0), riffInput.tagShortAt(2))); } else if (tag == 0x0f) { tags = tags.cloneWithGuitarGridOffset (riffInput.tagShortAt(0)); } else if (tag == 0x10) { tags = tags.cloneWithGuitarTablature(true); } else if (tag == 0x11) { tags = tags.cloneWithHeight (riffInput.tagShortAt(0)); } else if (tag == 0x12) { tags = tags.cloneWithId (riffInput.tagShortAt(0)); } else if (tag == 0x13) { tags = tags.cloneWithInvisible(true); } else if (tag == 0x14) { tags = tags.cloneWithLargeSize(true); } else if (tag == 0x15) { tags = tags.cloneWithLineQuality (convertLineQuality(riffInput.tagByteAt(0))); } else if (tag == 0x16) { tags = tags.cloneWithLogicalPlacement (new LogicalPlacement (riffInput.tagByteAt(0), riffInput.tagByteAt(1), riffInput.tagByteAt(2))); } // debug: add lyric verse offset else if (tag == 0x18) { // (Note that NIFF 6a3 has start time and duration as a RATIONAL // but these have been corrected to a LONG.) tags = tags.cloneWithMidiPerformance (new MidiPerformance (riffInput.tagLongAt(0), riffInput.tagLongAt(4), riffInput.tagByteAt(8), riffInput.tagByteAt(9))); } else if (tag == 0x19) { tags = tags.cloneWithMultiNodeEndOfSystem(true); } else if (tag == 0x1a) { tags = tags.cloneWithMultiNodeStartOfSystem(true); } else if (tag == 0x1b) { tags = tags.cloneWithNumberOfFlags (riffInput.tagByteAt(0)); } else if (tag == 0x1c) { tags = tags.cloneWithNumberOfNodes (riffInput.tagShortAt(0)); } else if (tag == 0x1d) { tags = tags.cloneWithNumberOfStaffLines (riffInput.tagByteAt(0)); } else if (tag == 0x1e) { tags = tags.cloneWithOssia (convertOssia(riffInput.tagByteAt(0))); } else if (tag == 0x1f) { tags = tags.cloneWithPartDescriptionOverride (new PartDescriptionOverride (riffInput.tagSignedByteAt(0), riffInput.tagSignedByteAt(1), riffInput.tagSignedByteAt(2))); } else if (tag == 0x20) { tags = tags.cloneWithPartID (riffInput.tagShortAt(0)); } else if (tag == 0x21) { tags = tags.cloneWithReferencePointOverride (new ReferencePointOverride (riffInput.tagByteAt(0), riffInput.tagByteAt(1), riffInput.tagByteAt(2), riffInput.tagByteAt(3))); } else if (tag == 0x22) { tags = tags.cloneWithRehearsalMarkOffset (riffInput.tagShortAt(0)); } else if (tag == 0x23) { tags = tags.cloneWithRestNumeral (riffInput.tagShortAt(0)); } else if (tag == 0x24) { tags = tags.cloneWithSilent(true); } else if (tag == 0x25) { tags = tags.cloneWithSlashedStem(true); } else if (tag == 0x26) { tags = tags.cloneWithSmallSize(true); } else if (tag == 0x27) { tags = tags.cloneWithSpacingByPart(true); } else if (tag == 0x28) { tags = tags.cloneWithSplitStem(true); } else if (tag == 0x29) { tags = tags.cloneWithStaffName(true); } else if (tag == 0x2a) { tags = tags.cloneWithStaffStep (riffInput.tagSignedByteAt(0)); } else if (tag == 0x2b) { tags = tags.cloneWithThickness (riffInput.tagShortAt(0)); } else if (tag == 0x2c) { tags = tags.cloneWithTieDirection (convertTieDirection(riffInput.tagByteAt(0))); } else if (tag == 0x2d) { tags = tags.cloneWithTupletDescription (new TupletDescription (riffInput.tagShortAt(0), riffInput.tagShortAt(2), riffInput.tagShortAt(4), riffInput.tagShortAt(6), riffInput.tagByteAt(8))); } // NOTE: number style tag 0x2e is defined in niff.h but not in the NIFF spec else if (tag == 0x2f) { tags = tags.cloneWithVoiceID (riffInput.tagShortAt(0)); } else if (tag == 0x30) { tags = tags.cloneWithWidth (riffInput.tagShortAt(0)); } // else skip the unknown tag ID } // This skips possible pad byte riffInput.skipRemaining(); return(tags); }