More-Programmable Speaker

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Roxor128
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Oct 02, 2016 9:48 am
Contact:

More-Programmable Speaker

Post by Roxor128 »

This one's easy to sum up in a sentence:

Allow the instrument and volume of the programmable speaker to be set via the circuit network as well as the pitch.

Both would be great for making music with it.

Right now, if you want to be able to change instrument and volume, you need a rather large mess of speakers and combinators. For ten instruments and just four volume levels, that's 40 speakers, plus a heap of combinators to ensure only the desired speaker actually plays anything. It works, but it's very tedious to set up, even with blueprints, as there are a lot of unique values that need to be set.

On the other hand, a more-programmable speaker would just need you to set which signals to take for controlling what parameter.

Just as you can now toggle a checkbox to pick whether the speaker has its pitch controlled by a signal or uses a particular one set by the user from a drop-down menu, provide similar ones for instrument and volume.

With the instrument one clear, you'd get the drop-down menu you get now. With it checked a number from 1 to N would pick which entry from the menu gets used.

With the volume box clear, you'd get the current slider. With it checked, the speaker would take a value (probably 0-255, given that's pretty common) to use for the volume.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: More-Programmable Speaker

Post by ssilk »

I find that pretty, but it's not very pratical. Someone who knows midi, would think that the volume information is part of the notes and not somthing which is sent over a different channel. So it in my eyes quite is logical, that volume is just a new type of circuit signal.

Same with anything else...
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Roxor128
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Oct 02, 2016 9:48 am
Contact:

Re: More-Programmable Speaker

Post by Roxor128 »

ssilk wrote:Someone who knows midi, would think that the volume information is part of the notes and not somthing which is sent over a different channel.
Locking the volume to the note? That's kind of already the case if you use the "mass of speakers and combinators" approach to selectable volume. I'm pretty sure MIDI isn't that restrictive, though. Not that I know much about the details of it, but I do listen to a fair few MIDI files, and I'm pretty sure I've heard a few with volume slides.
ssilk wrote:So it in my eyes quite is logical, that volume is just a new type of circuit signal.
That's exactly what I'm asking for. Being able to control the speaker by up to three signals, depending on what you want under software control.

In the maximal case, one signal for note, one for instrument, and one for volume.

In the minimal case, a single signal for play/don't play, with note, instrument and volume set manually by the player, so it always plays the same note on the same instrument at the same volume every time it's triggered (which you'd probably use for something like an alarm).

Ideally, changing the volume would be possible while a note is playing, which would allow you to implement volume-slides by sending a sequence of increasing or decreasing values on the volume signal. This isn't possible with the "mass of speakers and combinators" approach to selectable volume. That only allows you to set the volume when you start playing a note, not while it's playing.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: More-Programmable Speaker

Post by ssilk »

Roxor128 wrote:That's exactly what I'm asking for. Being able to control the speaker by up to three signals, depending on what you want under software control.
To make it 100% clear: We meant, that there is a standardized new signal type, that is interpreted by the speaker as "velocity" signal (which is part of midi standard for each note, so there could be in some future a converter from midi to Factorio signals).

Also a new signal type "Instrument", which (when set) switches the instrument type.

And there could be a lot more signals. Midi standard for example knows "press" and "release" of a note.

And the general target should in my opinion be this:
As source there is some midi-file, which can be seen as a description of "ordered events". And as output in Factorio there is a device, that can translate such a midi-file into circuit network and route the events based on rules to different circuit signals.

And for what to use something like that? For example Factory streets. When order of doing matters. When we need to repeat (loop). And thousand other things.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Roxor128
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Oct 02, 2016 9:48 am
Contact:

Re: More-Programmable Speaker

Post by Roxor128 »

ssilk wrote:
Roxor128 wrote:That's exactly what I'm asking for. Being able to control the speaker by up to three signals, depending on what you want under software control.
To make it 100% clear: We meant, that there is a standardized new signal type, that is interpreted by the speaker as "velocity" signal (which is part of midi standard for each note, so there could be in some future a converter from midi to Factorio signals).

Also a new signal type "Instrument", which (when set) switches the instrument type.

And there could be a lot more signals. Midi standard for example knows "press" and "release" of a note.

And the general target should in my opinion be this:
As source there is some midi-file, which can be seen as a description of "ordered events". And as output in Factorio there is a device, that can translate such a midi-file into circuit network and route the events based on rules to different circuit signals.

And for what to use something like that? For example Factory streets. When order of doing matters. When we need to repeat (loop). And thousand other things.
Sorry, ssilk, you've completely lost me. I have no idea what you're trying to describe now.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: More-Programmable Speaker

Post by ssilk »

I mean this:

Code: Select all

          MIDI File     =>     Combinator     =>     Signals on wire
The combinator makes a translation from the midi file to signals in the "rhythm" of Factorio ticks.

When in the midi file a key is pressed, the combinator translates that to two signals: One is the tone height, the other the velocity of that tone.
When the key is relesed, the signals are also released.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Roxor128
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Oct 02, 2016 9:48 am
Contact:

Re: More-Programmable Speaker

Post by Roxor128 »

ssilk wrote:One is the tone height, the other the velocity of that tone.
I don't know what you mean by either of these terms. I could try and ask how they correspond to MOD pattern data, but I'm afraid that might just result in more cases of us not knowing what the other is talking about.

As a common reference point, let's break things down to as simple a synthesiser as I can come up with that could still be useful. I'm writing this on the spot right now, so it's untested and probably buggy (C++, though if I got it right it'll probably compile as C if you change the comment syntax).

Code: Select all

// freq: frequency in Hz
// vol: volume 0-1
// waveform: 0=square, 1=sawtooth, 2=triangle
// t: current time in seconds from start of playback session
float generate_sample(float freq, float vol, int waveform, float t)
{
 float retval=0;
 float tf = frac(t/freq); // get position through a wave
 switch (waveform)
 {
  case 0:
   (tf > 0.5) ? retval=1 : retval=-1;
   break;
  case 1:
   retval = (tf-0.5)*2;
   break;
  case 2:
   retval = ( (tf<0.25) ? tf*4 : ( (tf>0.75) ? ((tf-0.75)*4)-1 : (1-(tf-0.25)*2)*2 ) );
   break;
  default:
   retval=0;
 }
 return retval*vol;
}
This function is pretty general. If you want specific notes, you need to convert them to a frequency first either via a lookup table in a simple usage (such as Factorio's programmable speakers) or via a formula in a more complex situation.

If you want a second worth of a 440Hz sawtooth wave at 50% volume at a 96kHz sample-rate, you'd use it like this:

Code: Select all

int len=96000;
float buffer[len];
int rate=96000;
float time=0;
float dt=1.0/rate;
for(int cnt=0; cnt<len; cnt++)
{
 buffer[cnt]=generate_sample(440,0.5,1,time);
 time+=dt;
}
Now, which of the input parameters for this function do the terms I don't understand correspond to?

juggernaut
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Jul 20, 2016 7:41 am
Contact:

Speaker volume controlled by signals.

Post by juggernaut »

Please add to the speaker the ability to change its volume using signals, as is done for the “tone”.
Simple request, simple topic.) Thank

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: More-Programmable Speaker

Post by Koub »

[Koub] Merged into older thread with encompassing suggestion
Koub - Please consider English is not my native language.

Post Reply

Return to “Ideas and Suggestions”