public void SetsClef() { var abc = @" V:1 V:2 clef=treble V:3 clef = bass "; var tune = Tune.Load(abc); Assert.AreEqual(3, tune.voices.Count); Assert.AreEqual(Clef.Treble, tune.voices[0].clef); Assert.AreEqual(Clef.Treble, tune.voices[1].clef); Assert.AreEqual(Clef.Bass, tune.voices[2].clef); }
public void CannotAppearInline() { var infoFields = new List <string>() { "T:Hello World", "C:Matthew LaRocca", "X:1" }; foreach (var infoField in infoFields) { var abc = $"CDEF | [{infoField}] GABc"; Assert.ThrowsException <ParseException>(() => { Tune.Load(abc); }, infoField); } }
private void CheckCollectionThenAddCollectionAndTuneCollection(Tune tune) { var user = GetCurrentUser(); var collections = _collectionRepository.GetCollectionsByUserId(user.Id); List <Collection> currentCollection = collections.Where(c => (c.Name == tune.Tuning) || (c.Name == $"{tune.Key}/{tune.Tuning}")).ToList(); if (currentCollection.Count() == 0) { //collection doesn't exist //add Collection string collName = ""; if (tune.Tuning == "Standard") { collName = tune.Key; } else { collName = $"{tune.Key}/{tune.Tuning}"; } var collToAdd = new Collection() { UserProfileId = user.Id, Name = collName }; Collection newColl = _collectionRepository.saveCollection(collToAdd); var tc = new TuneCollection() { CollectionId = newColl.Id, TuneId = tune.Id }; _tuneRepo.AddTuneCollection(tc); } else { //collection exists //add TC var tc = new TuneCollection() { CollectionId = currentCollection[0].Id, TuneId = tune.Id }; _tuneRepo.AddTuneCollection(tc); } }
public void ToString_Success() { var tune = new Tune(new List <TuneElement> { new Note(Pitches.A, Scales.Four, Durations.Whole), new Note(Pitches.Asharp, Scales.Five, Durations.Half), new Pause(Durations.Quarter) }, 100 ); var expectedString = "6999 68#* 08"; var actualString = converter.ToString(tune); Assert.AreEqual(expectedString, actualString); }
private void On_MouseDown(MouseEventArgs e) { _leftButtonDown = true; _delta.Reset(e.Location); var clickedTick = _desktopRange.Minimum + e.Location.X * _ticksPerPixel; _selectedTune = _tunes.FirstOrDefault(tune => tune.TickRange.ContainsValue(clickedTick) && new Range(100 + tune.Track * 260, 100 + (tune.Track + 1) * 260).ContainsValue(e.Location.Y)); if (_selectedTune == null) { _playCursor = clickedTick; } Invalidate(); }
private void Import(FileInfo file) { var m = validator.Match(file.Name); if (m.Success) { var tune = new Tune(file.FullName); if (Tunes.Contains(tune)) { var match = Tunes.First(t => t.Equals(tune)); match.Merge(tune); } else { Tunes.Add(tune); } } }
public MainPage() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); tunerPage = new Tune() { Title = "Tune" }; savedPage = new SavedTunes() { Title = "Saved Tunes" }; this.Children.Add(tunerPage); this.Children.Add(savedPage); }
public void TestParseNone() { var inputs = new List <string>() { "K:", "K: \t", "K: none", "K:NONE" }; foreach (var input in inputs) { var tune = Tune.Load(input); Assert.AreEqual(1, tune.voices.Count); Assert.AreEqual(KeySignature.None, tune.voices[0].initialKey); } }
public void ParseSymbols() { var symbols = new List <string>() { "C", "C|" }; foreach (var symbol in symbols) { var abc = $"M:{symbol}\nC"; var tune = Tune.Load(abc); Assert.AreEqual(1, tune.voices.Count); var voice = tune.voices[0]; Assert.AreEqual(symbol, voice.initialTimeSignature, symbol); } }
static void LoadTunes(string filename) { string[] lines = System.IO.File.ReadAllLines(filename); bool hasTitle = false; bool hasAltTitle = false; Tune tune = null; for (int i = 0; i < lines.Count(); i++) { string line = lines[i]; // Seach for the X: header. If we find one, its a new tune... if (line.IndexOf("X:") != -1) { tune = new Tune(); tunes.Add(tune); hasTitle = false; hasAltTitle = false; tune.X = int.Parse(line.Substring(2)); } if (line.IndexOf("K:") != -1) { tune.KeySig = line.Substring(2); } if (line.IndexOf("M:") != -1) { tune.TimeSig = line.Substring(2); } if (line.IndexOf("T:") != -1) { if (hasTitle) { if (!hasAltTitle) { tune.AltTitle = line.Substring(2); hasAltTitle = true; } } else { tune.Title = line.Substring(2); hasTitle = true; } } } }
public void RegistrujPjesmuTest() { Tune t = new Tune( Convert.ToString(TestContext.DataRow["title"]), Convert.ToString(TestContext.DataRow["artist"]), Convert.ToString(TestContext.DataRow["album"]), Convert.ToString(TestContext.DataRow["genre"]), Convert.ToDouble(TestContext.DataRow["rating"]), Convert.ToString(TestContext.DataRow["format"]), Convert.ToInt32(TestContext.DataRow["length"]), Convert.ToInt32(TestContext.DataRow["bitRate"]), Convert.ToDouble(TestContext.DataRow["price"]) ); Assert.AreEqual(t.Title, Convert.ToString(TestContext.DataRow["title"])); Assert.AreEqual(t.Artist, Convert.ToString(TestContext.DataRow["artist"])); Assert.AreEqual(t.Price, Convert.ToDouble(TestContext.DataRow["price"])); }
private static void GetSetCurrentTune() { if (Settings.publishTuneInfo) { Tune currentTune = new Tune(); currentTune.artist = GUIPropertyManager.GetProperty("#Play.Current.Artist"); currentTune.title = GUIPropertyManager.GetProperty("#Play.Current.Title"); currentTune.source = GUIPropertyManager.GetProperty("#Play.Current.Album"); try { currentTune.track = int.Parse(GUIPropertyManager.GetProperty("#Play.Current.Track")); currentTune.length = (int)TimeSpan.Parse(GUIPropertyManager.GetProperty("#Play.Current.Duration")).TotalSeconds; currentTune.rating = int.Parse(GUIPropertyManager.GetProperty("#Play.Current.Rating")); } catch (Exception e) { Log.Error(e); } SetTune(currentTune); } }
private void PlaceNotes(Tune tune) { foreach (Transform child in uiNotesHolder.transform) { GameObject.Destroy(child.gameObject); } float accumDelay = 0; foreach (Tune.Note note in tune.notes) { accumDelay += note.delay; Vector2 position = new Vector2(xOffset + accumDelay * scale, 0f); //Debug.Log(position); RectTransform noteRT = Instantiate(uiNotePrefab, uiNotesHolder); noteRT.localPosition = position; } }
public void SetsTimeSignatureInline() { var commonTime = "4/4"; var cutTime = "2/2"; var abc = $"M:{commonTime}\nC[M:{cutTime}]"; var tune = Tune.Load(abc); Assert.AreEqual(1, tune.voices.Count); var voice = tune.voices[0]; Assert.AreEqual(commonTime, voice.initialTimeSignature); Assert.AreEqual(2, voice.items.Count); var timeSignature = voice.items[1] as TimeSignature; Assert.IsNotNull(timeSignature); Assert.AreEqual(cutTime, timeSignature.value); }
public SliderViewModel( SliderConfiguration Configuration, IControlTuningService <SliderConfiguration> TuningService) { this.Configuration = Configuration; this.WhenAnyValue(x => x.UserValue, x => x.Precision, (v, p) => v.ToString("F" + p)) .ToProperty(this, x => x.OutputValueString, out _outputValueString); Tune = ReactiveCommand.CreateFromTask(() => TuningService.Tune(this.Configuration)); Tune.ObserveOnDispatcher() .BindTo(this, x => x.Configuration); Tune.IsExecuting .Select(x => !x) .ToProperty(this, x => x.IsEditable, out _isEditable); }
/// <summary> /// Updates the bard's progress through the current tune. /// </summary> public void UpdateTune() { // Reset the current button. pressedButton = ControllerInputWrapper.Buttons.Start; // Plays the tune on the beat. if (currentTune != null && buttonPressDelayTimer < 0f && LevelManager.instance.PerfectTiming(rhythmType) >= modifiedThreshold) { pressedButton = currentTune.tune[tuneProgress]; if (++tuneProgress >= currentTune.tune.Length) { tuneProgress = 0; currentTune = null; } buttonPressDelay = Mathf.Max(buttonPressDelayTimer, noteDelay); modifiedThreshold = Tune.PERFECT_THRESHOLD + Random.Range(-timingVariance, timingVariance); } }
public void Body() { var expectedTypes = new List <Item.Type>() { Item.Type.Note, Item.Type.Chord, Item.Type.Note, Item.Type.Chord, Item.Type.Bar, Item.Type.Note }; var tune = Tune.Load("_a' [CEF]B[^gAB]|^F"); Assert.AreEqual(1, tune.voices.Count); var voice = tune.voices[0]; Assert.AreEqual(expectedTypes.Count, voice.items.Count); for (int i = 0; i < expectedTypes.Count; i++) { Assert.AreEqual(expectedTypes[i], voice.items[i].type); } }
public void DoesNotBeamNotesWithWhitespace() { var abc = "[L:1/8]a b[L:1/16]b c"; var tune = Tune.Load(abc); Assert.AreEqual(1, tune.voices.Count); var voice = tune.voices[0]; Assert.AreEqual(4, voice.items.Count); foreach (var item in voice.items) { var noteItem = item as Note; Assert.IsNotNull(noteItem); Assert.AreEqual(0, noteItem.beam); } }
public void TuneNotInRange(int startTick) { // |-----| // |=====| | | |=====| // 400 500 600 700 800 900 // _mockFrameData.Setup(f => f.Length).Returns(100); var window = new Range(600, 700); var tune = new Tune(_mockFrameData.Object) { StartTick = startTick }; var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum)); Assert.Equal(-100, visibleTicks); }
private void IterateTune(Tune t) { buttonPressDelayTimer = buttonPressDelay; LevelManager.instance.playerUI[(int)control.player - 1].TuneProgressed(t); StopAllCoroutines(); StartCoroutine(TuneTimeOut()); if (t.IterateTune()) { foreach (Tune x in tunes) { x.ResetTune(); LevelManager.instance.playerUI[(int)control.player - 1].TuneReset(); currentTunes.Clear(); } } }
public void LinebreakEOL() { var abc = "I:linebreak <EOL>\nC\nz\nC"; var expectedTypes = new List <Item.Type>() { Item.Type.Note, Item.Type.LineBreak, Item.Type.Rest, Item.Type.LineBreak, Item.Type.Note }; var tune = Tune.Load(abc); Assert.AreEqual(1, tune.voices.Count); var voice = tune.voices[0]; Assert.AreEqual(expectedTypes.Count, voice.items.Count); for (int i = 0; i < expectedTypes.Count; i++) { Assert.AreEqual(expectedTypes[i], voice.items[i].type); } }
public void CreateInTuneBody() { var abc = @" X:1 [V:1] C [V:2 clef=bass] D"; var tune = Tune.Load(abc); Assert.AreEqual(2, tune.voices.Count); Assert.AreEqual(Clef.Treble, tune.voices[0].clef); var noteItem = tune.voices[0].items[0] as Note; Assert.AreEqual(Pitch.C4, noteItem.pitch); Assert.AreEqual(Clef.Bass, tune.voices[1].clef); noteItem = tune.voices[1].items[0] as Note; Assert.AreEqual(Pitch.D4, noteItem.pitch); }
private void IterateTune(Tune t) { buttonPressDelayTimer = buttonPressDelay; LevelManager.instance.GetPlayerUI(control.player).TuneProgressed(t); StopAllCoroutines(); StartCoroutine(TuneTimeOut()); if (t.IterateTune()) { RegisterNoteCorrect(true); foreach (Tune x in tunes) { x.ResetTune(); LevelManager.instance.GetPlayerUI(control.player).TuneReset(); currentTunes.Clear(); } } }
void OnRedraw(Tune cartridge) { Builder.IgnoreEvents = true; /*Cartridge*/ NameBind.text = Builder.AssembledData.Name; ColorBind.SetValue(Builder.AssembledData.TuneColor); RequirementMaskBind.Value = Builder.AssembledData.RequirementMask; DiscriptionBind.text = Builder.AssembledData.Description; IsExBind.isOn = Builder.AssembledData.IsEx; SuccessRateBind.text = Builder.AssembledData.SuccessRate.ToString(); /*Modifiers*/ CostBind.text = Builder.AssembledData.Stats.COST.ToString(); HPBind.text = Builder.AssembledData.Stats.HP.ToString(); STRBind.text = Builder.AssembledData.Stats.STR.ToString(); TECBind.text = Builder.AssembledData.Stats.TEC.ToString(); WLKBind.text = Builder.AssembledData.Stats.WLK.ToString(); FLYBind.text = Builder.AssembledData.Stats.FLY.ToString(); TGHBind.text = Builder.AssembledData.Stats.TGH.ToString(); CAPABind.text = Builder.AssembledData.Stats.CAPA.ToString(); MainForceBind.text = Builder.AssembledData.MainStats.Force.ToString(); MainAmmoBind.text = Builder.AssembledData.MainStats.Ammo.ToString(); MainRangeBind.text = Builder.AssembledData.MainStats.Range.ToString(); MainSpeedBind.text = Builder.AssembledData.MainStats.Speed.ToString(); MainIntBind.text = Builder.AssembledData.MainStats.Int.ToString(); MainForceMultiplierBind.text = Builder.AssembledData.MainMultiplier.Force.ToString(); MainAmmoMultiplierBind.text = Builder.AssembledData.MainMultiplier.Ammo.ToString(); MainRangeMultiplierBind.text = Builder.AssembledData.MainMultiplier.Range.ToString(); MainSpeedMultiplierBind.text = Builder.AssembledData.MainMultiplier.Speed.ToString(); MainIntMultiplierBind.text = Builder.AssembledData.MainMultiplier.Int.ToString(); SubForceBind.text = Builder.AssembledData.SubStats.Force.ToString(); SubAmmoBind.text = Builder.AssembledData.SubStats.Ammo.ToString(); SubRangeBind.text = Builder.AssembledData.SubStats.Range.ToString(); SubSpeedBind.text = Builder.AssembledData.SubStats.Speed.ToString(); SubIntBind.text = Builder.AssembledData.SubStats.Int.ToString(); SubForceMultiplierBind.text = Builder.AssembledData.SubMultiplier.Force.ToString(); SubAmmoMultiplierBind.text = Builder.AssembledData.SubMultiplier.Ammo.ToString(); SubRangeMultiplierBind.text = Builder.AssembledData.SubMultiplier.Range.ToString(); SubSpeedMultiplierBind.text = Builder.AssembledData.SubMultiplier.Speed.ToString(); SubIntMultiplierBind.text = Builder.AssembledData.SubMultiplier.Int.ToString(); Builder.IgnoreEvents = false; }
public ActionResult Create(TuneFormViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Genres = _context.Genres.ToList(); return(View("Create", viewModel)); } var tune = new Tune { ArtistId = User.Identity.GetUserId(), DateTime = viewModel.GetDateTime(), GenreId = viewModel.Genre, Venue = viewModel.Venue }; _context.Tunes.Add(tune); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
void Start() { control = GetComponent <PlayerControl>(); Tune[] tempTunes = new Tune[tunes.Length]; for (int i = 0; i < tunes.Length; i++) { Tune temp = (Tune)GameObject.Instantiate(tunes[i], Vector3.zero, Quaternion.identity); tempTunes[i] = temp; tempTunes[i].ownerTransform = transform; temp.transform.parent = transform; } tunes = tempTunes; if (volumeOverride != 0) { GetComponent <AudioSource>().volume = volumeOverride; } }
// Registracija novog korisnika na aplikaciju public String registrirajKorisnika(String i, String p, DateTime dr, String bkk, String un, String pass) { if (daLiPostoji(un)) { throw new Exception("Korisnik sa datim passwordom već postoji."); } RegisteredMember rm = new RegisteredMember(i, p, dr, bkk, un, p); rm.Id = Guid.NewGuid().ToString(); RegMembers.Add(rm); if (dr.Month == 2 && dr.Day == 24) // Rođendan Steve Jobs-a { Tune t = new Tune("Happy Birthday", "Patty Hill, Mildred J. Hill", "None", "Folk", 9.8, ".mp3", 60, 320, 9.50); rm.MojaBiblioteka.Add(t); } return(rm.Id); }
void Awake() { if (Instance == null) { DontDestroyOnLoad(this.gameObject); instance = this; } else if (this != Instance) { Destroy(this.gameObject); return; } isElimination = true; canPause = false; level = "Test"; tunes = new Tune[4][]; numOfPlayers = 4; for (int i = 0; i < tunes.Length; i++) { tunes[i] = new Tune[3]; for (int j = 0; j < tunes[i].Length; j++) { tunes[i][j] = defaultTunes[j]; } } clips = new AudioClip[4]; for (int i = 0; i < clips.Length; i++) { clips[i] = defaultClips[i]; } clipInstrumentMap = new Dictionary <AudioClip, int>(defaultClips.Length); for (int i = 0; i < defaultClips.Length; i++) { clipInstrumentMap.Add(defaultClips[i], i); } instruments = new GameObject[4]; DontDestroyOnLoad(this.gameObject); isAIPlayer = new bool[4]; }
/// <summary> /// Stops user tune publications /// </summary> public IXmppSession StopTunePublication() { var iq = new IQ(); var pubsub = new PubSub(); var publish = new PubSubPublish(); var item = new PubSubItem(); var tune = new Tune(); iq.Items.Add(pubsub); pubsub.Items.Add(publish); publish.Items.Add(item); iq.From = UserId.ToString(); iq.ID = XmppIdentifierGenerator.Generate(); iq.Type = IQType.Set; publish.Node = XmppFeatures.UserMood; item.Item = tune; Send(iq); return(this); }
public void TestCustomBar() { var customBars = new List <string>() { "[|:::", "|[|" }; foreach (var customBar in customBars) { var abc = $"X:1\nL:1/4\nK:C\nCCCC{customBar}"; var tune = Tune.Load(abc); Assert.AreEqual(1, tune.voices.Count); var voice = tune.voices[0]; Assert.AreEqual(5, voice.items.Count); var bar = voice.items[4] as CustomBar; Assert.IsNotNull(bar); Assert.AreEqual(customBar, bar.str, customBar); } }
public void SoundGeneratorSimpleTest() { const int sampleRate = 44100; var tune = new Tune(); var oscillator = new SineOscillator(sampleRate); var frequenceRepository = new Frequences(); var A440 = frequenceRepository[Pitches.A, Scales.Four]; var data = new List <double>(); oscillator.SetFrequency(A440); for (int i = 0; i < sampleRate; i++) { data.Add(oscillator.GetNext(i)); } //SoundGenerator.(data.ToArray(), data.Count, sampleRate); Assert.Fail("Not yet totally implmented !"); }
void Play(int index) { index %= playQueue.Count(); Tune tune = playQueue[index]; if (tune != null && tune != playing) { player.Load(tune.Path); tune.Duration = player.Duration; playing = tune; } playlist.SelectedIndices.Clear(); playlist.SelectedIndices.Add(index); player.PlayOrPause(); RefreshStatus(); }
private void TrackChanged(object sender, EventArgs args) { NowPlayingService nowPlaying = ServiceManager.Get<NowPlayingService>(); PubSubItem itemElement = new PubSubItem(m_Account.Client.Document); itemElement.SetAttribute("id", "current"); Tune tune = new Tune(m_Account.Client.Document); itemElement.AppendChild(tune); if (nowPlaying.IsPlaying) { tune.Artist = nowPlaying.CurrentTrackArtist; tune.Length = nowPlaying.CurrentTrackLength; tune.Rating = nowPlaying.CurrentTrackRating; tune.Source = nowPlaying.CurrentTrackSource; tune.Title = nowPlaying.CurrentTrackTitle; tune.Track = nowPlaying.CurrentTrackNumber; tune.Uri = nowPlaying.CurrentTrackUri; } m_Account.GetFeature<PersonalEventing>().Publish(Namespace.Tune, itemElement); }