mbehrens-games / opl2wave

The source code for OPL2Wave (a command line OPL2 style synth)
GNU General Public License v2.0
0 stars 0 forks source link

how to use #1

Open make-kmatze opened 1 year ago

make-kmatze commented 1 year ago

i've found your synths opl2wave and megawave. compile with gcc on windows works. But how to use? how is the input file structure? thanks for your help, kmatze

mbehrens-games commented 1 year ago

Thank you for your interest!

These programs (opl2wave and megawave) were uploaded to GitHub more as a backup; they may not be that useful in and of themselves. I guess I think of them as sort of "spiral notebook" notes, left here for my personal reference.

In other words, they have since been superseded by my later programs, "idunno" (which I used for the sound effects and music voices in my games thus far) and "gersemi" (which I plan to use in the future).

Gersemi will have (well, already has, technically) all the FM synth functionality of these programs. I plan to finish Gersemi by adding in the sequencer and a GUI as one of my next "things to do". So, you may want to wait until then if you want to try it out!

Otherwise, I could probably dig up an example input file if you wish. The format is a text file in a sort of pseudo-XML style. Though I believe these programs (opl2wave and megawave) have no sequencer functionality present, so again, they may not be that useful!

make-kmatze commented 1 year ago

thx for your fast response. An example input file would be nice. The sequencer functionality i write myself, textbased, called HIDCAM-SMS (inspired on abc). I'm interessed on the pure sound engine and how there works. HIDCAM is definitions of Header, Instruments, Drums, Chord, Arpreggios, Macros, SMS is SimpleMuicScript.

Greetings - kmatze

mbehrens-games commented 1 year ago

Well, here is a sample input file for opl2wave:

<opl2wave @export_sampling=44100 @export_bitres=16 @export_length=1.0
  /* modulator */
  <op1
    <ar 15> <dr 8> <sr 4> <rr 4> <tl 0> <sl 0>
    <multiple 1>
    <waveform "sine">
    <rks 1> <lks 0>
  >
  /* carrier */
  <op2
    <ar 15> <dr 8> <sr 4> <rr 4> <tl 8> <sl 0>
    <multiple 1>
    <waveform "sine">
    <rks 1> <lks 0>
  >
  <algorithm 0>
  <feedback 0>
  <note "c_4">
  <note_length 0.5>
  <filter_cutoff 3200>
>

The top line has the information for the output wave file (sampling rate of 44.1 kHz, 16-bit, and a length of 1.0 seconds).

The parameters for "op1" and "op2", along with the "algorithm" and "feedback" parameters that follow, should be the same as in the OPL2 documentation. Then at the bottom, we have "note", "note_length", and "filter cutoff". "note" is the note to be played (here, we are playing middle C). "note_length" is how long the key is held down (here, we have 0.5 seconds). "filter_cutoff" is the frequency in Hz for the 2nd order lowpass filter on the output.

If this input file is named "github_sample_01.txt", then the command:

opl2wave -n github_sample_01

should generate the output file "github_sample_01.wav" with the result.

make-kmatze commented 1 year ago

cool !!! thats fine and works, so i can test and try to integrate it into my development of HIDCAM. for my interest: the input format for megawave, idunno, gersemi the syntax are different?

thank you very much and greeting - kmatze

mbehrens-games commented 1 year ago

Yes. The format for "megawave" is very similar to this example, the only real difference being that there are 4 operators instead of 2 (so, there is op1, op2, op3, and op4). Also, the root level tag "opl2wave" at the top becomes "megawave".

For "idunno", the format is different. "idunno" is a subtractive synthesizer with 2 main oscillators that can be mixed, a 3rd oscillator for sync, and a 2nd order resonant filter. Here is an example (this is the "picked up a vial" sound effect from Vampiric Tower Remix):

<idunno @bpm=180 @tuning_fork="amiga" @downsampling_m=512 @export_sampling=22050 @export_bitres=16
  <generator
    <osc_1
      <waveform "square">
      <detune_octave 0>
      <detune_coarse 0>
      <detune_fine 0>
    >
    <osc_2
      <waveform "square">
      <detune_octave 0>
      <detune_coarse 0>
      <detune_fine 0>
    >
    <osc_3
      <detune_octave 0>
      <detune_coarse 0>
      <detune_fine 0>
    >
    <phi 0>
    <sync 0>
    <mix 16>
    <ring_mod 0>
  >
  <noise
    <period 0>
    <mix 0>
  >
  <filter
    <cutoff "c_8">
    <keytrack 0>
    <resonance 0>
  >
  <amplitude_envelope
    <ar 31> <dr 12> <sr 12> <rr 8>
    <tl 20> <sl 0> <rks 0> <lks 0>
  >
  <filter_envelope
    <ar 0> <dr 0> <sr 0> <rr 0>
    <tl 127> <sl 0> <rks 0> <lks 0>
  >
  <vibrato
    <waveform "sine">
    <depth 0>
    <speed 0>
    <delay 0>
  >
  <tremolo
    <waveform "sine">
    <depth 0>
    <speed 0>
    <delay 0>
  >
  <wobble
    <waveform "sine">
    <depth 0>
    <speed 0>
    <delay 0>
  >
  <hpf 0>
  <soft_clip 0>

  <sequencer
    <measure
      <length 4>
      <beat 16>
      <subdivisions 2>
      <step
        <scale
          <name "major">
          <tonic "c">
        >
        <chord
          <note_1 1>
          <note_2 3>
        >
        <position "c">
        <octave 5>
        <duration 1>
        <volume 127>
      >
      <step
        <chord
          <note_1 1>
          <note_2 3>
        >
        <position "e">
        <octave 5>
        <duration 1>
        <volume 127>
      >
      <step
        <chord
          <note_1 1>
          <note_2 3>
        >
        <position "g">
        <octave 5>
        <duration 1>
        <volume 127>
      >
      <step
        <position "rest">
        <duration 5>
      >
    >
  >
>

For "gersemi", the format changes again, but I plan to remove the text file input and move to a binary format once I get the GUI done. So, I will refrain from giving an example of that for now!