初学者数字合成器

发布于 2024-07-04 18:25:24 字数 1560 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

徒留西风 2024-07-11 18:25:24

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

I dont't know if that helps, but if you can use MIDI for anything, you should check out JFuge.

攒眉千度 2024-07-11 18:25:24

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

Java 中基于软件的模块化合成器

While studying for my degree, my dissertation project was the creation of a Java based modular synthesizer, and the University at which I studied saw fit to make my report publicly available:

A Software Based Modular Synthesiser in Java

怎会甘心 2024-07-11 18:25:24

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

其他信息:

Check out Frinika. It's a full-featured music workstation implemented in Java (open source). Using the API, you can run midi events through the synthesizer, read the raw sound output, and write it to a WAV file (see source code link below).

Additional information:

花伊自在美 2024-07-11 18:25:24
  1. 这个问题基本上是关于将函数映射到数字数组。 支持一流函数的语言在这里会非常方便。

  2. 查看
    http://www.harmony-central.com/Computer/Programming
    http://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。 我想你必须用“class”替换“struct”,用“char[] data”或“short[] data”或“int[] data”替换“void* 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 指针转换为与比特率相对应的数组,转换应该很简单。

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

  1. This problem is basically about mapping functions to arrays of numbers. A language that supports first-class functions would come in really handy here.

  2. Check out
    http://www.harmony-central.com/Computer/Programming and
    http://www.developer.com/java/other/article.php/3071021 for some Java-related info.

  3. If you don't know the basic concepts of encoding sound data, then read http://en.wikipedia.org/wiki/Sampling_rate

  4. The canonical WAVE format is very simple, see http://www.lightlink.com/tjweber/StripWav/Canon.html. A header (first 44 bytes) + the wave-data. You don't need any library to implement that.

In C/C++, the corresponding data structure would look something like this:

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;

I'm not sure about Java. I guess you'll have to substitute "struct" with "class" and "void* data" with "char[] data" or "short[] data" or "int[] data", corresponding to the number of bits per sample, as defined in the field bipsa.

To fill it with data, you would use something like that in 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
}

Again, I'm not sure about Java but the conversion should be straightforward if you convert the void-pointer to an array corresponding to the bitrate.

Then simply write the entire structure to a file to get a playable wave file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文