Exemple #1
0
        public MIDIPatternIO(GraphicsDevice gd, ImGuiView view, Func <Vector2> computeSize, MIDIPatternConnect pattern) : base(gd, view, computeSize)
        {
            Buffers = new BufferList <VertexPositionColor> [257]; // first buffer for general purpose, others for keys
            for (int i = 0; i < 257; i++)
            {
                Buffers[i] = dispose.Add(new BufferList <VertexPositionColor>(gd, 6 * 2048 * 16, new[] { 0, 3, 2, 0, 2, 1 }));
            }
            PatternHandler     = pattern;
            CurrentInteraction = new MIDIPatternInteractionIdle(PatternHandler);

            ProjMatrix = Factory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer | BufferUsage.Dynamic));
            dispose.Add(ProjMatrix);

            VertexLayoutDescription vertexLayout = new VertexLayoutDescription(
                new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2),
                new VertexElementDescription("Color", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float4));

            Layout = Factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                      new ResourceLayoutElementDescription("ProjectionMatrixBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex)));
            dispose.Add(Layout);

            ShaderDescription vertexShaderDesc = new ShaderDescription(
                ShaderStages.Vertex,
                Encoding.UTF8.GetBytes(VertexCode),
                "main");
            ShaderDescription fragmentShaderDesc = new ShaderDescription(
                ShaderStages.Fragment,
                Encoding.UTF8.GetBytes(FragmentCode),
                "main");

            Shaders = dispose.AddArray(Factory.CreateFromSpirv(vertexShaderDesc, fragmentShaderDesc));

            var pipelineDescription = new GraphicsPipelineDescription();

            pipelineDescription.BlendState        = BlendStateDescription.SingleAlphaBlend;
            pipelineDescription.DepthStencilState = new DepthStencilStateDescription(
                depthTestEnabled: true,
                depthWriteEnabled: true,
                comparisonKind: ComparisonKind.LessEqual);
            pipelineDescription.RasterizerState = new RasterizerStateDescription(
                cullMode: FaceCullMode.Front,
                fillMode: PolygonFillMode.Solid,
                frontFace: FrontFace.Clockwise,
                depthClipEnabled: true,
                scissorTestEnabled: false);
            pipelineDescription.PrimitiveTopology = PrimitiveTopology.TriangleList;
            pipelineDescription.ResourceLayouts   = new ResourceLayout[] { Layout };
            pipelineDescription.ShaderSet         = new ShaderSetDescription(
                vertexLayouts: new VertexLayoutDescription[] { vertexLayout },
                shaders: Shaders);
            pipelineDescription.Outputs = Canvas.FrameBuffer.OutputDescription;

            Pipeline = Factory.CreateGraphicsPipeline(pipelineDescription);

            MainResourceSet = Factory.CreateResourceSet(new ResourceSetDescription(Layout, ProjMatrix));
        }
Exemple #2
0
        public static UIWindow CreatePianoRollWindow(ProjectConnect projectConnect, MIDIPattern pattern, GraphicsDevice gd, ImGuiView imGui)
        {
            var menu    = new UIMenu("Retard Menu", new IUIComponent[] { new UIMenuItem("Snap Size") });
            var menuBar = new UIMenuBar(new IUIComponent[] { menu });

            pattern.GenNotes();
            var pianoPattern = new MIDIPatternConnect(projectConnect, pattern);
            var canvas       = new MIDIPatternIO(gd, imGui, ImGui.GetContentRegionAvail, pianoPattern);
            var window       = new UIWindow("PianoRoll", new UIValueProperty <bool>(true), ImGuiWindowFlags.MenuBar, new IUIComponent[] { menuBar, canvas });

            return(window);
        }
 public MIDIPatternInteractionMouseShiftDown(MIDIPatternConnect pianoRollPattern) : base(pianoRollPattern)
 {
     ClickLocation = GetMousePos();
     ClickedNote   = PianoRollPattern.GetNoteAtLocation(ClickLocation);
     if (ClickedNote != null)
     {
         var clickedNote = ClickedNote.Value;
         if (PianoRollPattern.IsNoteSelected(clickedNote))
         {
             PianoRollPattern.DeselectNote(clickedNote);
         }
         else
         {
             PianoRollPattern.SelectNote(clickedNote);
         }
     }
     ContinueWith(null);
 }
        public MIDIPatternInteractionMouseDown(MIDIPatternConnect pianoRollPattern) : base(pianoRollPattern)
        {
            if (ImGui.GetIO().KeyShift)
            {
                ContinueWith(new MIDIPatternInteractionMouseShiftDown(PianoRollPattern));
                return;
            }
            ClickLocation = GetMousePos();

            ClickedNote = PianoRollPattern.GetNoteAtLocation(ClickLocation);
            if (ClickedNote == null || !PianoRollPattern.IsNoteSelected(ClickedNote.Value))
            {
                PianoRollPattern.DeselectAllNotes();
            }

            if (ClickedNote != null)
            {
                PianoRollPattern.SelectNote(ClickedNote.Value);
            }
        }
Exemple #5
0
 public MIDIPatternInteractionSelectionRectangle(MIDIPatternConnect pianoRollPattern, Vector2d startLocation) : base(pianoRollPattern)
 {
     StartLocation = startLocation;
 }
Exemple #6
0
 public MIDIPatternInteractionMoveSelectedNotes(MIDIPatternConnect pianoRollPattern, Vector2d startLocation) : base(pianoRollPattern)
 {
     StartLocation = startLocation;
 }
 public MIDIPatternInteractionIdle(MIDIPatternConnect pianoRollPattern) : base(pianoRollPattern)
 {
 }