Author |
Message |
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sat Oct 25, 2014 2:30 pm Post subject:
ChipTune music box Subject description: simple chip tune generator |
|
|
This afternoon I was experimenting with my Lunetta Lab and started to patch something with the idea to extend the idea of the Crazy Fiddler circuit a bit. I was exploring how a shift register feedback can be used to generate waveform when I ran into this combination and optimized it until I had the following. The CHIPTUNE circuit plays a small tune that repeats endlessly. The tune is surprisingly long and generates harmonic tones in interesting self-similar sequences. After a while you will start to follow the melody of the tune.
How it works: oscillator U1B determines the basic pitch and clocks a shift register with a resistor network at the outputs Q0 to Q3. Depending on the feedback function for the shift register, different waveforms at different base frequencies are generated by the resistor network. The feedback function with arguments taken from Q1 to Q3 is implemented using an 8->1 selector U4. The bit pattern that describes the function is coming from the outputs of counter U2. Low frequency oscillator U1A generates the clock for the counter and can be used to vary the tempo. The value for binary input X7 is tied to ground to make sure that there is some tone generated when all bits in the shift register are at 1. You could also connect Q7 from the counter to X7, but then there will be a pause while the counter is between 0xC0 and 0xFF and the shift register is locked at a state with all 1s.
The generated melodies can be varied a bit by connecting Q1 to Q3 from the shift register to inputs A,B,C of U4 in different permutations.
Permutation Q3->A, Q2->B, Q1->C is used in the schematic. My favorite is Q2-A,Q3->B,Q1->C. I attached a recording for both tunes for your listening pleasure.
Description: |
|
Filesize: |
36.57 KB |
Viewed: |
908 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
ChipTuneA3B2C1.mp3 |
Filesize: |
827.41 KB |
Downloaded: |
1653 Time(s) |
Description: |
|
Download |
Filename: |
ChipTuneA2B3C1.mp3 |
Filesize: |
826.18 KB |
Downloaded: |
1371 Time(s) |
|
|
Back to top
|
|
|
RingMad
Joined: Jan 15, 2011 Posts: 427 Location: Montreal, Canada
Audio files: 4
|
Posted: Sun Oct 26, 2014 5:05 am Post subject:
|
|
|
Interesting circuit! I'll add it to my pile of circuits to try. I wonder what chaining the second shift reg on the 4015 to make it 8-bit would do. Thanks for sharing.
-- James. |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sun Oct 26, 2014 10:11 am Post subject:
|
|
|
Depending on the feedback function the 4-bit shift register acts as a divider between 2 and 14, with 3,4,5,6,7 being the most frequent dividers and 10 and 11 missing. If you make the shift register longer, the dividers become bigger. The melody gets lost and some dis-harmonic sounds are added.
I tried adding a 4053 to create permutations for the A,B,C inputs, driven by some of the unused 4040 outputs. However, I haven't found a way to connect the outputs from the 4015 to the 4053 yet, so that each output from the 4015 is used only once for the A,B,C inputs of the 4051. |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sun Oct 26, 2014 11:56 am Post subject:
|
|
|
Here is an automatic permutation that works quite nice. I have included Q0 and use Q7 to Q9 from the 4040 to switch between permutations.
Played back with higher speed the generated tune almost sounds like an arcade game and runs for a full 1 minute and 34 seconds before repeating.
Description: |
|
Filesize: |
12.25 KB |
Viewed: |
30968 Time(s) |
|
Description: |
|
Download |
Filename: |
ChipTunePermutation.mp3 |
Filesize: |
1.44 MB |
Downloaded: |
1302 Time(s) |
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
|
Back to top
|
|
|
commathe
Joined: Jul 26, 2013 Posts: 153 Location: Beijing
Audio files: 5
|
Posted: Sun Oct 26, 2014 4:53 pm Post subject:
|
|
|
Wow! The way it loops is surprisingly musical. It'd be really cool to run two alongside each other and maybe some percussion sounds! Instant 80s home-arcade style |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Mon Oct 27, 2014 12:24 pm Post subject:
|
|
|
One more improvement can be made. You can avoid the boring parts from the previous circuit when just two tones alternate by avoiding that one shift register output is switched to two of the selection inputs at the same time. In this variation I am using a 4052 instead of the 4053 and leave Q3 permanently connected to C. The 4052 can only create four permutations (given in the schematic) and the resulting tune is shorter because of that. Nevertheless, it sounds more interesting.
By the way, you could drop the resistor network and just connect Q3 to the output without much loss. The resulting waveform will be a simple square wave then.
Description: |
|
Filesize: |
29.55 KB |
Viewed: |
817 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
SuperChipTune2.mp3 |
Filesize: |
865.37 KB |
Downloaded: |
1402 Time(s) |
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Tue Oct 28, 2014 1:21 pm Post subject:
|
|
|
And one more variant, this time playing a random tune. The principle is the same: a shift register with a programmable feedback function implements a divider. Only this time I am using a second shift register to generate a (pseudo) random bit pattern for the feedback function. Plus, I am using the LFO output itself to provide one additional bit for the function synthesis.
The randomization comes from shifting in the output of the oscillator with each LFO clock. This makes it almost random, except that there always will be identical pairs of notes because one of the feedback function bits toggles before the next random bit is shifted in. I dropped the resistor network this time and use just the square wave from one of the divider (shift register) outputs. This circuit creates a nice swing with a minimum number of parts.
I used a spreadsheet to calculate the divider for each feedback function between 10000000 and 11111110. The assignment of the shift register outputs to the 4051 is carefully selected to avoid the divider 2 to occur, because this creates a rather high note that does not sound nice in the melody. The dividers that can occur with this schematic are 3,4,5,6,7,8,9,12 and 13. That makes 16 possible pairs of 9 possible notes.
Description: |
|
Filesize: |
26.9 KB |
Viewed: |
901 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
RandomChipTune.mp3 |
Filesize: |
1.02 MB |
Downloaded: |
1306 Time(s) |
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Wed Oct 29, 2014 2:18 pm Post subject:
|
|
|
Yeah. I am currently thinking about a second voice as well..
The divider in the second voice better has to be coupled somehow to a short sequence of the first voice, like four notes, so that they play together nicely.
Maybe just copy the bit pattern from the first to the second and hard-wire some of the bits to 0 or 1. Investigating...
By the way, I already spent a lot of time looking at generating bit permutations using switches. Let me draw a circuit of my current idea and share it in another thread. I would be very interested in other ideas. |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Wed Oct 29, 2014 2:47 pm Post subject:
|
|
|
synaesthesia wrote: | The divider in the second voice better has to be coupled somehow to a short sequence of the first voice, like four notes, so that they play together nicely.
Maybe just copy the bit pattern from the first to the second and hard-wire some of the bits to 0 or 1. Investigating... |
That's exactly what I had in mind (like playing chords and a melody) _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sat Nov 01, 2014 3:19 pm Post subject:
|
|
|
Not really chords, but it is a second voice. The output from the 4051 drives a second shift register that is connected as a divider by 2. The shift register is held in reset while input X0 is at 1. This way the second voice is only active if X0 is 0 and if there is no pause. A pause occurs if X0 is 0 and the current feedback function generates a sequence of zeroes. This is how it sounds.
Description: |
|
Filesize: |
42.76 KB |
Viewed: |
613 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
ChipTune2.mp3 |
Filesize: |
1.14 MB |
Downloaded: |
1212 Time(s) |
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sun Nov 23, 2014 3:22 pm Post subject:
|
|
|
After the WalkingBass circuit idea, what else could I do? Of course, I had to combine the two circuits. The ChipTuneSymphony circuit includes the melody generator from the ChipTune circuit, the second voice, and the walking bass. This makes for about 13 minutes of ChipTune music before the pattern repeats. If you don't have the patience to listen to the recording of the full cycle, skip to 09:30 and listen for a minute to enjoy the best parts.
Description: |
|
Filesize: |
40.96 KB |
Viewed: |
690 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
ChipTuneSymphony.mp3 |
Filesize: |
12.09 MB |
Downloaded: |
1312 Time(s) |
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sun Mar 08, 2015 3:14 am Post subject:
|
|
|
Here is a ChipTune circuit that plays a random melody forever. I used the same principle as in the RandomChime circuits, but without the XOR gate. Instead, I use a 4051 analog switch and inverters in the feedback path of the divider.
There are two oscillators, a fast one for the base pitch and a slow one for the tempo. The frequency from the fast oscillator U1A is fed into shift register U2 and using the feedback from selector U4 is divided by 8,10,12,14 or 16. Typically, the feedback to U2 is inverted to create a Johnson counter. However, for some of the inputs an extra inverter is used and that results in the current state of the shift register to be rotated instead, which results in additional waveforms with higher frequencies. This way the divider generates not only five tones, but a few more depending on the pattern in U2 at the time the control inputs A,B,C of U4 change. If all bits of the shift register happen to be the same and the output is not inverted, a pause will be heard.
The slow oscillator U1B drives shift register U3 which generates the control inputs A,B,C for U4. These signals determine the division and the mode of shift register U2. The input for U3 is taken directly from the fast oscillator as a random source. Of course, you could drive inputs A,B,C from other sources, like separate oscillators, as well.
Description: |
|
Filesize: |
48.84 KB |
Viewed: |
576 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
Opus4015.mp3 |
Filesize: |
1.35 MB |
Downloaded: |
1025 Time(s) |
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sat Mar 14, 2015 3:22 pm Post subject:
|
|
|
Here is one more patch with XOR gates in the feedback path again. This time I am generating a second voice by clocking another shift register from one output of the first. This gives a high frequency from the first, and a lower frequency from the second shift register. The outputs of both shift registers are mixed with a simple passive resistor mixer. The chosen values emphasize the higher tones.
To make the melody more interesting two analog switches X and Y are used to vary the feedback path of each shift register between the 3rd and 4th output stage. This way the generated frequencies change but will always be harmonic. I used a counter driven by a slow clock to control the analog switches.
Just because there was a third switch available I used it to change the counter output that drives the switch for the lower frequency feedback. This varies the rhythm of the melody a bit. The first recording is the raw signal. The second has a delay of 0.5s added using Audacity.
Description: |
|
Filesize: |
42.51 KB |
Viewed: |
505 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Download |
Filename: |
Opus4053.mp3 |
Filesize: |
2.3 MB |
Downloaded: |
957 Time(s) |
Description: |
|
Download |
Filename: |
Opus4053withDelay.mp3 |
Filesize: |
2.34 MB |
Downloaded: |
907 Time(s) |
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
rico C
Joined: Feb 27, 2014 Posts: 26 Location: Redondo Beach
|
Posted: Sat Mar 28, 2015 9:05 am Post subject:
|
|
|
I'm strolling around a casino in a distant galaxy...as the aliens win big, the arcade machines begin to levitate... |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Sun Mar 29, 2015 6:22 am Post subject:
|
|
|
And three recordings using two shift registers with different lengths and mode switch clocks (details in the MP3 tags). The first voice (higher) has the pause-free circuit added. The second voice (lower) is derived by using the output of the first as a clock. Because I had no more XOR's left, I omitted the pause-free circuit there.
Description: |
|
Download |
Filename: |
DoubleXorFeedbackShiftRegister.mp3 |
Filesize: |
1.74 MB |
Downloaded: |
951 Time(s) |
Description: |
|
Download |
Filename: |
DoubleXorFeedbackShiftRegisterFast.mp3 |
Filesize: |
1.86 MB |
Downloaded: |
919 Time(s) |
Description: |
|
Download |
Filename: |
DoubleXorFeedbackShiftRegisterSlow.mp3 |
Filesize: |
2.13 MB |
Downloaded: |
883 Time(s) |
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Sun Mar 29, 2015 6:55 am Post subject:
|
|
|
will have to listen to those.
one idea that came to mind is using a binary (or decimal) counter with a mux to vary the tempo/note length.
you could also go analog with a resistor ladder and a 4046 which can also be used to create different 'base notes' .
not sure if you already did something like this, you're posting so many fun circuits I can't keep up with them all.
rico C wrote: | I'm strolling around a casino in a distant galaxy...as the aliens win big, the arcade machines begin to levitate... | _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
|