当前位置: 首页>>代码示例>>C#>>正文


C# Pitch类代码示例

本文整理汇总了C#中Pitch的典型用法代码示例。如果您正苦于以下问题:C# Pitch类的具体用法?C# Pitch怎么用?C# Pitch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Pitch类属于命名空间,在下文中一共展示了Pitch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: YPitchBendCube

        public YPitchBendCube(Point3D center, double radius, 
                Pitch pitch, Instrument instrument, OutputDevice device, Channel channel)
            : base(center, radius, new InstrumentNoteAction(device, channel, pitch)) {

                outputDevice = device;
                this.channel = channel;
        }
开发者ID:probuilderz,项目名称:balloon,代码行数:7,代码来源:YPitchBendCube.cs

示例2: GenerateMajor

        public Chord GenerateMajor(Pitch root, int inversion, int startInterval, NoteLength noteLength, byte velocity = 100)
        {
            var inversionOffset = new int[3];

            switch (inversion)
            {
                case 0:
                    inversionOffset = NoInversion;
                    break;
                case 1:
                    inversionOffset = FirstInversion;
                    break;
            };

            int note1 = (int)root + inversionOffset[0];
            int note2 = (int)root + inversionOffset[1];
            int note3 = (int)root + inversionOffset[2];

            var notes = new List<Note>
            {
                new Note(PitchCode.GetNoteName(note1), startInterval, noteLength, velocity),
                new Note(PitchCode.GetNoteName(note2), startInterval, noteLength, velocity),
                new Note(PitchCode.GetNoteName(note3), startInterval, noteLength, velocity)
            };

            return new Chord
            {
                Notes = notes
            };
        }
开发者ID:Jbtyson,项目名称:cis598,代码行数:30,代码来源:ChordGenerator.cs

示例3: FindMatchesInBuffer

        public MidiMappingRecord[] FindMatchesInBuffer(Pitch[] buffer)
        {
            var results = new List<MidiMappingRecord>();
            var events = buffer.Cast<Pitch?>().ToArray();

            // Process chords first. Try to capture a chord with as many notes as possible.
            // This is O(scary), but seems quick enough in practice. (c) StackOverflow #184618
            foreach (var mapping in chordMappingsOrdered)
            {
                bool isChordComplete = mapping.Trigger.Pitches.All(p => events.Any(e => e.HasValue && e == p));
                if (isChordComplete)
                {
                    // Exclude matched notes from further processing.
                    for (int i = 0; i < events.Length; i++)
                    {
                        var pitch = events[i].Value;
                        if (mapping.Trigger.Pitches.Any(p => p == pitch))
                        {
                            events[i] = null;
                        }
                    }
                    results.Add(mapping);
                }
            }

            // Process remaining single notes.
            foreach (var e in events.Where(e => e.HasValue))
            {
                results.AddRange(FindSingleNoteMatches(e.Value));
            }

            return results.ToArray();
        }
开发者ID:ExSan,项目名称:midichlorian,代码行数:33,代码来源:MidiMappingMatcher.cs

示例4: ToggleBox

 public ToggleBox(int left, int top, Pitch pitch)
 {
     newToggleBox();
     this.Left = left;
     this.Top = top;
     this.pitch = pitch;
 }
开发者ID:mrreband,项目名称:MidiLooper,代码行数:7,代码来源:ToggleBox.cs

示例5: randomSpawnParticle

 /// <summary>
 /// Spawns the particle system randomly inside a sphere of size
 /// randomRadius and centered on this object.
 /// </summary>
 public void randomSpawnParticle(ParticleSystem ps, Pitch pitch)
 {
     Vector3 randOffset = Random.insideUnitSphere * randomRadius;
     Vector3 center = this.transform.position;
     ParticleSystem tempParticles =
         Instantiate(ps, center + randOffset, Quaternion.identity) as ParticleSystem;
     tempParticles.startColor = NoteDecorator.pitchToColor(pitch);
 }
开发者ID:TravisDean,项目名称:MEZ,代码行数:12,代码来源:ParticleScriptSpawnEffector.cs

示例6: LibNoteMessage

		internal LibNoteMessage(Pitch pitch, int velocity, float time, MessageType type, int channel)
		{
			Pitch = pitch;
			Velocity = velocity;
			Time = time;
			Type = type;
			Channel = channel;
		}
开发者ID:joha4270,项目名称:AAU-P2,代码行数:8,代码来源:Note.cs

示例7: DoAction

 public void DoAction() {
     // start playing the note
     if (!isPlaying) {
         if (!internalPitch.IsInMidiRange())
             internalPitch = Pitch.C4;
         Device.SendNoteOn(Channel, internalPitch, 64 );
         isPlaying = true;
     }
 }
开发者ID:probuilderz,项目名称:balloon,代码行数:9,代码来源:InstrumentNoteAction.cs

示例8: Pitch_Plus_Interval_Gives_Higher_Pitch

        public void Pitch_Plus_Interval_Gives_Higher_Pitch()
        {
            var original = new Pitch(100);
            var second = new Interval(IntervalDistance.MajorSecond);

            var higher = original + second;

            Assert.True(higher > original);
            Assert.Equal(IntervalDistance.MajorSecond, (higher - original).Distance);
        }
开发者ID:deejaygraham,项目名称:tedesco,代码行数:10,代码来源:PitchTests.cs

示例9: Run

 public override void Run()
 {
     OutputDevice outputDevice = ExampleUtil.ChooseOutputDeviceFromConsole();
     char inp;
     int dx;
     Pitch[] notes=new Pitch[7] { Pitch.A4, Pitch.B4, Pitch.C4, Pitch.D4, Pitch.E4, Pitch.F4, Pitch.G4 };
     Percussion[] drums=new Percussion[3] { Percussion.BassDrum1, Percussion.MidTom1, Percussion.CrashCymbal1 };
     if(outputDevice==null) {
         Console.WriteLine("\nNo output devices, so can't run this example.");
         ExampleUtil.PressAnyKeyToContinue();
         return;
     }
     if(!File.Exists(PiPath)) {
         Console.WriteLine("\nCould not find the data file: {0}", PiPath);
         ExampleUtil.PressAnyKeyToContinue();
         return;
     }
     Console.WriteLine("This didn't turn out well at all. A back beat may help it but I'm moving on for now.\n\n");
     Console.WriteLine("The follow 10 notes will be used:");
     for(dx=0; dx<10 && Console.KeyAvailable==false; dx++) {
         if(dx>=notes.Length) {
             Console.WriteLine("\tDigit {0} is represented by a {1} drum.", dx, drums[dx-notes.Length].ToString());
         } else {
             Console.WriteLine("\tDigit {0} is represented by a {1} note.", dx, notes[dx].ToString());
         }
     }
     Console.WriteLine("Interpreting Pi...Press any key to stop...\n\n");
     outputDevice.Open();
     // outputDevice.SendProgramChange(Channel.Channel1, Instrument.AltoSax);
     outputDevice.SendControlChange(Channel.Channel1, Control.SustainPedal, 0);
     try {
         using(StreamReader sr=new StreamReader(PiPath)) {
             while(sr.Peek()>=0 && Console.KeyAvailable==false) {
                 inp=(char)sr.Read();
                 if(Char.IsNumber(inp)) { // Skip over non numbers.
                     Console.Write(inp);
                     dx=(int)Char.GetNumericValue(inp);
                     if(dx>=notes.Length) outputDevice.SendPercussion(drums[dx-notes.Length], 90);
                     else outputDevice.SendNoteOn(Channel.Channel1, notes[dx], 80);
                     Thread.Sleep(500);
                 }
             }
         }
     } catch(FieldAccessException e) {
         Console.WriteLine("\nError: Could not access file {0}\n\nThe exception was: {1}\n", PiPath, e.Message);
     } catch(Exception e) {
         Console.WriteLine("\nError: {1}\n", PiPath, e.Message);
     }
     outputDevice.Close();
     while(Console.KeyAvailable) { Console.ReadKey(false); }
     Console.WriteLine();
     ExampleUtil.PressAnyKeyToContinue();
 }
开发者ID:krowe,项目名称:MidiPi,代码行数:53,代码来源:PiTest02.cs

示例10: DecodeNoteOff

 /// <summary>
 /// Decodes a Note Off short message.
 /// </summary>
 /// <param name="dwParam1">The dwParam1 arg passed to MidiInProc.</param>
 /// <param name="dwParam2">The dwParam2 arg passed to MidiInProc.</param>
 /// <param name="channel">Filled in with the channel.</param>
 /// <param name="pitch">Filled in with the pitch.</param>
 /// <param name="velocity">Filled in with the velocity, 0.127</param>
 /// <param name="timestamp">Filled in with the timestamp in microseconds since
 /// midiInStart().</param>
 public static void DecodeNoteOff(UIntPtr dwParam1, UIntPtr dwParam2,
     out Channel channel, out Pitch pitch, out int velocity, out UInt32 timestamp)
 {
     if (!IsNoteOff(dwParam1, dwParam2))
     {
         throw new ArgumentException("Not a Note Off message.");
     }
     channel = (Channel)((int)dwParam1 & 0x0f);
     pitch = (Pitch)(((int)dwParam1 & 0xff00) >> 8);
     velocity = (((int)dwParam1 & 0xff0000) >> 16);
     timestamp = (UInt32)dwParam2;
 }
开发者ID:krowe,项目名称:MidiPi,代码行数:22,代码来源:ShortMsg.cs

示例11: Run

 public override void Run()
 {
     OutputDevice outputDevice = ExampleUtil.ChooseOutputDeviceFromConsole();
     char inp;
     int dx;
     Pitch[] notes=new Pitch[10] { Pitch.F3, Pitch.A4, Pitch.B4, Pitch.C4, Pitch.D4, Pitch.E4, Pitch.F4, Pitch.G4, Pitch.A5, Pitch.B6 };
     if(outputDevice==null) {
         Console.WriteLine("\nNo output devices, so can't run this example.");
         ExampleUtil.PressAnyKeyToContinue();
         return;
     }
     if(!File.Exists(PiPath)) {
         Console.WriteLine("\nCould not find the data file: {0}", PiPath);
         ExampleUtil.PressAnyKeyToContinue();
         return;
     }
     Console.WriteLine("This version simply pads the extra data space with notes from adjacent octaves.\n");
     Console.WriteLine("This version many will say is the most accurately reproduction of Pi. That may be true but "+
         "at the same time every way of doing this involves a lot of fiddling with the numbers anyway. I wouldn't "+
         "be surprised if there are people out there who could listen to this and write down the digits. That "+
         "is probably not true of most of the other methods.\n\n");
     Console.WriteLine("The follow 10 notes will be used:");
     for(dx=0; dx<10 && Console.KeyAvailable==false; dx++) {
         Console.WriteLine("\tDigit {0} is represented by a {1} note.", dx, notes[dx].ToString());
     }
     Console.WriteLine("Interpreting Pi...Press any key to stop...\n\n");
     outputDevice.Open();
     // outputDevice.SendProgramChange(Channel.Channel1, Instrument.AltoSax);
     outputDevice.SendControlChange(Channel.Channel1, Control.SustainPedal, 0);
     try {
         using(StreamReader sr=new StreamReader(PiPath)) {
             while(sr.Peek()>=0 && Console.KeyAvailable==false) {
                 inp=(char)sr.Read();
                 if(Char.IsNumber(inp)) { // Skip over non numbers.
                     Console.Write(inp);
                     outputDevice.SendNoteOn(Channel.Channel1, notes[(int)Char.GetNumericValue(inp)], 80);
                     Thread.Sleep(200);
                     outputDevice.SendNoteOff(Channel.Channel1, notes[(int)Char.GetNumericValue(inp)], 80);
                     Thread.Sleep(100);
                 }
             }
         }
     } catch(FieldAccessException e) {
         Console.WriteLine("\nError: Could not access file {0}\n\nThe exception was: {1}\n", PiPath, e.Message);
     } catch(Exception e) {
         Console.WriteLine("\nError: {1}\n", PiPath, e.Message);
     }
     outputDevice.Close();
     while(Console.KeyAvailable) {Console.ReadKey(false);}
     Console.WriteLine();
     ExampleUtil.PressAnyKeyToContinue();
 }
开发者ID:krowe,项目名称:MidiPi,代码行数:52,代码来源:PiTest01.cs

示例12: ProcessPitch

 /// <summary>
 /// 初略想法,等待弹奏事件,正确就继续,错误继续等待
 /// 同GamePlayer CurrentEvent 需要改造
 /// </summary>
 /// <param name="pitch"></param>
 private void ProcessPitch(Pitch pitch)
 {
     Console.WriteLine("pitch:" + pitch + " waitPitch:" + waitPitch);
     if (pitch == waitPitch)
     {
         processer.Continue();
         OnLearing(true, null);
     }
     else
     {
         OnLearing(false, null);
     }
 }
开发者ID:yugsh,项目名称:PianoGame,代码行数:18,代码来源:LearningPlayer.cs

示例13: EncodeNoteOn

 /// <summary>
 /// Encodes a Note On short message.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="pitch">The pitch.</param>
 /// <param name="velocity">The velocity 0..127.</param>
 /// <returns>A value that can be passed to midiOutShortMsg.</returns>
 /// <exception cref="ArgumentOutOfRangeException">pitch is not in MIDI range.</exception>
 public static UInt32 EncodeNoteOn(Channel channel, Pitch pitch, int velocity)
 {
     channel.Validate();
     if (!pitch.IsInMidiRange())
     {
         throw new ArgumentOutOfRangeException("Pitch out of MIDI range.");
     }
     if (velocity < 0 || velocity > 127)
     {
         throw new ArgumentOutOfRangeException("Velocity is out of range.");
     }
     return (UInt32)(0x90 | ((int)channel) | ((int)pitch << 8) | (velocity << 16));
 }
开发者ID:bejotka77,项目名称:midi-dot-net,代码行数:21,代码来源:ShortMsg.cs

示例14: LearningPlayer

        public LearningPlayer(InputDevice input, MidiFile midifile, MidiOptions midiOption)
        {
            processer = new MidiProcesser(midifile, midiOption);
            inputDevice = input;
            inputDevice.NoteOn += delegate(NoteOnMessage msg)
            {
                ProcessPitch(msg.Pitch);
            };

            processer.NoteOn += delegate(Channel channel, Pitch pitch, int velocity)
            {
                waitPitch = pitch;
                processer.Stop();
            };
        }
开发者ID:yugsh,项目名称:PianoGame,代码行数:15,代码来源:LearningPlayer.cs

示例15: ThirdChordNote

        private List<Pitch> ThirdChordNote(Pitch pitch1, Pitch pitch2)
        {
            List<Pitch> p;

            Pitch[] pitchnote1 = Second[pitch1];
            if (Second.ContainsKey(pitch2))
            {
                Pitch[] pitchnote2 = Second[pitch2];
                p =  pitchnote1.Intersect(pitchnote2).ToList();
            }
            else
            {
                p = pitchnote1.ToList();
            }
            p.Remove(pitch2);
            return p;
        }
开发者ID:Rumu11,项目名称:AAU-P2,代码行数:17,代码来源:BrotherGenerator.cs


注:本文中的Pitch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。