Exemple #1
0
        void SendMidiNoteOff(int channel, int pitch, int velocity)
        {
            long tick = (long)(currentFrameNumber * tickMultiplier);

            // TODO: Why do I have to subtract 12 to get right notes?
            //midiTrack.Add(ShortEvent.CreateShortEvent((int) MidiHelper.MidiEventType.NoteOff, channel, pitch-12, velocity, tick));
            midiTrack.Add(ShortEvent.CreateShortEvent((int)MidiHelper.MidiEventType.NoteOff, channel, pitch - 12, 0, tick));
        }
Exemple #2
0
        public string BuildShortEventMessage(ShortEvent shortEvent)
        {
            var message = AddCaption(shortEvent.Name)
                          .AddTime(shortEvent.Date)
                          .AddPlace(shortEvent.Place)
                          .AddPrice(shortEvent.Price)
                          .AddMainText(shortEvent.Description)
                          .AddLink(shortEvent.Url)
                          .NewLine()
                          .Build();

            _stringBuilder.Clear();
            return(message);
        }
        private void LoadEventData(out string name, out string description, Descriptor[] descriptors)
        {
            // Descriptors we can have
            ShortEvent shortEvent = null;

            // Extended events
            List <ExtendedEvent> exEvents = new List <ExtendedEvent>();

            // Check all descriptors
            foreach (Descriptor descr in descriptors)
            {
                if (descr.IsValid)
                {
                    // Check type
                    if (null == shortEvent)
                    {
                        // Read
                        shortEvent = descr as ShortEvent;

                        // Done for now
                        if (null != shortEvent)
                        {
                            continue;
                        }
                    }

                    // Test
                    ExtendedEvent exEvent = descr as ExtendedEvent;

                    // Register
                    if (null != exEvent)
                    {
                        exEvents.Add(exEvent);
                    }
                }
            }

            // Reset all
            description = null;
            name        = null;

            // Take the best we got
            if (exEvents.Count > 0)
            {
                // Text builder
                StringBuilder text = new StringBuilder();

                // Process all
                foreach (ExtendedEvent exEvent in exEvents)
                {
                    // Normal
                    if (null == name)
                    {
                        name = exEvent.Name;
                    }

                    // Merge
                    if (exEvent.Text != null)
                    {
                        text.Append(exEvent.Text);
                    }
                }

                // Use
                description = text.ToString();
            }

            // Try short event
            if (null != shortEvent)
            {
                // Read
                if (null == name)
                {
                    name = shortEvent.Name;
                }
                if (null == description)
                {
                    description = shortEvent.Text;
                }

                // Check for additional information
                if (string.IsNullOrEmpty(name))
                {
                    name = shortEvent.Text;
                }
                else if (!string.IsNullOrEmpty(shortEvent.Text))
                {
                    name += string.Format(" ({0})", shortEvent.Text);
                }
            }
        }