【问题标题】:Beginner Digital Synth [closed]初学者数字合成器[关闭]
【发布时间】:2008-08-31 02:08:47
【问题描述】:

我正在考虑用 Java 编写音频合成器,想知道是否有人对编写这样的程序有任何建议或好的资源。我正在寻找有关生成原始声波、如何将它们输出为可用形式(通过扬声器播放)以及有关该主题的一般理论的信息。谢谢大家。

【问题讨论】:

    标签: java synthesizer


    【解决方案1】:
    1. 这个问题基本上是关于将函数映射到数字数组。支持一流功能的语言在这里会派上用场。

    2. 签出 http://www.harmony-central.com/Computer/Programminghttp://www.developer.com/java/other/article.php/3071021 获取一些与 Java 相关的信息。

    3. 如果您不了解编码声音数据的基本概念,请阅读http://en.wikipedia.org/wiki/Sampling_rate

    4. 规范的 WAVE 格式非常简单,请参阅http://www.lightlink.com/tjweber/StripWav/Canon.html。标头(前 44 个字节)+ 波形数据。你不需要任何库来实现它。

    在 C/C++ 中,相应的数据结构如下所示:

    typedef struct _WAVstruct
    {
        char headertag[4];
        unsigned int remnantlength;
        char fileid[4];
    
        char fmtchunktag[4];
        unsigned int fmtlength;
        unsigned short fmttag;
        unsigned short channels;
        unsigned int samplerate;
        unsigned int bypse;
        unsigned short ba;
        unsigned short bipsa;
    
        char datatag[4];
        unsigned int datalength;
    
        void* data; //<--- that's where the raw sound-data goes
    }* WAVstruct;
    

    我不确定 Java。我想您必须将“struct”替换为“class”,将“void* data”替换为“char[] data”或“short[] data”或“int[] data”,对应于每个字节的位数样本,如字段 bipsa 中所定义。

    要用数据填充它,你可以在 C/C++ 中使用类似的东西:

    int data2WAVstruct(unsigned short channels, unsigned short bipsa, unsigned int samplerate, unsigned int datalength, void* data, WAVstruct result)
    {
        result->headertag[0] = 'R';
        result->headertag[1] = 'I';
        result->headertag[2] = 'F';
        result->headertag[3] = 'F';
        result->remnantlength = 44 + datalength - 8;
        result->fileid[0] = 'W';
        result->fileid[1] = 'A';
        result->fileid[2] = 'V';
        result->fileid[3] = 'E';
    
        result->fmtchunktag[0] = 'f';
        result->fmtchunktag[1] = 'm'; 
        result->fmtchunktag[2] = 't';
        result->fmtchunktag[3] = ' ';
        result->fmtlength = 0x00000010;
        result->fmttag = 1;
        result->channels = channels;
        result->samplerate = samplerate;
        result->bipsa = bipsa;
        result->ba = channels*bipsa / 8;
        result->bypse = samplerate*result->ba;
    
        result->datatag[0] = 'd';
        result->datatag[1] = 'a';
        result->datatag[2] = 't';
        result->datatag[3] = 'a';
        result->datalength = datalength;
    
        result->data = data; // <--- that's were the data comes in
    
        return 0; // an error code, not implemented, yet ...; in Java: return result
    }
    

    同样,我不确定 Java,但如果将 void 指针转换为与比特率对应的数组,转换应该很简单。

    然后只需将整个结构写入文件即可获得可播放的波形文件。

    【讨论】:

      【解决方案2】:

      查看Frinika。它是用 Java(开源)实现的全功能音乐工作站。使用 API,您可以通过合成器运行 midi 事件,读取原始声音输出,并将其写入 WAV 文件(请参阅下面的源代码链接)。

      附加信息:

      【讨论】:

        【解决方案3】:

        在攻读学位期间,我的论文项目是创建基于 Java 的模块化合成器,而我所在的大学认为适合公开我的报告:

        A Software Based Modular Synthesiser in Java

        【讨论】:

        • 非常有用的论文,特别是基础知识。
        【解决方案4】:

        我不知道这是否有帮助,但如果您可以将 MIDI 用于任何事情,您应该查看JFuge

        【讨论】:

        • 那是jfugue.org的JFugue
        • MIDI 就像打火石:它值得尊重,因为它在遥远的过去为人类服务,但今天任何人都不应该认真使用它。
        • @MusiGenesis - 你是认真的吗?哈哈
        猜你喜欢
        • 1970-01-01
        • 2011-03-17
        • 2020-07-25
        • 1970-01-01
        • 2013-05-16
        • 2011-08-16
        • 2011-12-12
        • 1970-01-01
        • 2018-08-03
        相关资源
        最近更新 更多