client/annotviz/app/annotsroll.html
author ymh <ymh.work@gmail.com>
Tue, 20 Jan 2015 11:57:44 +0100
changeset 98 72d767c5142d
child 100 0d7dac03c1a0
permissions -rw-r--r--
refactor and make work annotsroll

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="I.R.I">
    <link rel="shortcut icon" href="/img/favicon.ico">

    <title>AnnotsRoll</title>

    <!-- Custom styles for this template -->
    <link href="/css/annotviz.css" rel="stylesheet">
</head>

<body>
    <h1>Piano Roll vertical</h1>
    <noscript>You must enable JavaScript</noscript>
    <div id="canvasContainer"></div>
    <p>
        <a href="#" onclick="stop(); return false;">stop intervals</a> -
        <a href="#" onclick="start(); return false;">start intervals</a> -
        temps écoulé : <span id="timeStarted"></span>
    </p>
    <!--pre id="log"></pre-->
    <script src="/js/libs-annotviz.js"></script>
    <script src="/js/annotviz.js"></script>
    <script>
        var pianorollChannel  = 'PIANOROLL';
        var annotationChannel = 'ANNOT';
        var eventCode = 'test_1';
        var wsUri;
        if (window.location.protocol === 'file:') {
            wsUri = 'ws://127.0.0.1:8090/broadcast';
        }
        else {
            wsUri = 'ws://' + window.location.hostname + ':8090/broadcast';
        }
        wsUriPianoroll = wsUri + '?channel=' + pianorollChannel + '&event_code=' + eventCode;
        wsUriAnnotation = wsUri + '?channel=' + annotationChannel + '&event_code=' + eventCode;



        var logger = new annotviz.ConsoleLogger(true);

        var doubleroll = new annotviz.DoubleRoll({
            logger: logger,
            externalRefresh: true,
            ws: new annotviz.WsWrapper(wsUriPianoroll, logger),
            orientation: 'vertical',
            sceneHeight: 1080,
            pianorolls : [
                {
                    height: 435,
                    timeWidth: 60,
                    lineInterval: 5000,
                    noteHeight: undefined
                },
            ]
        });


        var annotsroll = new annotviz.AnnotsRoll({
            logger: logger,
            externalRefresh: true,
            ws: new annotviz.WsWrapper(wsUriAnnotation, logger),
            parentContainer: doubleroll.stage,
            xInit: 1920 - 435 - 300,
            yInit: 1080,
            width: 1920,
            height: 1080,
            widthRoll: 300,
            framerate: doubleroll.framerate,
            pixelsPerSecond: Math.floor(1920 / 60),
            annotColors: [{ts: 0, colors: {'ntm' : '#cdc83f'}}],
        });

        var refreshInterval;

        function stop() {
            doubleroll.stop();
            annotsroll.stop();
            window.clearInterval(refreshInterval);
        }
        function start() {
            doubleroll.start();
            annotsroll.start();
            refreshInterval = setInterval(function() { doubleroll.refresh(); annotsroll.refresh(); }, 1000/doubleroll.framerate);
        }

        window.onload = function() {
            doubleroll.init();
            annotsroll.init();
            start();
        }


var sessionJson =
    {
        "categories": [
    {
        "color": "rgb(205,200,63)",
        "subcategories": [
    {
        "color": "rgb(205,200,63)",
        "code": "ntm",
        "full_label": "sous-catégorie 1-1",
        "label": "Batterie"
    },
{
    "color": "rgb(205,200,63)",
    "code": "iam",
    "full_label": "sous-catégorie 1-2",
    "label": "Clavier"
},
{
    "color": "rgb(205,200,63)",
    "code": "hip",
    "full_label": "sous-catégorie 1-3",
    "label": "Guitare"
},
{
    "color": "rgb(205,200,63)",
    "code": "hop",
    "full_label": "sous-catégorie 1-4",
    "label": "Trombone"
}
],
"full_label": "Liste des instruments disponibles",
"label": "Instruments"
},
{
    "color": "rgb(222,139,83)",
    "subcategories": [
{
    "color": "rgb(222,139,83)",
    "code": "rock",
    "full_label": "sous-catégorie 2-1",
    "label": "Accélération"
},
{
    "color": "rgb(222,139,83)",
    "code": "rap",
    "full_label": "sous-catégorie 2-2",
    "label": "Décélération"
},
{
    "color": "rgb(222,139,83)",
    "code": "classic",
    "full_label": "sous-catégorie 2-3",
    "label": "Pause"
}
],
"full_label": "catégorie 2",
"label": "Rythmique"
},
{
    "color": "rgb(197,163,202)",
    "subcategories": [
    {
        "color": "rgb(197,163,202)",
        "code": "drums",
        "full_label": "sous-catégorie 3-1",
        "label": "sub cat 3-1"
    },
    {
        "color": "rgb(197,163,202)",
        "code": "guitar",
        "full_label": "sous-catégorie 3-2",
        "label": "sub cat 3-2"
    }
    ],
    "full_label": "catégorie 3",
    "label": "Une 3ème cat"
},
{
    "color": "rgb(121,187,146)",
    "code": "bass",
    "full_label": "catégorie 4",
    "label": "Annot'direct"
}
]
};
    </script>
</body>
</html>