public Track Get(string name) { if (IsDisposed) { throw new ObjectDisposedException($"Cannot retrieve items for an already disposed {nameof(PreviewTrackStore)}"); } if (string.IsNullOrEmpty(name)) { return(null); } var dataStream = store.GetStream(name); if (dataStream == null) { return(null); } // Todo: This is quite unsafe. TrackBass shouldn't be exposed as public. Track track = new TrackBass(dataStream); defaultMixer.Add(track); AddItem(track); return(track); }
public void Setup() { bass = new BassTestComponents(); track = bass.GetTrack(); bass.Update(); }
private void load(ITrackStore tracks) { bassTrack = (TrackBass)tracks.Get("sample-track.mp3"); int length = bassTrack.CurrentAmplitudes.FrequencyAmplitudes.Length; Children = new Drawable[] { track = new DrawableTrack(bassTrack), new GridContainer { RelativeSizeAxes = Axes.Both, Content = new[] { new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { leftChannel = new Box { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.CentreRight, }, rightChannel = new Box { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.CentreLeft, } } }, }, new Drawable[] { amplitudeBoxes = new Container { RelativeSizeAxes = Axes.Both, ChildrenEnumerable = Enumerable.Range(0, length) .Select(i => new Box { RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.X, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Width = 1f / length, X = (float)i / length }) }, } } }, }; }
private WeakReference <TrackBass> testDisposeTrackWithoutReference() { var weakRef = new WeakReference <TrackBass>(track); track.Dispose(); track = null; return(weakRef); }
public void Setup() { // Initialize bass with no audio to make sure the test remains consistent even if there is no audio device. Bass.Init(0); resources = new DllResourceStore(typeof(TrackBassTest).Assembly); track = new TrackBass(resources.GetStream("Resources.Tracks.sample-track.mp3")); updateTrack(); }
public TrackBassTest() { Architecture.SetIncludePath(); // Initialize bass with no audio to make sure the test remains consistent even if there is no audio device. Bass.Init(0); var resources = new DllResourceStore("osu.Framework.Tests.dll"); var fileStream = resources.GetStream("Resources.Tracks.sample-track.mp3"); track = new TrackBass(fileStream); }
public void play(BeatmapInfo Beatmap, BeatmapDatabase Database) { using (var reader = Database.GetReader(Beatmap.BeatmapSet)) using (var file = reader.GetStream(Beatmap.Metadata?.AudioFile ?? Beatmap.BeatmapSet.Metadata.AudioFile)) { MemoryStream ms = new MemoryStream(); file.CopyTo(ms); System.Diagnostics.Debug.Print("Loaded file of size {0}", ms.Length); Track track = new TrackBass(ms); Audio.Track.SetExclusive(track); track.Start(); } }
private void load(AudioManager audio, Game game) { AddStep("Play track", () => { Track = new TrackBass(game.Resources.GetStream("Tracks/" + TestLevel.Metadata.Level.LevelName + "/" + TestLevel.SongUrl)); audio.AddItem(Track); Track.Start(); }); AddStep("Stop track", () => { Track.Stop(); Track.Seek(0); }); }
public void Setup() { if (RuntimeInfo.OS == RuntimeInfo.Platform.Linux) { // required for the time being to address libbass_fx.so load failures (see https://github.com/ppy/osu/issues/2852) Library.Load("libbass.so", Library.LoadFlags.RTLD_LAZY | Library.LoadFlags.RTLD_GLOBAL); } // Initialize bass with no audio to make sure the test remains consistent even if there is no audio device. Bass.Init(0); resources = new DllResourceStore(typeof(TrackBassTest).Assembly); track = new TrackBass(resources.GetStream("Resources.Tracks.sample-track.mp3")); updateTrack(); }
public void TestTrackReferenceLostWhenTrackIsDisposed() { track.Dispose(); // The first update disposes the track, the second one removes the track from the TrackStore. bass.Update(); bass.Update(); var trackReference = new WeakReference <TrackBass>(track); track = null; GC.Collect(); GC.WaitForPendingFinalizers(); Assert.That(!trackReference.TryGetTarget(out _)); }
public Track Get(string name) { if (IsDisposed) { throw new ObjectDisposedException($"Cannot retrieve items for an already disposed {nameof(PreviewTrackStore)}"); } if (string.IsNullOrEmpty(name)) { return(null); } var dataStream = store.GetStream(name); if (dataStream == null) { return(null); } Track track = new TrackBass(dataStream); AddItem(track); return(track); }
private void load(Game game, AudioManager audio) { track = new TrackBass(game.Resources.GetStream("Tracks/sample-track.mp3")); audio.Track.AddItem(track); var waveform = new Waveform(game.Resources.GetStream("Tracks/sample-track.mp3")); FillFlowContainer flow; const float track_width = 1366; // required because RelativeSizeAxes.X doesn't seem to work with horizontal scroll Child = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Spacing = new Vector2(10), Children = new Drawable[] { button = new Button { Text = "Start", Size = new Vector2(100, 50), BackgroundColour = Color4.DarkSlateGray, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Action = startStop }, new SpriteText { Text = "Zoom Level:", Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, }, new BasicSliderBar <float> { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Size = new Vector2(200, 40), Current = zoom }, }, }, new ScrollContainer(Direction.Horizontal) { RelativeSizeAxes = Axes.Both, Child = flow = new FillFlowContainer { RelativeSizeAxes = Axes.Y, Width = track_width, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10) } } } }; for (int i = 1; i <= 16; i *= 2) { flow.Add(new TestWaveform(track, 1f / i) { Waveform = waveform }); } zoom.ValueChanged += v => flow.Width = track_width * v; }
public void Setup() { track = new TrackBass(resources.GetStream("Resources.Tracks.sample-track.mp3")); track.Update(); }