小编Don*_*man的帖子

使用基于javascript浏览器的midi.js创建鼓声?

我一直在尝试使用midi.js http://mudcu.be/midi-js/

我一直在寻找一个地方发布关于使用它的问题,但没有找到,所以我将在这里尝试..

图书馆的第一个工作很棒.

我试图让一个鼓声只能触发,但它无法正常工作.我可以从"acoustic_grand_piano"中获取其他音符,而不是仅仅从"synth_drum"触发.

我认为midi音符35应该与"Acoustic Bass Drum"有关.

使用demo-Basic.html中的示例

window.onload = function () {
    MIDI.loadPlugin({
        soundfontUrl: "./soundfont/",
        instrument: "synth_drum",
        callback: function() {
            var delay = 0; // play one note every quarter second
            var note = 35; // the MIDI note
            var velocity = 127; // how hard the note hits
            // play the note
            MIDI.setVolume(0, 127);
            MIDI.noteOn(0, note, velocity, delay);
            MIDI.noteOff(0, note, delay + 0.75);
        }
    });
};
Run Code Online (Sandbox Code Playgroud)

javascript midi

5
推荐指数
1
解决办法
1721
查看次数

使用rsvg-convert可以将多页或多文件SVG转换为多页PDF吗?

有没有办法使用"rsvg-convert"将多页SVG或多SVG文件转换为单页多页PDF?

我正在使用命令:

 /usr/bin/rsvg-convert -f pdf -o out.pdf in.svg
Run Code Online (Sandbox Code Playgroud)

linux pdf svg pdf-generation

4
推荐指数
2
解决办法
1111
查看次数

jQuery使用事件treetable

我需要帮助找出如何使用jQuery插件treetable提供的事件.

jQuery treetable(PLUGIN):http://plugins.jquery.com/treetable/

这就是我想要解决的问题.

当分支崩溃时,插件应该触发一个名为"onNodeCollapse"的事件.

当分支崩溃时,我只需要显示一个javascript弹出窗口,上面写着"分支已经崩溃".从这里我可以把它绑在我们自己的功能上.

我尝试了几种不同的方法以及在线搜索解决方案.

示例脚本:http: //jsfiddle.net/djlerman/yLb25dy9/

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>jQuery treetable with event trigger - jsFiddle demo by djlerman</title>

  <link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css">
  <link rel="stylesheet" type="text/css" href="http://ludo.cubicphuse.nl/jquery-treetable/css/screen.css">
  <link rel="stylesheet" type="text/css" href="http://ludo.cubicphuse.nl/jquery-treetable/css/jquery.treetable.css">
  <link rel="stylesheet" type="text/css" href="http://ludo.cubicphuse.nl/jquery-treetable/css/jquery.treetable.theme.default.css">

  <script type='text/javascript' src='//code.jquery.com/jquery-1.11.0.js'></script>
  <script type='text/javascript' src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
  <script type='text/javascript' src="http://ludo.cubicphuse.nl/jquery-treetable/jquery.treetable.js"></script>

  <script type='text/javascript'>//<![CDATA[ 
    $(window).load(function(){
    $("#example-basic").treetable({ expandable: true });

    /* 
        Trying to get this function to happen when 
        "onNodeCollapse" event happens
    */
    $("#example-basic").on("onNodeCollapse", function() {
        alert( …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-ui jquery-plugins treetable

2
推荐指数
1
解决办法
7979
查看次数

perl:什么是PRO和CON在命令行上传递json?

我想标准化使用json作为我做各种编程的数据交换格式吗?[到目前为止除了MySQL以外的一切:-(]

我当前的问题是:使用json格式通过命令行将参数传递给perl脚本的PRO和CON什么?

以下是我想出的一些内容.如果从长远来看这是不可行的,请告诉我

PRO:

  • 参数可以按任何顺序排列
  • 参数以标准格式传递,可以使用和解析以用于其他目的.(传递给javascript函数,传递给PHP,保存在表中)

CON:

  • 不知道长度限制
  • 不知道可能出现的问题.

这是命令行的样子:

perl perlScript.pl {\"key\ 1\": \"value\ 1\", \"key\ 2\" : \"value\ 2\", \"key\ 3\" : 0  }
Run Code Online (Sandbox Code Playgroud)

以下是脚本的外观:

#!/usr/bin/perl

# Pass arguments to script on command line via json

use JSON;

# Use loop to combine all command line arguments into one variable
my $json = '';
foreach my $arg(@ARGV) {
  $json .= $arg;
}

# convert variable to hash
my $hash = decode_json($json);

use Data::Dumper;
print Dumper(\%$hash);
Run Code Online (Sandbox Code Playgroud)

perl json command-line-arguments

1
推荐指数
1
解决办法
618
查看次数

如何正确地将引用的哈希值添加到数据结构而不覆盖之前的值?

我正在使用Perl JSON模块将Perl哈希转换为JSON字符串.我无法弄清楚如何在保持先前分配的键和值的同时向散列数组添加新的哈希值.

我正在尝试创建以下JSON:

{
  "key1":"value1",
  "key2":"value2",
  "arrayOfHash":[
    {
      "key1-1":"value1-1",
      "key1-2":"value1-2"
    },
    {
      "key2-1":"value2-1",
      "key2-2":"value2-2"
    }
  ]
} 
Run Code Online (Sandbox Code Playgroud)

这是代码:

use JSON; # imports encode_json, decode_json, to_json and from_json.

$json{key1}   = "value1";
$json{key2}   = "value2";

%hash             = ();
$hash{'key1-1'}   = "value1-1";
$hash{'key1-2'}   = "value1-2";
push(@{ $json{arrayOfHash} }, \%hash);

%hash             = ();
$hash{'key2-1'}   = "value2-1";
$hash{'key2-2'}   = "value2-2";
push(@{ $json{arrayOfHash} }, \%hash);

$json = encode_json(\%json);
Run Code Online (Sandbox Code Playgroud)

我得到的是:

{
  "key1":"value1",
  "key2":"value2",
  "arrayOfHash":[
    {
      "key2-1":"value2-1",
      "key2-2":"value2-2"
    },
    {
      "key2-1":"value2-1",
      "key2-2":"value2-2"
    }
  ]
} 
Run Code Online (Sandbox Code Playgroud)

arrays perl hash

0
推荐指数
1
解决办法
66
查看次数