###### Abstract  
Electric and hybrid vehicles are known for their significant reduction in road noise. However, concerns have emerged regarding their silent operation, potentially increasing risks for other road users. To mitigate this, the Acoustic Vehicle Alert System (AVAS) has been mandated by regulations such as R138 by UNECE in the USA and Europe. This regulation dictates the generation of sound in electric vehicles of categories M and N1 during normal, reverse, and forward motion without the internal combustion engine engaged. Compliance involves meeting specific sound requirements based on vehicle mode and condition. This paper introduces a Python-based approach to designing digital horn sounds, leveraging music theory and signal processing techniques to replace traditional mechanical horns in electric vehicles equipped with AVAS devices. The aim is to offer a practical and efficient means of generating digital horn sounds using this software. The software includes an application capable of producing and customizing horn sounds, with the Horn-SoundGeneratorCUI class providing a user-friendly interface built with the Tkinter library. To validate the digital horn produced sounds by the software and ensure compliance with AVAS regulations, comprehensive electrical and acoustic tests were conducted in a fully equipped quality laboratory. The results demonstrated that the sound levels achieved met the required 105-107 dB/2 m standard specified by the regulation. electric vehicles; hybrid electric vehicles; acoustic vehicle alert system; sound synthesis; oscillator coding +
Footnote †: journal: Applied sciences  
138 regulation in 2017, coinciding with the development of various warning systems [9]. This regulation mandates the installation of an Acoustic Vehicle Alert System (AVAS), which generates sound to alert pedestrians of approaching vehicles within the 0-20 km/h speed range, with specific criteria outlining sound levels and frequency ranges. The preference for natural and clear sounds stems from their pleasing acoustic qualities. However, these sounds often do not align with vehicle characteristics and require customization. It is advisable to construct the sound concept based on layout-oriented sound components, allowing for adjustments in the driving sound frequency based on the current vehicle or engine speed. In the development of Acoustic Vehicle Alert Systems (AVAS), appealing sounds need to be crafted and integrated into an in-car application. This necessitates finding a suitable software and hardware solution, such as an Electronic Control Unit (ECU) equipped with adequate resources and interfaces like CAN-bus and audio output. Once the sound design phase is finalized, the desired sound profile is integrated into the in-car application, and appropriate adjustments are made within the vehicle. The primary purpose of the designed system is to enable real-time control of driving sound, reverse gear sound, and horn sound based on control parameters communicated via the CAN-bus. These parameters, transmitted from the vehicle through the CAN-bus protocol, include ignition status, driving mode (e.g., drive, park, reverse), and speed information. The ECU processes these inputs using a microcontroller (MCU), generates the corresponding sound file, and sends it to the amplifier. The amplifier then boosts the sound and projects it through a speaker. Additionally, while generating the driving sound, the system employs a pitch shift technique to incorporate acceleration and deceleration effects based on the vehicle's speed. The flexibility in the AVAS development process allows for additional functionalities, such as modifying the sound during vehicle startup, system initialization, or when the battery level reaches a critical threshold. By utilizing such parameters, the ECU dynamically adjusts the sound settings to reflect the vehicle's condition, and the sound is emitted through external and/or internal speakers [10].