使用音频引擎MITA创建自己的编码器的源代码

音频引擎IrrKlang学习笔记01:播放控制与音效设置 本系列与FMOD系列、Irrlicht系列是并列的。 关于IrrKlang,可以在早先的几篇博文中找到踪迹。 Irrlicht例程04:创造一个有声世界(上)  Irrlicht例程05:创造一个有声世界(下) 鬼火(irrlicht)的复燃 这几篇博文中已经涉及到IrrKlang的使用,但是本系列是专门研究Audio处理的,因此独立出来。 同时也方便与FMOD等进行对比。 与F 阅读详情

#include "../../include/mita.h" /**< @brief MITA SDK Header */
#ifdef _DEBUG
#pragma comment(lib, "../../library/mitaD.lib")
#else
#pragma comment(lib, "../../library/mita.lib")
#endif

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>

#define _IID_Example MITA_UUID_Make(AAAABBBB,5059,11E0,8000,0B15,00000A15)

typedef struct MITA_TAG_MODULEHEADER
{
MITA_IEncoder base;
//////////////////////////////////////////////////////////////////////////
//TODO: 添加额外的模块数据
}MITA_MODULEHEADER;

#pragma warning(push)
#pragma warning(disable:4996)

MITA_STATIC
MITA_INLINE
MITA_VOID
MITA_CheckError(MITA_VOID)
{
MITA_ERROR lastError = MITA_GetLastError();
if (lastError != MITA_ERROR_OK)
{
printf("ERROR: MITA Framework error with %u codes\n", lastError);
exit(lastError);
}
}

MITA_STATIC
MITA_INLINE
MITA_BYTE
MITA_EnterKey(MITA_VOID)
{
MITA_INT32 key = 0xFF;
do
{
if (kbhit())
{
key = getch();
break;
}
} while (1);
if (key >= 'a' && key <= 'z')
key -= 32;
return key;
}

//////////////////////////////////////////////////////////////////////////

MITA_STATIC
MITA_VOID
MITA_CALLBACK
Example_Release(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 释放资源
if (pThis)
MITA_Free(pThis);
}

MITA_STATIC
MITA_BOOL
MITA_CALLBACK
Example_SetParam(MITA_MODULEHEADER *pThis, MITA_UINT32 nParamID, MITA_LPCVOID lpParam)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 添加参数设置
return MITA_FALSE;
}

MITA_STATIC
MITA_BOOL
MITA_CALLBACK
Example_GetParam(MITA_MODULEHEADER *pThis, MITA_UINT32 nParamID, MITA_LPVOID lpParam)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 添加参数获取
return MITA_FALSE;
}

MITA_SIZE
MITA_CALLBACK
Example_GetFileDescribeNums(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 获取所支持的文件列表长度
return MITA_NULL;
}

MITA_LPCAFD
MITA_CALLBACK
Example_GetFileDescribe(MITA_MODULEHEADER *pThis, MITA_SIZE nIndex)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 获取所支持的文件列表
// 请参见 MITA_AFD 结构体
// 这里允许用户添加自定义数据
return MITA_NULL;
}

MITA_DWORD
MITA_CALLBACK
Example_GetFlags(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 获取解码的支持标签
// 参见MITA_EF_XXXX
//注意:如果不支持seek的话,一定不能添加 MITA_EF_SEEKABLE
return MITA_DF_DEFAULT;
}

MITA_BOOL
MITA_CALLBACK
Example_IsOpen(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 判断当前"编码器"是否已经初始化完毕
return MITA_FALSE;
}

MITA_BOOL
MITA_CALLBACK
Example_IsEof(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 判断是否已经编码结束
return MITA_FALSE;
}

MITA_LPCTIMEPOS
MITA_CALLBACK
Example_GetCurPos(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 获取当前编码位置
return MITA_NULL;
}

MITA_LPCCHANNELFORMAT
MITA_CALLBACK
Example_GetChannelInfo(MITA_MODULEHEADER* pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 获取当前编码源的通道格式信息
return MITA_NULL;
}

MITA_STATIC
MITA_INLINE
MITA_HSTREAM
getStream(MITA_HINSTANCE Instance, MITA_DWORD flag, MITA_LPCFILEPARAM lpParam, MITA_LPBOOL pNeedDelete)
{
MITA_HSTREAM hStream;
if (!MITA_ParseFileParam(Instance, (MITA_LPCFILEPARAM)lpParam, flag, (MITA_LPBOOL)pNeedDelete, &hStream))
return MITA_NULL;
return hStream;
}

MITA_HTAG
MITA_CALLBACK
Example_CreateTag(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 创建文件Tag描述对象
return MITA_NULL;
}

MITA_BOOL
MITA_CALLBACK
Example_Seek(MITA_MODULEHEADER *pThis, MITA_LPCTIME pCurTime)
{
//////////////////////////////////////////////////////////////////////////
//TODO: Seek audio source.
return MITA_TRUE;
}

MITA_BOOL
MITA_CALLBACK
Example_Startup(MITA_MODULEHEADER *pThis, MITA_LPCFILEPARAM lpParam, MITA_HARRAY hSoundArray)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 添加你的初始化代码
return MITA_TRUE;
}

MITA_SIZE
MITA_CALLBACK
Example_Encode(MITA_MODULEHEADER *pThis, MITA_LPCVOID pFrames, MITA_SIZE nFrames)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 添加您的编码代码
return (-1);
}

MITA_BOOL
MITA_CALLBACK
Example_Terminate(MITA_MODULEHEADER *pThis)
{
//////////////////////////////////////////////////////////////////////////
//TODO: 添加你的结束代码
return MITA_FALSE;
}

MITA_STATIC
MITA_LPCMODULEINFO
MITA_CALLBACK
Example_GetModuleInfo(MITA_IModule* pThis)
{
return pThis->PlusObject->getModuleInfo(pThis->PlusObject);
}

MITA_STATIC
MITA_BOOL
MITA_CALLBACK
Example_HasWindow(MITA_IModule* pThis, MITA_DWORD dwType)
{
return pThis->PlusObject->hasWindow(pThis->PlusObject, dwType);
}

MITA_STATIC
MITA_BOOL
MITA_CALLBACK
Example_ShowWindow(MITA_IModule* pThis, MITA_DWORD dwType, MITA_HANDLE hParent, MITA_BOOL bShow)
{
return pThis->PlusObject->showWindow(pThis->PlusObject, dwType, hParent, bShow);
}

MITA_STATIC
MITA_IModule*
MITA_CALLBACK
Example_CreateObject(MITA_IStaticPlus *pThis, MITA_HINSTANCE hInstance)
{
MITA_MODULEHEADER *pExample = (MITA_MODULEHEADER *)MITA_Malloc(sizeof(MITA_MODULEHEADER));
if (pExample == MITA_NULL)
return MITA_NULL;

pExample->base.base.PlusObject = &pThis->base;
pExample->base.base._instance = hInstance;
pExample->base.base._resverd = MITA_MODULE_RESVERD_ENCODER;
pExample->base.base.release = Example_Release;
pExample->base.base.getModuleInfo = Example_GetModuleInfo;
pExample->base.base.hasWindow = Example_HasWindow;
pExample->base.base.showWindow = Example_ShowWindow;
pExample->base.setParam = Example_SetParam;
pExample->base.getParam = Example_GetParam;
pExample->base.getFileDescribeNums = Example_GetFileDescribeNums;
pExample->base.getFileDescribe = Example_GetFileDescribe;
pExample->base.getFlags = Example_GetFlags;
pExample->base.seek = Example_Seek;
pExample->base.createTag = Example_CreateTag;
pExample->base.startup = Example_Startup;
pExample->base.encode = Example_Encode;
pExample->base.terminate = Example_Terminate;
pExample->base.isEof = Example_IsEof;
pExample->base.isOpen = Example_IsOpen;
pExample->base.getCurPos = Example_GetCurPos;
pExample->base.getChannelInfo = Example_GetChannelInfo;
//////////////////////////////////////////////////////////////////////////
//TODO: 添加额外的初始化操作。

return (MITA_IModule*)pExample;
}

MITA_STATIC
MITA_LPCMODULEINFO
MITA_CALLBACK
Plus_GetModuleInfo(MITA_IStaticPlus *pThis)
{
return &pThis->moduleInfo;
}
MITA_STATIC
MITA_BOOL
MITA_CALLBACK
Plus_HasWindow(MITA_IStaticPlus *pThis, MITA_DWORD dwType)
{
return MITA_FALSE;
}
MITA_STATIC
MITA_BOOL
MITA_CALLBACK
Plus_ShowWindow(MITA_IStaticPlus *pThis, MITA_DWORD dwType, MITA_HANDLE hParent, MITA_BOOL bShow)
{
return MITA_FALSE;
}

MITA_STATIC
MITA_IStaticPlus
gExamplePlugin =
{
Plus_GetModuleInfo,
Plus_HasWindow,
Plus_ShowWindow,
Example_CreateObject,
{
MITA_MT_ENCODER,
_IID_Example,
1,
L"MITA Plugin Example",
L"MITA Plugin Example Module",
L"Copyright(C) Hangzhou Migan Technology 2008-2011. All rights reserved.",
MITA_NULL
}
};

MITA_STATIC
MITA_HPLUSOBJECT
MITA_CALL
Example_ModuleMain(void)
{
return (MITA_HPLUSOBJECT)&gExamplePlugin;
}

//////////////////////////////////////////////////////////////////////////
//如果你想要导出dll的话,那么还需要添加一个接口函数
// MITA_GetPlusMains, nIndex 为模块的序号
_declspec(dllexport)
MITA_MODULEMAIN
MITA_CALL
MITA_GetPlusMains(MITA_SIZE nIndex)
{
switch (nIndex)
{
case 0:
return Example_ModuleMain;
}
return MITA_NULL;
}

void main(void)
{
MITA_HINSTANCE hInstance;
MITA_HPLUGIN hExamplePlugin;
MITA_HMODULE hExampleModule;
MITA_HOBJECT hExampleObject;
MITA_UUID RegGuid;
MITA_MODULEINFO moduleInfo;
MITA_BYTE Key;

printf(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n");
printf(";;Copyright(C) 杭州蜜柑科技有限公司 2008 - 2010. 保留所有权利。;;\n");
printf(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n");
printf(";;Plugin Encoder Example ;;\n");
printf(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n");

//////////////////////////////////////////////////////////////////////////
//1. Create a global instance handle.
hInstance = MITA_Initialize(MITA_NULL);
MITA_CheckError();

printf("Press A use static module loader.\n");
printf("Press B use export module loader.\n");
Key = MITA_EnterKey() - 'A';

if (Key == 0)
{
//////////////////////////////////////////////////////////////////////////
//2. Register Module
MITA_Ins_RegisterModule(hInstance, Example_ModuleMain, &RegGuid, &hExampleModule);
MITA_CheckError();
}
else
{
//////////////////////////////////////////////////////////////////////////
//2. Load Plugin, just this exe file.
MITA_Ins_LoadPlugin(hInstance, L"make_your_encoder.exe", &hExamplePlugin);
MITA_CheckError();
MITA_Ins_GetModuleByIndex(hInstance, 0, &hExampleModule);
MITA_CheckError();
}

//////////////////////////////////////////////////////////////////////////
//3. Create Module Object
MITA_Module_CreateModuleObject(hExampleModule, &hExampleObject);
MITA_CheckError();

//////////////////////////////////////////////////////////////////////////
MITA_Object_GetModuleInfo(hExampleObject, &moduleInfo);
MITA_CheckError();

printf("\n");
printf("Name: %s\n", MITA_Text_ToSystemS(moduleInfo.name, MITA_TCT_DEFAULT));
printf("Vers: %08X\n", moduleInfo.version);
printf("Desc: %s\n", MITA_Text_ToSystemS(moduleInfo.describe, MITA_TCT_DEFAULT));
printf("Copy: %s\n", MITA_Text_ToSystemS(moduleInfo.copyright, MITA_TCT_DEFAULT));
printf("\n");

/*
use MITA_Encoder_XXXX operations.
*/

//////////////////////////////////////////////////////////////////////////
//4. Delete Module Object
MITA_CloseHandle(hExampleObject);
MITA_CheckError();

//////////////////////////////////////////////////////////////////////////
//*: 这一步不是必须的
if (Key == 0)
{
//////////////////////////////////////////////////////////////////////////
//5*. Unregister Module,这一步不是必须的,在释放“实例句柄”的时候,会自动
// 进行移除操作。
MITA_Ins_UnregisterModule(hInstance, &RegGuid);
MITA_CheckError();
}
else
{
MITA_Ins_UnregisterPluginModule(hInstance, hExamplePlugin, MITA_NULL);
MITA_CheckError();
}

//////////////////////////////////////////////////////////////////////////
//6. Delete global instance handle.
MITA_CloseHandle(hInstance);
}

#pragma warning(pop)

douyin-favorite-MyLike-main.zip 立即下载

相关推荐

企业碳排放计算方法与实践:从年度总量到月度分配的完整流程

本文系统介绍了企业碳排放计算的全流程方法,包括数据预处理、能源活动与产品生产碳排放计算、年度汇总及月度分配优化。通过ARIMA模型预测补充缺失数据,采用二次规划算法实现基于用电量模式的月度碳排放分配,确保计算结果的准确性与合理性。该方法为企业碳排放管理提供了科学工具,有助于精准监控排放、制定减排策略并满足合规要求。实施中需注重数据质量控制和排放因子选择,并根据企业特点调整参数。该流程适用于制造业企业,为实现碳中和目标提供可靠的数据基础和管理支持。

applehunqiu的博客 1572

两个简单的声音引擎

两个简单的声音引擎

hdduuyf的博客 1499

基于Arduino的智能垃圾桶

通过本次简单的Arduino智能垃圾桶小实验可以快速了解Arduino的基本用法 1、材料准备 Arduino UNO HC-SR04超声波模块 SG90舵机 杜邦线 电源 电脑 2、代码分析 电机的控制 #include<Servo.h> #define duoji D5 Servo myduoji; void setup() { myduoji.attach(duoji); //舵机连接 Serial.begin(115200); } void loop() { myduoji.w

weixin_41679960的博客 1万+

使用音频引擎MITA处理音频文件tag的源代码

#include "../../include/mita.h" /**#ifdef _DEBUG#pragma comment(lib, "../../library/mitaD.lib")#else#pragma comment(lib, "../../library/mit

D-Y-W-DIY-? 939

完整版:ultralytics下运行yoloworld并训练

本文介绍了Ultralytics YOLO环境的快速配置与使用流程:1) 通过conda创建Python 3.9环境并安装依赖包;2) 配置中科大镜像源加速安装PyTorch和Ultralytics;3) 准备YOLO格式数据集并修改data.yaml配置文件;4) 提供模型预测、训练和验证的常用指令,包括predict/train/val等命令参数设置。文章还包含CLIP模型下载、权重文件获取以及本地安装等注意事项,完整覆盖了从环境搭建到模型部署的全过程。

weixin_50209871的博客 1343

《Zephyr OS 入门与实战》第5章:内存管理策略

【代码】《Zephyr OS 入门与实战》第5章:内存管理策略。

2301_79143213的博客 349

使用音频引擎MITA实现多输出源的源代码

#include "../../include/mita.h" /**#ifdef _DEBUG#pragma comment(lib, "../../library/mitaD.lib")#else#pragma comment(lib, "../../library/mit

D-Y-W-DIY-? 725

C#实现Socket通信同时监听多客户端(附完整源码)

C#实现Socket通信同时监听多客户端(附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 427

C/C++ 循环语句的优化

主题:for,do while,while的使用C代码:void test_for_and_while(){ int i, j = 0; for (i = 0; i {  d_printf(""); } for (i = 100; i>=0; i--) {  d_printf(""); } i=100; do {  d_printf(""); }while (--i); i =

D-Y-W-DIY-? 2841

ENVI无法打开Landsat8的头文件问题和解决

再次将txt文件拖入ENVI中,就会得到7个波段组合后的真彩色图像,而且辐射定标所需的参数信息都已经定义好了。按住CTRL+F,查找GROUP = LEVEL1_PROCESSING_RECORD。第一行GROUP = LANDSAT_METADATA_FILE。会查到两个包含的句子,把这两个中间的部分全部删掉。双击打开该xxx_MTL.txt的头文件。删除空行后,应该为如下图的样子。把LANDSAT改为L1。

所有专家都曾始于新手 9697

元数据治理实战:构建企业数据地图与血缘体系

元数据(Metadata)是描述数据的数据,是你能了解“数据是怎么来的”、“它是做什么的”、“能不能用”的基础信息。📌 举个例子:order_idstringods_order定义:平台内用户在订单系统中产生的唯一订单编号更新时间:每天凌晨 2 点,由 Airflow 调度任务生成所属人:张三(数据开发部)🔍 这些信息本身不直接参与计算,但它们是数据可管理、可追踪、可评估的基础。模块实战建议元数据类型技术 + 业务 + 操作元数据三类统一治理治理路径。

晴天彩虹雨的博客 290

关于2D游戏编程-粒子系统(雪)的实现

读了那篇文章后自己也去动手,嘿嘿,没想到真的做出来了,可惜不是很好,但是还算可以看的过去…… 下雪,对于我们北方的朋友来说一定很熟悉了,南方的朋友也一定从电视等等看过了吧,嘿嘿,下雪的时候还是挺美的,这么大了,还没有仔细的看过下雪呢,=。=,请勿见笑!好了开始正题了…… (-)特征描述 (1)雪花有不同的形状或大小 (2)雪花不是直线落下的,受空气阻力会到处飘荡 (3)雪花受空气阻力不同,其下落速

D-Y-W-DIY-? 2393

【AI大模型应用开发实战】大型语言模型评估指南白皮书(LLM Eval)

近年来,大型语言模型(LLM)在自然语言处理领域取得了重大进展,例如 GPT-3 和 Chat-GPT。这些模型经过大型数据集的训练,在文本相关任务中表现出卓越的能力,甚至超越了人类。本文将简要介绍如何验证 LLMs 性能的评估指标。自然语言处理(NLP)是人工智能的一个领域,涉及计算机和人类语言之间的交互。NLP 的基本任务之一是语言建模 (LM),它涉及构建统计模型来分析和生成自然语言。LM 已成为推进机器语言智能的关键方法,使机器能够执行机器翻译、情感分析和对话系统等任务。

AI天才研究院 1011

游戏中bmp图片文件的读取

用DirectX SDK 显示图片,一个是从文件读取BMP文件,一个是从内存中读取文件(为了打包文件读取文件的实现),我曾经测试过,调用这个函数读取图片文件比系统自带的要速度快,可惜我没有写完整,现在只支持24真彩色bmp图片,因为我的游戏是在32位下运行的,以后在添加了…… 参数说明:lpDDSTemp 目标页面 filename 文件名 isColorKey 是否有透明色 color_key

D-Y-W-DIY-? 2336

OV9734 DATASHEET,完整规格书

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

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

让你的代码在 main 或者 WinMain 之前执行!

Initialize your framework before main and WinMain, release your function after main and WinMain.

D-Y-W-DIY-? 2219

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

AT24C02,04,08... 系列MC51单片机驱动程序

头文件: #ifndef _AT24C_EEPROM_Driver_H#define _AT24C_EEPROM_Driver_H#include #include #include "IIC_BUS_Driver.h" //Depended I2C Bus Driver #define uchar unsigned char#define ushort unsigned sh

D-Y-W-DIY-? 1999

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

用ogre做图像引擎,用MITA做音频引擎做游戏的源代码1(附完整工程代码资源下载地址)

BaseApplication.h和mitademo.h两个头文件的源代码,里面有注释,有什么问题给我留言。/*-----------------------------------------------------------------------------Filenam

D-Y-W-DIY-? 1973

使你的代码变得更加美观,易读

  无意中看了很多代码,大家往往为了更加方便,轻松,而使代码的可读性下降,可读性很重要,无论是对你或者是看你代码的别人。可以这样想,假如过了几年,无意中翻到以前写的代码,你能确保在读懂它的意思吗?同样,也要确保别人也能读懂。在软件工程中,团队合作是很重要的,成员之间的交流更为之重,交流当中也包含了代码的浏览,所以一定要保证代码的美观。 第一: 熟练使用typedef 1. type

D-Y-W-DIY-? 1616

用ogre做图像引擎,用MITA做音频引擎做游戏的源代码3(附完整工程代码资源下载地址)

关键的处理代码都写在mitademo.cpp里面了。里面有注释,大家有什么问题给我留言。/*-----------------------------------------------------------------------------Filename: mita

D-Y-W-DIY-? 1468

谈谈C,C++内存申请器 [1]

谈谈C,C++内存申请器 之 一

D-Y-W-DIY-? 1354

对某个女孩“恋爱”代码的改进

曾经一个女孩写的代码: result love(boy, girl) {-   if ( boy.有房() and boy.有车() )    {-     boy.set(nothing);     return girl.嫁给(boy);   }   if ( girl.愿意等() )   {-    while( ! (boy.赚钱 > 100,000 and girl.感情 > 8 )  

D-Y-W-DIY-? 1288

美化你的代码

记得很久以前就看过一篇文章,说怎么写代码可以使你的代码更加的美观,前几天在论坛上又看到关于美化代码的见解,所以我也写点东西…… 一个好的程序员他写出代码不仅优秀而且很美,任何一个学过得人都可以看懂,为了更好的可以交流代码,我们需要对我们的代码进行美化。 代码的美化主要善用缩进,空格和换行的时机的,有的编辑软件就提供了自动缩进功能。 从基础的来了,比如函数的编写: 空格的应用: void Test(

D-Y-W-DIY-? 1264

用ogre做图像引擎,用MITA做音频引擎做游戏的源代码2(附完整工程代码资源下载地址)

BaseApplication.cpp大部分都是用OgreSDKWizard生成的。/*-----------------------------------------------------------------------------Filename: BaseAp

D-Y-W-DIY-? 1182

使用音频引擎MITA处理播放器列表的源代码

#include "../../include/mita.h" /**#ifdef _DEBUG#pragma comment(lib, "../../library/mitaD.lib")#else#pragma comment(lib, "../../library/mit

D-Y-W-DIY-? 1164

使用音频引擎MITA实现卡拉ok的源代码

#include "../../include/mita.h" /**#ifdef _DEBUG#pragma comment(lib, "../../library/mitaD.lib")#else#pragma comment(lib, "../../library/mit

D-Y-W-DIY-? 1071

使用音频引擎MITA给音频文件添加dsp音效源代码

#include "../../include/mita.h" /**#ifdef _DEBUG#pragma comment(lib, "../../library/mitaD.lib")#else#pragma comment(lib, "../../library/mit

D-Y-W-DIY-? 1064
上一篇: 使用音频引擎MITA编写自己的dsp插件的源代码
下一篇: 使用音频引擎MITA实现多音源输入的源代码
Debug_Today
博客等级 码龄19年 31粉丝 64原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值