稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ)

【深度学习预测】项目介绍 Python实现基于BO-Transformer-LSTM贝叶斯优化算法(BO)优化Transformer-LSTM模型进行多变量时间序列预测(含模型描述及部分示例代码) 内容概要:本文详细介绍了一个基于BO-Transformer-LSTM的多变量时间序列预测项目,通过结合Transformer的全局自注意力机制与LSTM的局部时序建模能力,构建了适用于复杂业务场景的深度学习预测模型。模型输入采用多变量滑动窗口结构,并引入正弦余弦位置编码以保留时间顺序信息;Transformer编码器提取变量间长距离依赖关系,LSTM进一步捕捉动态演化特征,最终通过回归层输出预测值。为优化模型性能,采用贝叶斯优化算法(基于Tree-structured Parzen Estimator)自动搜索最优超参数组合,包括嵌入维度、注意力头数、学习率、窗口长度等,显著提升了调参效率与模型泛化能力。项目还设计了包含周期性、趋势性、均值回归、突发事件和异方差噪声的五因素模拟数据生成机制,确保数据贴近真实业务场景,并建立了从数据预处理、模型训练、验证评估到结果恢复的完整技术链路。; 适合人群:具备一定机器学习与深度学习基础,熟悉PyTorch框架,从事时间序列预测相关研究或工程应用的研发人员、数据科学家及研究生。; 使用场景及目标:①应用于能源负荷预测、设备状态监测、金融风控、供应链需求预测等多变量时间序列预测任务;②解决传统模型在长时依赖、非线性关系和高维特征下的预测瓶颈;③实现高效超参数优化,提升模型调优自动化水平与部署可行性。; 阅读建议:本文含核心模型结构与部分示例代码,建议结合完整项目代码(如GitHub或博客资源)进行复现实践,重点关注数据生成逻辑、模型前向传播流程及贝叶斯优化集成方式,同时可通过调整网络结构或优化策略进一步拓展至多步预测、概率输出与可视化分析等高级功能。 立即下载
[源码下载]


稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ)


作者: webabcd


介绍
用Silverlight 1.0实现一个可以用鼠标或键盘弹奏,并且支持录音和回放的钢琴。(Silverlight+ASP.NET AJAX+DLINQ)
参考: http://silverlight.net/community/communitygallery.aspx


示例
Piano.xaml(用Expression Blend开发)
< Canvas
    
xmlns ="http://schemas.microsoft.com/client/2007"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Name
="Piano"  
    Width
="1024"  Height ="500" >
    
< Image  Source ="Image/bg.jpg"  Height ="500"  Width ="1024" />

    
< Image  x:Name ="imgC"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/C.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgC2"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/C2.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgD"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/D.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgD2"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/D2.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgE"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/E.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgF"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/F.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgF2"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/F2.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgG"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/G.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgG2"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/G2.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgA"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/A.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgA2"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/A2.jpg"  Opacity ="0" />
    
< Image  x:Name ="imgB"  Height ="500"  Width ="1024"  Canvas.Top ="0"  Source ="Image/B.jpg"  Opacity ="0" />

    
< MediaElement  x:Name ="C"  AutoPlay ="false"  Source ="Media/C.wma" />
    
< MediaElement  x:Name ="C2"  AutoPlay ="false"  Source ="Media/C2.wma" />
    
< MediaElement  x:Name ="D"  AutoPlay ="false"  Source ="Media/D.wma" />
    
< MediaElement  x:Name ="D2"  AutoPlay ="false"  Source ="Media/D2.wma" />
    
< MediaElement  x:Name ="E"  AutoPlay ="false"  Source ="Media/E.wma" />
    
< MediaElement  x:Name ="F"  AutoPlay ="false"  Source ="Media/F.wma" />
    
< MediaElement  x:Name ="F2"  AutoPlay ="false"  Source ="Media/F2.wma" />
    
< MediaElement  x:Name ="G"  AutoPlay ="false"  Source ="Media/G.wma" />
    
< MediaElement  x:Name ="G2"  AutoPlay ="false"  Source ="Media/G2.wma" />
    
< MediaElement  x:Name ="A"  AutoPlay ="false"  Source ="Media/A.wma" />
    
< MediaElement  x:Name ="A2"  AutoPlay ="false"  Source ="Media/A2.wma" />
    
< MediaElement  x:Name ="B"  AutoPlay ="false"  Source ="Media/B.wma" />

    
< Canvas  x:Name ="pathCanvas" >
        
< Path  x:Name ="CPath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="161.666656494141"  Height ="272.333312988281"  Canvas.Left ="135.5"  Canvas.Top ="138.83332824707"  Data ="M272.66667,140 L136,330 147.33333,336 162.66667,410.66667 247.33333,410 234.66667,330.66667 278,248 254,242.66667 258.66667,200.66667 296.66667,139.33333 272.66667,140"   />
        
< Path  x:Name ="C2Path"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="91"  Height ="136.333319306374"  Canvas.Left ="263.5"  Canvas.Top ="105.500005066396"  Data ="M325.33333,106.66667 L264,202.66667 266,241.33333 307.33333,238.66667 354,138 351.33333,106.66666 326.66667,106"   />
        
< Path  x:Name ="DPath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="131"  Height ="274.333297729492"  Canvas.Left ="247.499999999999"  Canvas.Top ="137.499984741212"  Data ="M358,142.66667 L311.33333,243.33333 288.66667,246 248,330.66667 258,338 266.66667,411.33333 354,410.66665 347.33333,330.66668 374,246.66668 350,243.33336 352.66667,202.66669 378,138.00005 360.66667,140.00005"   />
        
< Path  x:Name ="D2Path"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="70.3333129882813"  Height ="134.333319425583"  Canvas.Left ="356.83334350586"  Canvas.Top ="107.500003457069"  Data ="M394.66667,108.66667 L357.33333,204 359.33333,241.33333 398,240.66667 426.66667,134.66667 425.33333,108"   />
        
< Path  x:Name ="EPath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="117.666656494141"  Height ="274.333343505859"  Canvas.Left ="358.833343505859"  Canvas.Top ="137.5"  Data ="M431.33333,140 L403.33333,245.33333 381.33333,248 359.33333,330 368.66667,339.33333 372,411.33333 458,411.33333 455.33333,331.33333 476,138 433.33333,138.66667"   />
        
< Path  x:Name ="FPath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="99.6666564941406"  Height ="273.666680037975"  Canvas.Left ="470.83334350586"  Canvas.Top ="138.833345949649"  Data ="M486.66667,140.66667 L471.33333,332 477.33333,334 476.66667,412 563.33333,411.33335 564,339.33334 570,328 560,246.66665 535.33333,243.33331 530,139.3333 486.66667,139.33329"   />
        
< Path  x:Name ="F2Path"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="51"  Height ="133.666656494141"  Canvas.Left ="534.166687011719"  Canvas.Top ="108.16665649414"  Data ="M538.66667,109.33333 L534.66667,137.33333 542,241.33333 584,240.66666 584.66667,205.33334 568,108.66667 540.66667,108.66668"   />
        
< Path  x:Name ="GPath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="111"  Height ="274.333343505859"  Canvas.Left ="570.166687011719"  Canvas.Top ="137.5"  Data ="M570.66667,248 L582.66667,336 582,411.33333 669.33333,410.66667 672.66667,332.66667 680.66667,330 655.33333,245.33333 631.33333,244 601.33333,138 578.66667,138 594.66667,244.66667 571.33333,248"   />
        
< Path  x:Name ="G2Path"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="76.3333129882813"  Height ="131.666656494141"  Canvas.Left ="603.5"  Canvas.Top ="110.166664123534"  Data ="M612,111.33333 L604,136.66667 636,238.66667 636.66667,241.33333 679.33333,241.33333 679.33333,206.66667 641.33333,111.33334 612.66667,110.66668"   />
        
< Path  x:Name ="APath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="138.333312988281"  Height ="274.333343505859"  Canvas.Left ="655.5"  Canvas.Top ="137.5"  Data ="M665.33333,246 L694.66667,336.66667 686,411.33333 774.66667,410 785.33333,335.33333 793.33333,328.66667 750.66667,246.66667 722,243.33333 673.33333,138 656,138.66667 688.66667,216.66667 685.33333,245.33333 666,246"   />
        
< Path  x:Name ="A2Path"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="95"  Height ="131"  Canvas.Left ="676.166687011719"  Canvas.Top ="110.833320617675"  Data ="M682,111.33333 L676.66667,138.66667 730.66667,240.66667 768.66667,241.33333 770.66667,204.00001 713.33333,111.33334 683.33333,111.33335"   />
        
< Path  x:Name ="BPath"  Opacity ="0.01"  Fill ="#FFFFFFFF"  Stretch ="Fill"  Stroke ="#FF000000"  Width ="172.333312988281"  Height ="275.666687011719"  Canvas.Left ="733.5"  Canvas.Top ="136.833320051431"  Data ="M758,247.33333 L806,333.33333 790,412 878,412 894.66667,334 905.33333,327.33333 764.66667,138.66667 734,137.33333 776.66667,207.33334 778.66667,246.66668 758.66667,248"   />
    
</ Canvas >

    
< Ellipse  x:Name ="stopRecord"   Height ="30"  Width ="30"  Canvas.Left ="40"  Canvas.Top ="430"
      Stroke
="Black"  StrokeThickness ="3"  Fill ="Red" />
    
< Ellipse  x:Name ="startRecord"   Height ="30"  Width ="30"  Canvas.Left ="80"  Canvas.Top ="430"
      Stroke
="Black"  StrokeThickness ="3"  Fill ="Green" />

    
< Canvas  Width ="60"  Height ="30"  Canvas.Left ="760"  Canvas.Top ="422"  Cursor ="Hand" >
        
< TextBlock  x:Name ="play"  TextWrapping ="Wrap"  FontSize ="28"  Foreground ="#FF4C7185"  Text ="Play" >
        
</ TextBlock >
    
</ Canvas >

    
< TextBlock  x:Name ="lblMussicBook"  TextWrapping ="Wrap"  Canvas.Left ="120"  Canvas.Top ="434"  FontSize ="14"  Foreground ="#FFFFFFFF"  Text ="MusicBook:" >
    
</ TextBlock >
    
< TextBlock  x:Name ="lblName"  TextWrapping ="Wrap"  Canvas.Left ="520"  Canvas.Top ="434"  FontSize ="14"  Foreground ="#FFFFFFFF"  Text ="Name:" >
    
</ TextBlock >
</ Canvas >

Piano.xaml.js
if  ( ! window.Piano)
    window.Piano 
=   {} ;

Piano.Page 
=   function () 
{
}


Piano.Page.prototype 
=
{
    handleLoad: 
function(control, userContext, rootElement) 
    
{
        
this.control = control;
        
        
// Sample event hookup:    
        rootElement.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
    }
,
    
    
// Sample event handler
    handleMouseDown: function(sender, eventArgs) 
    
{
        
// The following line of code shows how to find an element by name and call a method on it.
        // this.control.content.findName("Timeline1").Begin();
    }

}

Default.aspx
<% @ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs"
    Inherits
="_10_Piano_Default" Title="支持录音和回放的钢琴" 
%>

< asp:Content  ID ="Content1"  ContentPlaceHolderID ="head"  runat ="Server" >

    
< script  type ="text/javascript"  src ="../Silverlight.js" ></ script >

    
< script  type ="text/javascript"  src ="Default.aspx.js" ></ script >

    
< script  type ="text/javascript"  src ="Piano.xaml.js" ></ script >

    
< script  type ="text/javascript"  src ="Piano.js" ></ script >

    
< style  type ="text/css" >
        .silverlightHost
        
{
            height
: 500px;
            width
: 1024px;
        
}

    
</ style >
</ asp:Content >
< asp:Content  ID ="Content2"  ContentPlaceHolderID ="ContentPlaceHolder1"  runat ="Server" >
    
< asp:ScriptManager  ID ="ScriptManager1"  runat ="server" >
    
</ asp:ScriptManager >
    
< div  id ="SilverlightControlHost"  class ="silverlightHost" >

        
< script  type ="text/javascript" >
            
var txtInput = '<%= txtInput.ClientID %>';
            
var txtName = '<%= txtName.ClientID %>';
            createSilverlight();
        
</ script >

        
< asp:UpdateProgress  ID ="UpdateProgress1"  runat ="server" >
            
< ProgressTemplate >
                
< div  style ="position: absolute; top: 0px; background-color: Red; color: White; z-index: 999" >
                    Loading
</ div >
            
</ ProgressTemplate >
        
</ asp:UpdateProgress >
        
< asp:UpdatePanel  ID ="UpdatePanel1"  runat ="server" >
            
< ContentTemplate >
                
< asp:GridView  ID ="GridView1"  runat ="server"  Style ="position: absolute; top: 0px;
                    width: 1024px"
 AllowPaging ="True"  AllowSorting ="True"  AutoGenerateColumns ="False"
                    DataKeyNames
="ID"  DataSourceID ="LinqDataSource1"  RowStyle-HorizontalAlign ="Center"
                    PageSize
="2"  OnSelectedIndexChanged ="GridView1_SelectedIndexChanged" >
                    
< Columns >
                        
< asp:CommandField  ShowSelectButton ="True"  HeaderText ="选择"  ItemStyle-Width ="40px" ></ asp:CommandField >
                        
< asp:CommandField  ShowDeleteButton ="True"  HeaderText ="删除"  ItemStyle-Width ="40px" ></ asp:CommandField >
                        
< asp:BoundField  DataField ="ID"  HeaderText ="ID"  InsertVisible ="False"  ReadOnly ="True"
                            SortExpression
="ID"  ItemStyle-Width ="40px" ></ asp:BoundField >
                        
< asp:BoundField  DataField ="Name"  HeaderText ="名称"  SortExpression ="Name" ></ asp:BoundField >
                        
< asp:TemplateField  HeaderText ="乐谱"  SortExpression ="Details"  ItemStyle-Width ="700px" >
                            
< ItemTemplate >
                                
< div  style ="overflow: hidden; width: 666px" >
                                    
< asp:Label  ID ="lblDetails"  runat ="server"  Text ='<%#  Bind("Details") % > '> </ asp:Label >
                                
</ div >
                            
</ ItemTemplate >
                        
</ asp:TemplateField >
                    
</ Columns >
                
</ asp:GridView >
                
< asp:TextBox  ID ="txtInput"  runat ="server"  Style ="position: absolute; left: 200px;
                    top: 434px; width: 300px"
  />
                
< asp:TextBox  ID ="txtName"  runat ="server"  Style ="position: absolute; left: 566px;
                    top: 434px;"
  />
            
</ ContentTemplate >
            
< Triggers >
                
< asp:AsyncPostBackTrigger  ControlID ="btnAdd"   />
            
</ Triggers >
        
</ asp:UpdatePanel >
        
< asp:LinqDataSource  ID ="LinqDataSource1"  runat ="server"  ContextTypeName ="Data.MusicBookDataContext"
            EnableDelete
="True"  TableName ="MusicBook" >
        
</ asp:LinqDataSource >
        
< asp:Button  ID ="btnAdd"  runat ="server"  Text ="添加"  Style ="position: absolute; left: 710px;
            top: 434px;"
 OnClick ="btnAdd_Click"   />
    
</ div >
</ asp:Content >

Default.aspx.cs
using  System;
using  System.Data;
using  System.Configuration;
using  System.Collections;
using  System.Linq;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;
using  System.Xml.Linq;

public  partial  class  _10_Piano_Default : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{

    }


    
protected void btnAdd_Click(object sender, EventArgs e)
    
{
        Data.MusicBookDataContext mbdc 
= new Data.MusicBookDataContext();
        Data.MusicBook mb 
= new Data.MusicBook();

        mb.Name 
= txtName.Text;
        mb.Details 
= txtInput.Text;

        mbdc.MusicBook.Add(mb);
        mbdc.SubmitChanges();

        txtName.Text 
= "";
        txtInput.Text 
= "";

        GridView1.DataBind();
    }


    
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    
{
        txtName.Text 
= GridView1.Rows[GridView1.SelectedIndex].Cells[3].Text;
        txtInput.Text 
= ((Label)GridView1.Rows[GridView1.SelectedIndex].Cells[4].FindControl("lblDetails")).Text;
    }

}


Default.aspx.js
function  createSilverlight()
{
    
var scene = new Webabcd.Piano();
    Silverlight.createObjectEx(
{
        source: 
"Piano.xaml",
        parentElement: document.getElementById(
"SilverlightControlHost"),
        id: 
"SilverlightControl",
        properties: 
{
            width: 
"100%",
            height: 
"100%",
            version: 
"1.0",
            isWindowless: 
"true"
        }
,
        events: 
{
            onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
        }

    }
);
}



if  ( ! window.Silverlight) 
    window.Silverlight 
=   {} ;

Silverlight.createDelegate 
=   function (instance, method)  {
    
return function() {
        
return method.apply(instance, arguments);
    }

}

Piano.js
if  ( ! window.Webabcd)
    window.Webabcd 
=   {} ;

Webabcd.Piano 
=  function() 
{
}


Webabcd.Piano.prototype 
=
{
    handleLoad: function(control, userContext, rootElement) 
    
{
        
// plugin(插件)
        this.control = control;
        
        
// 根Canvas元素
        this.rootElement = rootElement;
        
        
// object.addEventListener(eventName, functionReference)为对象添加一个事件监听器(事件名称,函数名称)
        
// Silverlight.createDelegate用来创建一个调用“this”上下文下的特定函数的委托,其被定义在runtime
        
// Silverlight.createDelegate = function(instance, method) 
        
// {
        
//   return function() 
        
//   {
        
//      return method.apply(instance, arguments);
        
//    }
        
// }
        this.rootElement.addEventListener("GotFocus", Silverlight.createDelegate(this, this.resetPiano));
        
this.rootElement.addEventListener("KeyDown", Silverlight.createDelegate(this, this.handleKeyDown));
        
this.rootElement.addEventListener("KeyUp", Silverlight.createDelegate(this, this.handleKeyUp));

        
// 鼠标热区的Canvas
        
// object.findName(name)
        this.pathCanvas = rootElement.findName("pathCanvas");   

        
// 开始录制按钮
        this.startRecord = rootElement.findName("startRecord");   
        
this.startRecord.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleStartRecord));

        
// 停止录制按钮
        this.stopRecord = rootElement.findName("stopRecord");   
        
this.stopRecord.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleStopRecord));
        
        
// 默认为选中停止录制按钮
        
// plugin.content.findName(objectName)
        document.getElementById('SilverlightControl').content.findName("stopRecord").Stroke = "LightBlue";
        document.getElementById(
'SilverlightControl').content.findName("stopRecord").StrokeThickness = 6;
        
        
// 播放按钮
        this.play = rootElement.findName("play");   
        
this.play.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handlePlay));

        
// object.children对应<Canvas>一个或多个子元素</Canvas>
        
// object.getItem(index)获取集合内指定的对象
        
// object.count集合内的成员数量
        for(var i = 0; i<this.pathCanvas.children.count; ++i)
        
{
            
// 为所有鼠标热区添加相关的事件监听器
            this.pathCanvas.children.getItem(i).addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
            
this.pathCanvas.children.getItem(i).addEventListener("MouseLeftButtonUp", Silverlight.createDelegate(this, this.handleMouseUp));
        }

        
        
// 是否启用录制
        this._enableRecord = false;
        
// 上一次按键的时间
        this._prevTime = new Date().getTime();
    }
,
    
    
// 单击开始录制按钮
    handleStartRecord: function(sender, eventArgs) 
    
{
        
// 设置开始录制按钮样式
        sender.Stroke = 'LightBlue';
        sender.StrokeThickness 
= 6;
        
        
// 设置停止录制按钮样式
        document.getElementById('SilverlightControl').content.findName("stopRecord").Stroke = "Black";
        document.getElementById(
'SilverlightControl').content.findName("stopRecord").StrokeThickness = 3;
        
        
// 启用录音
        this._enableRecord = true;
        
// 记录时间
        this._prevTime = new Date().getTime();
    }
,
    
    
// 单击停止录制按钮
    handleStopRecord: function(sender, eventArgs) 
    
{
        
// 设置停止录制按钮样式
        sender.Stroke = 'LightBlue';
        sender.StrokeThickness 
= 6;

        
// 设置开始录制按钮样式
        document.getElementById('SilverlightControl').content.findName("startRecord").Stroke = "Black";
        document.getElementById(
'SilverlightControl').content.findName("startRecord").StrokeThickness = 3;

        
// 清空乐谱名称和乐谱内容
        document.getElementById(txtInput).value = '';
        document.getElementById(txtName).value 
= '';
        
        
// 停止录音
        this._enableRecord = false;
    }
,
    
    
// 单击播放按钮
    handlePlay: function(sender, eventArgs) 
    
{
        
// 根据乐谱自动播放
        autoPlay(this, 0);
    }
,
    
    
// 记录乐谱
    handleRecord: function(currentPianoKeyID)
    
{
        
if (this._enableRecord)
        
{
            
// 插入乐谱
            document.getElementById(txtInput).value += new Date().getTime() - this._prevTime + ',';
            document.getElementById(txtInput).value 
+= currentPianoKeyID + ';';

            
// 更新时间
            this._prevTime = new Date().getTime();
        }

    }
,
    
    handleMouseDown: function(sender, eventArgs) 
    
{
        
// object.captureMouse()为对象启用鼠标捕捉(鼠标离开热区也可触发相关事件,如MouseLeftButtonUp)
        sender.captureMouse();
        
        var currentPianoKeyID 
= sender.name.substr(0, sender.name.indexOf("Path"));
        var currentImage 
= sender.findName("img" + currentPianoKeyID);
        currentImage.opacity 
= 1;
        
        var currentMediaElement 
= sender.findName(currentPianoKeyID);
        currentMediaElement.stop();
        currentMediaElement.play();
        
        
this.handleRecord(currentPianoKeyID);
    }
,
    
    handleMouseUp: function(sender, eventArgs) 
    
{
        
// object.releaseMouseCapture()释放对象的鼠标捕捉
        sender.releaseMouseCapture();
        
        var currentPianoKeyID 
= sender.name.substr(0, sender.name.indexOf("Path"));
        var currentImage 
= sender.findName("img" + currentPianoKeyID);
        currentImage.opacity 
= 0;
    }
,

    pressKey: function (currentPianoKeyID)
    
{
        var currentImage 
= this.control.content.findName("img" + currentPianoKeyID);
        currentImage.opacity 
= 1;
        
        var currentMediaElement 
= this.control.content.findName(currentPianoKeyID);
        
// object.play()播放,object.pause()暂停,object.stop()停止
        currentMediaElement.stop();
        currentMediaElement.play();
    }
,

    depressKey: function (currentPianoKeyID)
    
{
        var currentImage 
= this.control.content.findName("img" + currentPianoKeyID);
        currentImage.opacity 
= 0;
    }
,

    handleKeyDown: function (sender, eventArgs)
    
{
        
switch (eventArgs.Key)
        
{
            
// eventArgs.Key - 获取与该事件相关的键盘按键
            case 55: this.pressKey("C"); this.handleRecord("C"); break;
            
case 48: this.pressKey("C2"); this.handleRecord("C2"); break;
            
case 53: this.pressKey("D");  this.handleRecord("D"); break;
            
case 33: this.pressKey("D2"); this.handleRecord("D2"); break;
            
case 32: this.pressKey("E");  this.handleRecord("E"); break;
            
case 51: this.pressKey("F");  this.handleRecord("F"); break;
            
case 36: this.pressKey("F2"); this.handleRecord("F2"); break;
            
case 31: this.pressKey("G");  this.handleRecord("G"); break;
            
case 37: this.pressKey("G2"); this.handleRecord("G2"); break;
            
case 43: this.pressKey("A");  this.handleRecord("A"); break;
            
case 39: this.pressKey("A2"); this.handleRecord("A2"); break;
            
case 42: this.pressKey("B");  this.handleRecord("B"); break;
        }

    }
,

    handleKeyUp: function (sender, eventArgs)
    
{
        
switch (eventArgs.Key)
        
{
            
// eventArgs.Key - 获取与该事件相关的键盘按键
            case 55: this.depressKey("C");  break;
            
case 48: this.depressKey("C2"); break;
            
case 53: this.depressKey("D");  break;
            
case 33: this.depressKey("D2"); break;
            
case 32: this.depressKey("E");  break;
            
case 51: this.depressKey("F");  break;
            
case 36: this.depressKey("F2"); break;
            
case 31: this.depressKey("G");  break;
            
case 37: this.depressKey("G2"); break;
            
case 43: this.depressKey("A");  break;
            
case 39: this.depressKey("A2"); break;
            
case 42: this.depressKey("B");  break;
        }

    }
,
    
    resetPiano: function(sender, eventArgs) 
    
{
        
this.depressKey("C");
        
this.depressKey("C2");
        
this.depressKey("D");
        
this.depressKey("D2");
        
this.depressKey("E");
        
this.depressKey("F");
        
this.depressKey("F2");
        
this.depressKey("G");
        
this.depressKey("G2");
        
this.depressKey("A");
        
this.depressKey("A2");
        
this.depressKey("B");
    }

}



var _obj; 
//  Webabcd.Piano对象
var _index;  //  乐谱索引
function autoPlay(obj, index)
{
    _obj 
= obj;
    _index 
= index;
    
    execAutoPlay();
}


function execAutoPlay()
{
    _obj.resetPiano();

    var str 
= document.getElementById(txtInput).value; // 乐谱
    var ary = str.split(';'); // 间隔时间,按键名称
    
    
if (_index != 0 && typeof(ary[_index-1]) != 'undefined' && ary[_index-1] != '')
    
{
        
// 按下当前乐谱索引的上一个索引的按键
        _obj.pressKey(ary[_index-1].split(',')[1]); 
    }

     
    var currentIndex 
= _index;   
    _index
++;
    
    
if (typeof(ary[currentIndex]) != 'undefined')
    
{
        setTimeout(
"_obj.resetPiano();", 100)
        
// 经过当前乐谱索引的间隔时间则调用execAutoPlay()
        setTimeout("execAutoPlay();", parseInt(ary[currentIndex].split(',')[0], 10)); 
    }

}



OK
[源码下载]
西周BC798年世界历史地图矢量文件SHP格式.zip 本资源为《西周BC798年世界历史地图矢量文件SHP格式》压缩包,文件大小约 24.84 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

相关推荐

西周BC1010年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC1010年世界历史地图矢量文件SHP格式》压缩包,文件大小约 21.04 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ)...

[×××] 稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ)作者:webabcd介绍用Silverlight 1.0实现一个可以用鼠标或键盘弹奏,并且支持录音和回放的钢琴。(Silverlight+ASP.NET AJAX+DLINQ)参考:http://silverlight.net...

weixin_34297704的博客 99

城市生命线之长距离输水管线的监测与检测.pdf

城市生命线之长距离输水管线的监测与检测.pdf

经典博文--各系列文章

稳扎稳打Silverlight Silverlight 1.0 稳扎稳打Silverlight(1) - 1.0实例之电子表 稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ) Silverlight 2.0 稳扎稳打Silverlight(3) - 2.0控件之Bo...

diaoshanwai2368的博客 231

AI大模型训练大规模智算中心建设方案.pdf

AI大模型训练大规模智算中心建设方案.pdf

智慧博物馆数字化平台建设方案.docx

智慧博物馆数字化平台建设方案.docx

(2)经典导读:(webabcd)的Silverlight文章索引

[最后更新:2010.10.28] 源代码索引 稳扎稳打 Silverlight 系列文章 Silverlight 1.0 稳扎稳打Silverlight(1) - 1.0实例之电子表 稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ) Silverlight 2....

weixin_30832405的博客 255

复现水下航行器(NMPC)非线性模型预测控制分布式轨迹跟踪(Matlab代码实现)

内容概要:本文档围绕水下航行器(AUV)的非线性模型预测控制(NMPC)分布式轨迹跟踪技术展开,重点复现并实现了国际顶级期刊中提出的先进控制算法。该资源详细提供了基于Matlab的仿真代码,涵盖AUV的非线性动力学建模、多智能体系统协同控制、事件触发通信机制以及复杂海洋环境下分布式轨迹跟踪的优化求解过程。通过系统地构建NMPC控制器,实现对预设轨迹的高精度跟踪,同时有效处理系统约束与外部扰动。研究强调算法在多AUV协同任务中的适用性,突出其在节能通信与实时性方面的优势,是控制理论与工程实践相结合的典型范例; 适合人群:具备自动控制原理、非线性系统理论及Matlab编程基础的研究生、科研人员和工程技术开发者,尤其适用于从事水下机器人、智能控制、多智能体协同、路径规划与优化控制等方向的研究者; 使用场景及目标:① 深入理解非线性模型预测控制(NMPC)在欠驱动AUV轨迹跟踪中的设计与实现机制;② 复现并验证高水平学术论文中的控制策略,支撑科研创新与论文撰写;③ 探索事件触发机制下的分布式协同控制架构,提升多智能体系统的通信效率与控制性能; 阅读建议:建议结合现代控制理论相关教材与原始参考文献,逐行分析Matlab代码结构与算法流程,重点关注系统建模、代价函数构造、约束处理与优化求解器的调用方式。可通过调整控制参数、初始状态或引入环境干扰等方式进行仿真实验,以评估算法的鲁棒性、收敛性与工程实用性。

索引测试

[最后更新:2010.10.28] 源代码索引 稳扎稳打 Silverlight 系列文章 Silverlight 1.0 稳扎稳打Silverlight(1) - 1.0实例之电子表 稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ) Silverlight ...

weixin_30802171的博客 279

制造业与工业知识图谱应用

在全球数字化转型背景下,制造业面临创新周期缩短、质量管控精细化等挑战。知识图谱技术通过结构化表示工业知识,为智能制造提供关键技术支撑。工业知识图谱具有专业性强、多源异构数据融合、实时性要求高等特点,其构建流程涵盖本体设计、知识抽取与整合等环节。研究显示,知识图谱与大模型结合可提升工业场景的智能化水平,在设备故障诊断、供应链优化等领域具有显著应用价值。该技术有望成为制造业数字化转型的核心驱动力。

分享一些感兴趣的技术方面 1466

别再只会用QTcpSocket了!手把手教你用QSslSocket为你的Qt网络应用加上SSL/TLS加密(附完整代码示例)

本文详细介绍了如何将Qt网络应用从QTcpSocket迁移到QSslSocket,实现SSL/TLS加密传输。通过对比API差异、解析核心机制和提供完整代码示例,帮助开发者快速掌握安全网络编程技巧,有效防范数据窃听和中间人攻击等安全风险。

weixin_30654583的博客 405

系列文章索引

作者:webabcd来源:博客园发布时间:2007-02-24 17:58阅读:19538 次原文链接 [收藏] [最后更新:2010.01.30] 稳扎稳打 Silverlight 系列文章 Silverlight 1.0 稳扎稳打Silverlight(1) - 1.0实例之电子表 稳扎稳打Silverlight(2) -...

weixin_30435261的博客 188

智能车竞赛轮腿穿越组:GPS+IMU导航绕桩实战技巧(附避坑指南)

本文详细介绍了智能车竞赛轮腿穿越组中GPS+IMU导航绕桩的实战技巧,包括硬件选型、传感器标定、路径规划及多传感器数据融合策略。通过实际案例和避坑指南,帮助参赛队伍提升导航精度和稳定性,避免常见错误。特别强调IMU安装位置和标定对导航系统的重要性。

gin88的博客 592

我(webabcd)的文章索引

源代码索引 稳扎稳打 Silverlight 系列文章 Silverlight 1.0 稳扎稳打Silverlight(1) - 1.0实例之电子表 稳扎稳打Silverlight(2) - 1.0实例...

cqujfclnu90923045的博客 199

大模型安全-生成检测-事实核查-攻击-防御-思考-记忆-融合-语音相关研究 2025年版

本文整理了关于大模型安全领域的综合性资源,包括7篇综述论文、9个安全数据集以及5篇强化学习相关的安全研究论文。主要涉及大模型的对抗攻击、隐私保护、安全评估等方向,涵盖TruthfulQA、ToxiGen等知名数据集和TrustLLM、HarmBench等关键研究。资源包括知乎博主分享、arXiv预印本和顶会论文,并附有详细的中文讲解链接,为研究者提供了系统性的安全研究参考。

CSPhD-winston的博客 3637

Android15车载系统开机冷启动流程源码解析

本文主要介绍Android15车机系统开机冷启动的流程,暂不包含bootloader,仅从kernel开始直至Launcher首页展示。

jidapenglin28的专栏 261

【转自 webabcd】系列文章

稳扎稳打 Silverlight 系列文章 Silverlight 1.0 稳扎稳打Silverlight(1) - 1.0实例之电子表稳扎稳打Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ) Silverlight 2.0 系列文章索引Silverlight 2.0 在线 Demo 稳扎稳打Silv...

weixin_33968104的博客 246

12、信号采样与Z变换的全面解析

本文全面解析了信号采样和Z变换的核心概念与应用。内容涵盖采样基础、采样频率与奈奎斯特率的关系、离散时间处理模拟信号的方法、采样率转换技术,以及Z变换的定义、性质、常见变换对和逆变换计算。通过实例分析和流程图展示,帮助读者深入理解数字信号处理的关键步骤,为相关领域的学习与应用打下坚实基础。

Jerry的专栏 126

NCCL-AllReduce-P2P 与 NET(GDR)数据传输过程分析 (八)

四个 rank 执行 AllReduce 求和时,Ring 和 Tree 采用不同的归约顺序。在 Ring 中,每个 rank 从前驱接收数据,向后继发送数据。每个 chunk 沿环逐跳归约,再沿同一方向分发归约结果。在 Tree 中,叶节点向父节点发送本地输入数据。中间节点将子节点发来的数据与本地输入数据逐元素相加,再把部分和发给父节点。根节点完成归约后向下广播结果。两种算法都沿当前 Channel 的邻接关系收发。节点内走 P2P 时,GPU 通过映射地址,经 PCIe 或 NVLink 访问对端显存。

非专业业余程序员 354

零基础入门转录组数据可视化——绘制差异小提琴图(常规)

转录组数据可视化之一,先介绍相关基础知识,其次用实际案例为基础,由浅入深介绍差异小提琴图绘制的全过程,包括内容有相关代码和截屏。

呆猪儿的博客 641

手把手入门YOLO到改进优化教程专栏介绍与说明——列表目录查阅(持续更新)

手把手入门YOLO到改进优化教程专栏介绍与说明——列表目录查阅(持续更新)

嵌入式阿齐Archie 2万+

Spark 和 Flink 挤在一个 YARN 队列里:一次容器超限把实时任务打挂之后

这次事故之后我最大的改变是:不再把"集群资源不够"当成扩容的理由。96 核的集群,离线队列平均利用率不到 40%,实时队列却被打挂,问题从来不是总量,是边界。隔离靠队列,稳定靠不抢实时,容量按峰值留而不是按平均算。如果你们也是 Spark 和 Flink 共用一个 YARN,先去看一眼实时队列有没有,这一个配置能省掉很多凌晨的电话。

编程技术探索者,分享C/C++、C#、Java、数据库等开发经验,聚焦实战技巧与AI兴趣,助力编程爱好者成长。 239

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

上一篇: 稳扎稳打Silverlight(1) - 1.0实例之电子表
下一篇: 步步为营VS 2008 + .NET 3.5(1) - VS 2008新特性之Multi Targeting(多定向)、Web Designer and CSS(集成了CSS的web设计器)和Nested Master Page(嵌套母版页)
webabcd
博客等级 码龄17年 28粉丝 911原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址