<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Reetwiz on Medium]]></title>
        <description><![CDATA[Stories by Reetwiz on Medium]]></description>
        <link>https://medium.com/@reetwiz02?source=rss-3618b27af47e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tn0KkhSnAc_AjSgk</url>
            <title>Stories by Reetwiz on Medium</title>
            <link>https://medium.com/@reetwiz02?source=rss-3618b27af47e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:25:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reetwiz02/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Neural Audio Synthesis and Timbre Transfer: A Step Towards Digitalizing Musical Instruments]]></title>
            <link>https://medium.com/zerone-magazine/neural-audio-synthesis-and-timbre-transfer-a-step-towards-digitalizing-musical-instruments-30337b65197f?source=rss-3618b27af47e------2</link>
            <guid isPermaLink="false">https://medium.com/p/30337b65197f</guid>
            <category><![CDATA[technical-competition]]></category>
            <dc:creator><![CDATA[Reetwiz]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 17:58:52 GMT</pubDate>
            <atom:updated>2024-12-24T18:13:12.311Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Necessity to Cook:</h3><p>A few days ago, I could only associate the word ‘tom’ with a cat. The only ‘kick’ I recognized was the thrust of a hind leg. Today, our drummer asked me, “How have you been ideating and sending me the drum loops when you can’t even differentiate the sound of a kick from that of a tom?” I paused for several seconds, puzzled by the latter part of his question. Then he broke the silence and explained that the kick and tom are parts of a drum kit. He then asked me to address the first part of his question. I responded that I had been using my voice to imitate the sound of a drum and generating drum samples with the help of artificial intelligence. Our drummer expressed a desire to learn how he could incorporate this technique into his workflow.</p><p>I began by explaining how <strong>timbre transfer</strong> can alter the sound of any input instrument to resemble a specific target instrument and how we can generate samples of the target instrument without any input using <strong>audio synthesis</strong>. Both of these processes can be accomplished with the help of <strong>Variational Autoencoders (VAEs)</strong>.</p><h3>The Ingredients:</h3><ol><li><strong>Timbral and Non-timbral Characteristics</strong></li></ol><p>A vibrating object moves back and forth at a specific rate, generating sound at a particular volume. This rate is known as frequency. Specific frequencies can be represented by a letter and a number; for example, 130.81 Hz corresponds to C3, and 196 Hz corresponds to G3. A single frequency is referred to as a pure tone.</p><p>We plan to produce pure tones of 130.81 Hz for two seconds, followed by 196 Hz for the next two seconds on a musical instrument. We will call this melody “C3 followed by G3.” However, it is essential to recognize that a pure tone can solely be generated by an ideal sine wave generator rather than by musical instruments. Most sounds, including those produced by vocal cords and musical instruments, comprise a fundamental frequency — the desired pure tone — and a series of higher frequencies referred to as harmonics or overtones. Harmonics are the additional frequencies that are integer multiples of the fundamental frequency. For C3, the harmonics include 261.62 Hz (2 times the fundamental), 392.43 Hz (3 times), 523.24 Hz (4 times), and so on. This combination of sounds is what we recognize as a note.</p><p>In nature, each vibrating source generates a distinctive set of harmonics and an energy distribution corresponding to those harmonics. For instance, the C3 note produced by your vocal cords may have a second harmonic with higher energy than the third harmonic but lower energy than the fundamental frequency. In contrast, the second harmonic may have higher energy for a flute than the fundamental frequency. This unique set of harmonics gives each instrument its distinct fingerprint, known as timbre. Timbre is the characteristic quality that makes different instruments sound unique, even when playing identical notes at the same volume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*t4w-rLbpmBCh8EUPWWk8Ng.png" /><figcaption>Figure 1. The melody ‘C3 followed by G3’ played on two different instruments.</figcaption></figure><p>To understand timbre scientifically, we will examine the visual representation of sound, called a spectrogram. This graph displays the intensity of different frequencies over time for our melody.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cP0z5neY2YPy-UXspzkcmw.png" /><figcaption>Figure 2. Spectrograms for the melody ‘C3 followed by G3’ played on two different instruments. Brighter colors indicate higher energy, whereas darker colors indicate lower energy for the given frequencies at specific times.</figcaption></figure><p>We observe that the lowest intended frequency, known as the fundamental frequency (or pitch), remains the same for both instruments: C3 at 130.81 Hz and G3 at 196 Hz. For both flutes, the second harmonic shows the highest energy. The spectrogram of the steel flute displays a series of smooth, evenly spaced lines that represent the harmonics, with a higher concentration of energy in the upper harmonics. This results in a bright, sharp timbre. In contrast, the spectrogram of the bamboo flute exhibits harmonics with varying relative intensities and a stronger energy concentration in the lower harmonics, resulting in a soft, mellow timbre. We also observe frequencies below the fundamental frequency and outside of the harmonics, referred to as noise components, which further contribute to the timbre. Playing techniques like blowing into the flute introduce these noise components.</p><p>While we expect each note to last exactly 2 seconds, the actual durations may vary slightly from the intended timing. Ideally, the sound would maintain a constant amplitude throughout its duration, but this is rarely the case. This variation occurs because every instrument has a unique ADSR envelope, which defines how its sound evolves from the initial attack to the final release. The attack phase refers to the time it takes for a sound to reach its maximum amplitude after being initiated. The decay phase is the time it takes for the sound to decrease to a steady sustain level. Sustain is the amplitude level the sound maintains while the note is played, and release is the time it takes to fade to silence after the note ends.</p><p>To illustrate this concept, consider the sound of thunder. The explosive crack represents the attack phase, followed by the decay phase, where it transitions into a deep rumble. In the sustain phase, the rumble stabilizes at a lower amplitude, and in the release phase, it gradually fades into silence. The ADSR envelope of each instrument defines its sound characteristics and influences the durations seen in the spectrogram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*5q2XZIAL3xWnTj6YIPj3Sw.png" /><figcaption>Figure 3. ADSR envelope for bamboo flute and steel flute</figcaption></figure><p>We conclude that the timbre of an instrument is determined by its unique set of harmonics, noise components, and ADSR envelope. These elements are collectively referred to as <strong>timbral characteristics</strong>. In contrast, factors such as pitch and timing are not specific to any particular instrument and are classified as <strong>non-timbral characteristics</strong>.</p><p><strong>2. Audio Synthesis and Timbre Transfer</strong></p><p>Imagine we have 1,000 recordings of a flute, all sampled at 44.1 kHz. According to the Nyquist theorem, this sampling rate allows us to accurately capture all frequencies up to 22.05 kHz, well above the typical upper limit of human hearing (around 20 kHz). This means we can represent the audio signals without losing essential details. However, analyzing raw waveform data can be overwhelming, especially with 44,100 data points every second.</p><p>Instead, spectrograms can simplify the intricate time-domain signals into an easier-to-read frequency-time format. Spectrograms reveal patterns and characteristics of the flute recordings, such as harmonics, noise, and shifts in timbre. This approach makes it much simpler to understand and work with audio for tasks like synthesis and timbre transfer.</p><p>So, we convert the 1,000 recordings into spectrograms using the Short-Time Fourier Transform (STFT). After a month of analysis, we might be able to extract meaningful patterns from these images. We could then spend an additional month creating our own spectrograms based on the patterns we have deciphered. We can obtain an audio signal by performing the Inverse Short-Time Fourier Transform (ISTFT) on these spectrograms. Since we focused on the patterns associated with a flute’s sound, the resulting audio will resemble a flute. Essentially, we have ‘synthesized’ the sound of a flute. This operation is called <strong>audio synthesis</strong>.</p><p>Again, imagine we have 1,000 recordings of a bamboo flute and want to make it sound like a steel flute. First, we would analyze the patterns of the bamboo flute recordings. Next, we would compare these patterns to those of the target instrument, the steel flute recording we already own. Then, we would adjust the parameters that define the unique characteristics of the bamboo flute, such as its harmonic content, noise, and the ADSR envelope, to align them with those of the steel flute. This entire process is known as <strong>timbre transfer</strong>. It can be defined as modifying an input instrument’s timbral characteristics — harmonics, envelope, and noise components — to mimic the target instrument’s timbre while preserving its non-timbral characteristics — pitch and timing. It is akin to a painter effortlessly swapping colors within shapes while keeping the same canvas intact.</p><p><strong>3. Variational Autoencoders (VAEs)</strong></p><p>Relying on human intuition to identify and reconstruct patterns can be cumbersome. Therefore, we will utilize an artificial neural network (ANN), specifically VAEs, to translate our task into the neural domain. VAEs are designed to learn complex data distributions and generate new data samples based on these learned patterns.</p><p>To understand VAEs, we first need to grasp their precursor: Autoencoders. The architecture of an autoencoder consists of two main components: an encoder and a decoder. The encoder processes the input, extracts the most meaningful information, and represents this information as a single point in a latent space. The term “latent” refers to the hidden or abstract features contributing to this representation that are not directly observable in the input. This latent space is structured so that similar pieces of information are located close to each other while dissimilar information is placed further apart. The decoder can then randomly sample these points and reconstruct the original input.</p><p>This process can be thought of as summarizing multiple texts into a new page (the latent space). Similar summaries are positioned next to each other as points, and their placement is influenced by factors (latent variables) such as genre, purpose, complexity, etc. By sampling from a summary (latent point), we aim to recreate the entire text.</p><p>However, autoencoders’ limitations include the fact that the points in the latent space are not uniformly distributed. The result can be nonsensical if the decoder samples an unencoded point from this space. VAEs address this issue by mapping the extracted information not to a single point but to a multivariate normal distribution characterized by its mean and variance for each input. This approach ensures that the latent space is smooth and continuous, allowing the decoder to sample any point in the space and still generate meaningful outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kRbYY5XaS1mMcTXH1KgUrA.png" /><figcaption>Figure 4. Encoding of input data in an autoencoder and a VAE</figcaption></figure><h3>The Recipe:</h3><p>We will be training VAEs for drum sounds.</p><ol><li>Similar to how a drummer practices on various tracks to replicate sounds, we train our VAE using a diverse collection of drum recordings, enabling it to learn the intricacies of different drum sounds. In our analogy, if genre, purpose, and complexity represent the latent variables in a text summary, then, in our case, the timbral and non-timbral characteristics serve as the latent variables that map specific spectrogram inputs to regions of a multivariate normal distribution in the latent space.</li><li>After a single practice session, the drummer compares their performance to the reference track and might notice some inaccuracies or a “loss.” Similarly, the VAE consists of a loss function that combines reconstruction loss and KL divergence loss. In our VAE, the decoder samples the mapped input from the latent space and attempts to reconstruct the spectrogram image. If the reconstructed image matches the original, the reconstruction loss will be zero. This indicates we are on the right track. However, the main advantage of using a VAE over a standard autoencoder is its ability to interpolate latent points for unencoded data effectively. Therefore, we aim to minimize the <em>KL divergence loss</em>, which quantifies how close the learned normal distribution is to a standard normal distribution. By reducing the loss function, the VAE becomes more accurate.</li><li>A drummer may recognize the need to improve their physical fitness to enhance their drumming accuracy. So, they work out, lose some weight, and return to practice with renewed focus. Likewise, in our VAE, we adjust the weights of the artificial neural network (ANN) and run a new epoch, akin to the drummer’s new practice session. This process results in improved accuracy for the VAE.</li></ol><p>After repeatedly practicing with the same reference tracks for countless practice sessions, the drummer develops the skill to translate what he has learned onto his drum set. Similarly, our VAE, after training on the same dataset for multiple epochs, becomes proficient at reconstructing the spectrogram images it has been trained on.</p><h3>The Final Dish:</h3><p><strong>Neural Timbre Transfer</strong>: When an instrument sound is passed to a VAE trained on drum sounds, the encoder generates a latent representation of the input. The decoder then reconstructs an output based on this latent representation. Since the drum data have shaped the latent space during training, the decoder produces outputs resembling drum sounds, as these represent the dominant features encoded within the latent space. Consequently, the reconstructed outputs reflect the characteristics of the drum sounds learned by the VAE.</p><p><strong>Neural Audio Synthesis</strong>: By operating the decoder independently to randomly sample from the latent space, generating a new drum dataset is possible.</p><p>Since sound is perceptually auditory, I encourage you to listen to the results here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*vx4zxMGgK_kqiqsmX-ohKg.png" /><figcaption>Figure 5. QR Code for <a href="https://youtu.be/hUuWGaWRpAo">https://youtu.be/hUuWGaWRpAo</a></figcaption></figure><p>Similar to the transformative impact that MIDI has had on the music industry over the past four decades, neural audio synthesis and timbre transfer hold significant potential to leave a lasting impression by digitalizing musical instruments and democratizing music creation for musicians and non-musicians.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30337b65197f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zerone-magazine/neural-audio-synthesis-and-timbre-transfer-a-step-towards-digitalizing-musical-instruments-30337b65197f">Neural Audio Synthesis and Timbre Transfer: A Step Towards Digitalizing Musical Instruments</a> was originally published in <a href="https://medium.com/zerone-magazine">The Zerone</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>