Combinator Jukebox

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
Post Reply
SuicideJunkie
Fast Inserter
Fast Inserter
Posts: 123
Joined: Wed Aug 23, 2017 10:17 pm
Contact:

Combinator Jukebox

Post by SuicideJunkie »

I have made a Jukebox!
Jump to latest, useful version in this thread: viewtopic.php?f=193&t=61306#p370811


Original prototype below
------

When a green signal of 1 comes in from the bottom right, the song will be loaded from the combinators on the left and start playing! When the green signal goes to zero, the clock resets.
I'm not the best at this, so it is not super optimized. If anyone cares to improve it, please do so, and let me know so I can make mine better too!

The blueprint I've attached is what I've been using to play (an off-key) Twinkle Twinkle Little Star whenever a rocket is launched at my base.
You get one note per signal (with Fish and Green being reserved for Clock and Play respectively), so tunes can be quite long although you'll need multiple constant combinators on the left side for longer tunes.

I hope people with more musical talent will take advantage of this to write or translate better songs and post them.
With two or more copies of the system, more instruments and chords can be used as well.
Jukebox.png
Jukebox.png (519.54 KiB) Viewed 4796 times
blueprint string
Detailed explanation:
Song Constants: High bits of the signal = timing. Low bits = pitch.
Clock adds Green and multiplies by Green, so 0=reset and 1=Play
The clock is bitshifted up to the same position as the timing bits to simplify the memory cell.
Memory cell forgets each note as the clock passes it, and on that last cycle before getting dropped, the note is passed on to the output.
Output block filters out the timing bits, leaving only the pitch bits, and combines them all down to Green signal.
Green signal then gets played on the speaker.
Jukebox_labels2.png
Jukebox_labels2.png (606.92 KiB) Viewed 4796 times
[/spoiler]
See the latest here:
Last edited by SuicideJunkie on Fri Jul 06, 2018 3:48 am, edited 1 time in total.

johnwhile
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue May 08, 2018 10:01 pm
Contact:

Re: Combinator Jukebox

Post by johnwhile »

Wow, nice, to create the music you have used some tools to convert MIDI file to bits or you have done all manualy ?
it is very interesting now to try to optimize, reduce the bits and use more speakers... i will try :mrgreen:

SuicideJunkie
Fast Inserter
Fast Inserter
Posts: 123
Joined: Wed Aug 23, 2017 10:17 pm
Contact:

Re: Combinator Jukebox

Post by SuicideJunkie »

I plugged in numbers manually, using the top left bit shifter so that timing and pitch could be typed in separately. I did a terrible job on the tune, but it works as a proof of concept.

I should also note that a serious jukebox would use a "Green > 0" => "1xGreen" combinator on the play button, and a set of "Green = X" filters to decide which of multiple tunes to load into the memory cell.

johnwhile
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue May 08, 2018 10:01 pm
Contact:

Re: Combinator Jukebox

Post by johnwhile »

Hi, now i understand your system, is not so simple :mrgreen:
I'm working in this way:
idea to encode
Like you i will use one signal to encode 3 different pitch, 1 time and 1 note position.
One constant combinator can contain 18 signals but with the note's position number you can chain 2048/18 = 113 constant combinators for a total of 2048 notes. But the hard work is write manually all these numbers....

SuicideJunkie
Fast Inserter
Fast Inserter
Posts: 123
Joined: Wed Aug 23, 2017 10:17 pm
Contact:

Re: Combinator Jukebox

Post by SuicideJunkie »

How do you plan to actually get durations out of a speaker? As I understand it, the speakers play a fixed strum/ding/plink/etc sample, and if the signal is still present, they repeat it.
IE: DingDingDingDing, not Diiiiiiiiiinnnnnng.

Chords in one signal is a good addition; when the timing activates it, you can have three parallel mask & bitshift paths to send pitches to three separate speakers.
I had tried to think of a way to have it be Pitch bits, Speaker bits, Timing bits, but I couldn't see a way to break up the speaker bits from the pitch and then bring them back together because they're the same signal and would just add together.

To extend that idea in a different direction:
A couple bits can be reserved for paging... instead of being wired into a speaker, they'd be wired into a loader for another bank of constants and would also trigger a clock reset. That would allow for very long tunes. Even more so if the page loaders are specific to the signal type. If the low bits were set it would also play the final note, but if the pitch bits cover 1-63, a 64 would load page 2, 128 would load page 3, 192 would load page 4, etc, and 512 and up would be timing bits within the page.

I'm also thinking that the clock can be removed, by doing Memory Cell ---> {EACH} > 0 => 1x {EACH} ---> {EACH} * -512 ----> Memory Cell.
IE: Subtract 1 from the timing bits of all signals in the memory cell. Then play them when they reach time=0 rather than time < clock.
Not entirely sure if the combinators will do that; I'll have to test it after work. It will free up the fish signal for another note. It will also need plenty of bits reserved for timing, but multi-page tunes would no longer be limited by the clock overflowing, and spending more bits on chords instead of timing would be more affordable.

---

Actually, I think I may have just seen what you mean for your Time value.
The fish clock signal would tick once, and release the first note. Then a secondary clock would count down from 2^N. When it hits zero, it increments the fish clock by one, releasing the second note and that note definition would add to the secondary clock so it counts down towards zero again. Repeat until done.
You can't hold the note as such, but you can delay the start of the next one arbitrarily long.
That would be completely compatible with the paging idea, and I think would make the songs potentially play for years with enough constant combinators.

johnwhile
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue May 08, 2018 10:01 pm
Contact:

Re: Combinator Jukebox

Post by johnwhile »

True... after some test with a clock where are no way to make a continuous sound, one note have its fixed time of execution. So, is not necessary indixing the notes, just sort notes by time: store only pitch (or more pitch) and time of execution.

To chain more constant combinators and avoid sum of signals require some combinators to select the correct input....

johnwhile
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue May 08, 2018 10:01 pm
Contact:

Re: Combinator Jukebox

Post by johnwhile »

After various versions I came to the conclusion that your system is the simplest. In this version I used a different method to filter the notes and i increase the song lenght.
scheme
TimeAndOnePitch
https://soundcloud.com/john-while/twink ... e-factorio :mrgreen:

SuicideJunkie
Fast Inserter
Fast Inserter
Posts: 123
Joined: Wed Aug 23, 2017 10:17 pm
Contact:

Re: Combinator Jukebox

Post by SuicideJunkie »

Jukebox Mk2!

This has three "tunes" pre-loaded.
Make your selection using the bottom-most constant combinator, setting fish = 1, 2, or 3.
Then give the inserter arm an iron plate 'coin' to begin the song!

#1 is johnwhile's rendition of Twinkle Twinkle, with alternating instruments.
#2 is a rapid note-sweep, which also then loads up #1 as a finisher.
#3 is the song that never ends (in its entirety)
JukeboxThatNeverEnds_Labels.png
JukeboxThatNeverEnds_Labels.png (696.19 KiB) Viewed 4620 times
Blueprint String
Perl code to generate the necessary constants from notes

Post Reply

Return to “Combinator Creations”