Back to Home

Nostalgia for Half Life - creating a prefix for a radio station to receive the voice and sound of the ending in the style of combines

half-life · diy · atmel · attiny · attiny85 · dream · games · childhood · old school

Nostalgia for Half Life - creating a prefix for a radio station to receive the voice and sound of the ending in the style of combines


    Once upon a time, when the trees were large, there was such a Half-Life shooter, the continuation of which is still awaited - this is already a byword.

    There were opponents such as Combines (Combine Soldiers) - people changed by the invaders.
    During the game, one could hear their conversations on the radio - and I just dreamed of a radio station that would make the voice look like them and have the same sound when the broadcast ended.

    After a lot of time, I still decided to fulfill my dream.

    The negotiations were like this:


    At that time, I really dreamed of making my radio station have at least the same roger beep as in these negotiations. Who does not know what a roger beep is - a signal to end the transmission, the one that sounds at the end of each message.

    In the game, his tone changes depending on the soldier, here is something in between:


    Then it was difficult for me to do it, but the development of microprocessors today has made it not only possible to easily repeat it, but also to slow down the voice so that it is even more similar to what was in the game.

    The heart of this scheme was the processor from the company ATMEL - ATTINY85.

    And yes - real time audio processing on the tiny ATTINY85 - it's quite possible :)

    The result of the work on the example of the voice of Geralt of Rivia


    Original sound


    Modified sound


    Live does not sound so deaf and more clear. Here, due to the many transformations and transcoding, this happened, but the overall picture, I think, is understandable.

    We can say that this is all “just for fun”, but if you remove the voice transformation, then the scheme allows you to add the roger beep to any radio station if it has a connector for accessories like “kenwood” (the same double connector).

    I tested it on Baofeng-888s, and it just doesn’t have a roger beep, so the ability to do this, or, for example, scrambling, is quite fun.

    How does the firmware work?


    In fact, there is nothing complicated there.

    A low-speed peripheral mode is used (via PLLCSR) - in this case, ATTINY can be powered from 2.7 volts and this gives a sampling frequency of about 9kHz.

    It was possible to use high-speed mode, which would give a frequency of about 18kHz, but then it would be necessary to use a supply voltage of 4.5 volts, and there were problems with this.

    When you press the transmit button on the tangent, an interrupt is generated and ATTINY wakes up, turns on the transmission mode to the radio stations and uses ADC at a frequency of about 8.9kHz to digitize the voice from the microphone into the cyclic buffer:



    When the next value is entered into the buffer, it is mixed with the previous one - is the average, i.e. the formula is:$ (oldValue + newValue) / 2 $.

    This gives us the opportunity to experience the case when the old meaning has not yet been surrendered, and a new one has already taken its place. And this will happen sooner or later, because read and write speeds are different.
    The pointers to the buffer increase after each such operation, when they reach the maximum, they are reset to zero - i.e. to the beginning of the buffer - that's why it is called circular.

    ATTINY does not have much memory - only 500 bytes, in this case 450 bytes will be used under the ring buffer, because memory is also needed for variables and stack.

    The buffer has two pointers - one is written data, the other is read and the ratio of this just sets the read speed relative to the write speed.

    When reading data is transmitted through PWM and after a smoothing filter, it turns into sound, which goes into the microphone path of the radio station.

    By the way, through PWM it turns out very good quality and it can be used for any place where you need to play some kind of sound (music boxes, gifts, etc.), and ATTINY has enough conclusions to connect even SD - and then you can even whole compositions to play.

    But back to our scheme: when you release the button, ATTINY still holds the transmission mode, stops the digitization, and gives the digital sound of the roger beep through PWM, then turns off the transmission mode and goes to sleep to reduce power consumption.

    Sound, because takes up a lot of space - about 5 kilobytes - takes up part of the memory for the program - because this memory is enough for the code - this solves the problem of lack of memory.

    As for the degree of slowdown or speed up of the voice, the desired coefficient should be written to 0 EEPROM ATTINY address, and, accordingly, it can be changed from 0 to 255.

    Examples of values:
    30 speed up the voice
    55 unchanged
    75 slow down the voice

    Scheme


    The device itself will be a tangent (or more correctly - a manipulator) to the radio station and will work with it through the standard Kenwood accessories connector.

    The scheme is very, very simple, easy to assemble “on the knee”.

    I ordered the microphone amplifier module on Aliexpress, and I recommend just this type of module, which is here in the photo. It is powered by 3-5v, the cost is about $ 2.

    A speaker needs about 8 ohms, 0.5-1 watts.

    Button - any, working on the circuit. Any LED with the ability to work from 3 volts, well, or with an appropriate resistor.



    There is one feature that did not fall into this circuit - the 5-volt power supply of the accessories is provided in the accessory connector, but specifically, in the Baofeng-888s, something the Chinese did wrong. Not only is there 3 volts, it also drops to 0.7 volts under load and, of course, the circuit does not work.

    In order to get around this, a tiny DC-DC converter from 1.2 to 3.3 volts with Aliexpress and an external connector for connecting any AA-battery was added.

    And by default, when nothing is inserted into the connector, the circuit will try to be powered by the radio station.

    What does the assembled circuit look like: The culprit of the celebration: How to make a double plug (KENWOOD connector) for a radio station: Two plugs 3.5 and 2.5, wound together with electrical tape - where without it.













    Housing


    There is nothing particularly complicated here, the only thing I had to tinker with is a window in the form of a lambda. It turned out quite crookedly, but a little bit like it :) I

    made it a dremel, then glued it with tape on the front side, and poured glue from the glue gun on the opposite side, drowned the LED on it, which lights up when the transmission is in progress.

    There is no external power connector yet.

    Outside: Inside: All together:











    Summary


    In general, I fulfilled my childhood dream and although it was irrational, its fulfillment warms my adult soul. I hope someone experiences similar feelings. :)

    Firmware


    FUSE-bits for ATTINY85 (8Mhz, power> = 2.7v):

    0xE2 LOW
    0xDD HIGH
    0xFF EXTENDED

    Download firmware files
    In the near future I will try to comb and lay out the source of all this.



    Note


    Since my brother did not work out with UFOs, I decided to publish this article on Habré on my own behalf. When I collected it - you know - I was happy as a child. And I thought that she was worthy of the attention of the habrasociety.

    She lives with me with the radio station YAESU, and works fine, powered by the station itself.

    New firmware versions and files related to it can be found on my brother’s blog protocoder.ru .

    Well, since I was directly involved in the development and put together the same thing myself, I’ll try to answer any questions about it.

    Read Next