Task: it is required to synthesize music in the style of chiptune / as in Keygen.

Ultimately, you should get a simple tracker. The task is complicated by the need to implement it in Java, i.e. the code must generate sounds in real time. I tried to work with javax.sound.midi using the Sequencer , MidiEvent and so on - everything is clear, but it is an imitation of real instruments, i.e. not at all what is needed.

Need the ability to generate sound from scratch, using formulas for the calculation. I understand that I need to use javax.sound.sampled , this package loses anything, including the sound generated by the code. But how to generate sound? where to get the formulas? where to look for examples in java? How to create a chiptune effect in the program?

There are thousands of keygen'ov with music on the network, but I could not find the source for any of them. Basically a lot of information on how to lose v2m, mod, etc., but for some reason there is no information about creating these songs. Has anyone come across this? At least show me where to dig, but frankly, hands are already falling ..

    1 answer 1

    Here is a small code generation example taken from here . May help you.

     byte[] buf = new byte[ 1 ];; AudioFormat af = new AudioFormat( (float )44100, 8, 1, true, false ); SourceDataLine sdl = AudioSystem.getSourceDataLine( af ); sdl.open(); sdl.start(); for( int i = 0; i < 1000 * (float )44100 / 1000; i++ ) { double angle = i / ( (float )44100 / 440 ) * 2.0 * Math.PI; buf[ 0 ] = (byte )( Math.sin( angle ) * 100 ); sdl.write( buf, 0, 1 ); } sdl.drain(); sdl.stop();