# 买球有没有长期盈利的

## Learn Computer Programming and Audio Engineering

Welcome to Hack Audio. Here you will find informational content related to audio and computer programming, as well as a community of coders/engineers interested in music.

new information will be posted on a weekly basis for a range of experience levels – from beginner to professional.

if you feel like you don’t have a lot of experience with programming, that’s great! this blog is meant to help you go from zero to hacker hero.

content is organized by specific topics in the side menu or chronologically (by most recent) below.

Finally, I always appreciate connecting with other engineers. Feel free to contact me with feedback. I will try my best to respond as soon as possible.

i started this blog to deliver content about coding and signal processing for audio applications. i hope you will join me as part of a community of people interested in these topics.

have you ever wanted to:

• Learn how to program a computer to process or synthesize audio?
• Create your own mobile app, DAW effect plug-in, or virtual instrument?
• Apply the computer programming skills you already have towards your passion for music?

if so, you’ve found the right place! i hope to help you with everything you need to get started and help you have a fun time in the process.

additionally, if you are looking for resources on music production/recording/mixing, check out some my tutorials on and at .

Thanks for stopping by!

additionally, i started a podcast to share stories, interests, passions, anecdotes, philosophies, interviews, and everything else about the same topic.

Subscribe to the podcast on iTunes .

there are all kinds of items: from clothing to coffee mugs. we all know coders love (need) their java.

Do you want to stay up-to-date on the latest content from Hack Audio? Join the mailing list to receive weekly email notifications.

# MATLAB IIR Functions

There are several functions built-in to the MATLAB Signal Processing Toolbox which can be used to create IIR filters. Similar to the FIR filter functions, the IIR functions make it possible for a programmer to specify the type of filter (LPF, HPF, etc.) along with the defining characteristics (cut-off frequency, amplitude, etc.) and MATLAB produces the coefficients for the filter.

# MATLAB FIR Functions

there are several functions built-in to matlab which can be used to create various types of filters. these functions make it possible for a programmer to specify the type of filter (lpf, hpf, etc.) along with the defining characteristics (cut-off frequency, amplitude, etc.) and matlab produces an impulse response for the filter.

there are two functions that create feed-forward filters with a finite-length impulse response (fir). to create standard filter shapes (lpf, hpf, bpf, bsf), the function fir1 should be used. to create filters with any arbitrary amplitude response, the function fir2 should be used.

# Band-Pass Filter

a band-pass filter (bpf) is another type of spectral effect. it reduces the amplitude of low frequencies and also reduces the amplitude of high frequencies. however, a band of frequencies in the mid-range of the spectrum pass through the filter.

a delay of two samples is used in parallel. on the parallel path, the signal is flipped upside-down by multiplying by negative one. then, the two paths are combined together.

constructive interference occurs for frequencies in the middle of the spectrum. destructive interference occurs for low and high frequencies.

# High-Pass Filter

A high-pass filter (HPF) is a type of spectral effect. It is the complement of the low-pass filter. The HPF can be used to reduce the amplitude of low frequencies without changing the amplitude of high frequencies. In other words, the high frequencies pass through the filter and the low frequencies are cut.

When the two paths are combined at the output, low frequencies will be canceled out due to destructive interference. High frequencies will pass through with constructive interference. This is the opposite result of the low-pass filter. Therefore, by having a gain of negative one on the delayed path, it flips which frequencies…

# Filter Background

spectral filter effects are created by using short time delay. as discussed for echo effects, time delay can be described in units of seconds, milliseconds, or samples.

another was to describe a short time delay is relative to the length of a frequency’s cycle. the delay could be described as a fraction of a cycle, or in terms of degrees/radians. recall, half of a cycle is equal to 180 degrees. therefore, time delay has the effect of a phase shift.

the important thing is: different frequencies have a different amount of phase shift. a low frequency with a longer period has a different phase shift than a high frequency…

# Convolution Function

Another method to create delay effects involves the use of convolution and an impulse response. Convolution is a very important process in digital signal processing, and it is very common because it can be used for many types of delay effects. The convolution operation can be performed in Matlab by using a built-in function: conv.

[y] = conv(x,h)

input variables:

x – an array of samples representing the input signal.

# Multi-Tap Echo

this approach to creating the echo effect allows for precise control because each delay can be set to an independent time. similarly, the relative gain for each path…

# Tempo-Sync Echo

one technique used by audio engineers with echo effects is to synchronize the delay time with the . this technique will create signal repetitions which line up with the rhythm of the performance, rather than having the echo “out of time.”

to create a tempo-sync’d echo as a programmer, it is necessary to…

# Echo Effects

echo effects are one type of audio effect based on delaying a signal over time. in this case, listeners perceive an audible repetition of a signal after some duration of time.

listeners perceive distinct echoes when the time delay is relatively long (greater than ~30 milliseconds). when a time delay is short, listeners do not perceive echoes. instead, a single “fused” sound is perceived. this makes it possible to create other types of effects like: chorus, flanger, phaser, and spectral filters.

This important time delay duration of ~30 milliseconds is called the echo threshold. 买球有没有长期盈利的It represents the minimum time delay for a listener to perceive a distinct repetition…

# I/O Characteristics

one way to visualize the processing of an audio effect is to compare the amplitude of the output signal versus the amplitude of the input signal. this relationship is plotted on a two-dimensional axes, with the input amplitude on the horizontal (x-axis) and the output amplitude on the vertical (y-axis).

This is a different way to visualize the amplitude of a signal than the waveform.

for this plot, the idea is to display how the entire range of input amplitude values (e.g. from -1 to 1) get mapped to output amplitude values. for instance, if the input amplitude is 0.5, the plot will show…

# Infinite Clipping

infinite clipping is a type of distortion effect where the amplitude of a signal is processed to only allow a maximum and minimum amplitude value. all positive amplitude values are processed to equal the maximum value. all negative amplitude values are processed to equal the minimum value.

infinite clipping can be implemented in computer code using a conditional statement. if the signal amplitude is greater than zero, then the output amplitude is set to 1. otherwise (else), the output amplitude is…

# Functions

A very useful aspect of many programming languages, including Matlab, is the ability to create functions. (Note: the term, function, is used here as a computer programming concept. This is not the same thing as a function in mathematics.)

Already, we have looked at how to use built-in functions including: sqrt, abs, log10, audioread, audiowrite,
plot
, etc. These functions help us as programmers accomplish complicated tasks using a single command.

additionally, we can create our own user-generated functions. in this case, we are writing the code to perform the task of a function. then, we can execute the entire process by using a single command.

# Conditional Statements

Another type of control structure is called a conditional statement. In this case, the typical flow of executed commands is interrupted such that certain commands are only executed under certain conditions. If those conditions are not met, then those commands are not executed.

# Stereo Image Widening

stereo image widening is the process of changing the perceived panoramic width of an audio signal. it can be used to make a signal sound wider, as well as narrower.

This process is based on mid-side processing. As part of the process of encoding and decoding, the relative amplitude of the “mid” and “side” channels are adjusted.

to make a signal sound wider, the amplitude of the “side” channel is increased compared to the “mid” channel. to make a signal sound narrower, the amplitude of the “mid”channel” is increased…

# Mid-side Encoding

There are two necessary steps to perform mid-side processing. First, the two-channel, left-right stereo signal must be encoded as a two-channel, mid-side stereo signal. Then the process is reversed by decoding买球有没有长期盈利的 a conventional two-channel, left-right stereo signal.

Mid-side processing is based on an interesting consequence of stereo panning. For signals panned to the center of the stereo field, the amplitude of the signal is identical in the left channel and the right channel. Therefore, if the right channel is subtracted from the left channel, any signals panned to the center will cancel out. However, any signals panned to either of the sides will be left over.

furthermore, the right channel can be added to the left channel. this will result in a new signal called the “mids.” this is because…

# Mid-side Processing

mid-side (ms) processing is a special method of processing stereo signals. the purpose of ms processing is to decompose a stereo signal into different parts.

on its own, ms processing does not actually change the signal. however, it is meant to be used with other processing like equalization or compression.

when using ms processing, a conventional stereo signal with a left channel and right channel is separated into a mid channel and a sides channel. this way it is possible…

# Linear Panning

the panning potentiometer (pan pot) is a variable control allowing an audio engineer to place a signal at different locations across the stereo field. with a stereo pair of loudspeakers, the pan pot changes the signal from the left side over to the right side.

the basic function of a pan pot is to change the amplitude of a signal in the left channel and also change the amplitude in the right channel. when the pan pot is turned to the left, the amplitude of the signal in the left channel is increased while the amplitude in the right channel is decreased. when the knob is turned to the center, the amplitude is identical in both channels.

There are several mathematical panning functions which can be used to determine the level of the amplitude should be for each channel based on the position of a (virtual) panning potentiometer. The first, and most intuitive, function to consider is the linear panning function.

here are the steps required to calculate the linear panning functions. first, assuming the value…

# Mono to Stereo

every electric signal created by a single microphone capturing acoustic vibrations starts as a mono audio signal.

when that signal is routed through the channel of an audio console or of a digital audio workstation, the mono signal is converted to a stereo signal with two channels.

when working with computer code in matlab, a stereo signal is represented as an array with two columns. the first column is for the “left” channel and the second column is for the “right” channel.

the process of converting a mono signal to a stereo signal…

# Axes Labels

there are several parts of a plot within a figure window which can be labeled by the programmer. these parts are locations relative to the two-dimensional axes.

The horizontal and vertical axes can be labeled by using the commands: xlabel(‘string’) and ylabel(‘string’), respectively.

The title of the axes can be labeled using the command: title(‘string’).

# Tremolo

Tremolo is the audio effect created from using amplitude modulation买球有没有长期盈利的. of the effect can be found in many styles of music from different eras in time. Tremolo creates the perception of a pulsating signal.

it is an effect used most commonly with electric guitar. there are many with the  included. additionally, there are many versions of the effect in form.

Amplitude fades are a method to smooth out the transitions of amplitude changes. Audio engineers regularly use fades at the beginning and end of a sound file. A “fade in” gradually increases the amplitude of the signal from 0 to 1 (unity gain). A “fade out” gradually decreases the gain of a signal from 1 (unity gain) to 0.

# Subtracting Signals

another method signals can be combined is by subtracting the amplitude of one signal from another signal. when working with signals (or arrays in matlab) this is accomplished using element-wise subtraction.

# Combining Signals

therefore, an important task for audio engineers to perform is the process of combining signals together…

# RMS Amplitude

An analysis used for the overall amplitude of a signal is called the root-mean-square (RMS) 买球有没有长期盈利的amplitude or level. Conceptually, it describes the average signal amplitude. However, it is different than simply measuring the arithmetic mean of a signal.

an audio signal can have both positive and negative amplitude values. if we took the arithmetic mean of a sine wave, the negative values would offset the positive values and the result would be zero. this approach is not informative about the average signal level.

# Peak Amplitude

One measurement of a signal’s amplitude is to determine the peak. This process involves analyzing and comparing each sample to find the one with the greatest amplitude.

audio signals can have a positive and negative amplitude. therefore, the amplitude peak is actually based on the sample with the largest deviation from zero, positive or negative. this is specifically called the signal’s peak magnitude.

here is a two step process to determine the peak magnitude. first, take the absolute value of the signal. this will allow for a simple comparison between both positive and negative values. second, go through the samples to find the maximum…

# DC Offset

If multiplying a number by a signal scales the amplitude, adding a number to a signal performs an offset. From a waveform plot, addition shifts the value of every sample up (or down) by the same amount.

the term, “dc offset,” is commonly used by audio engineers to describe this operation. from the days of analog circuits, there were two types of current: direct current (dc) and alternating current (ac). when direct current was applied to  alternating current, the result was a signal shifted away from zero.

generally speaking, when we play audio signals over loudspeakers, it is better for the signal to be centered around zero. therefore, most of the time a dc offset should be avoided. however, there are a few situations…

# Linear Gain Change

The underlying process to control the amplitude of a signal is a linear gain change. This process involves multiplying the value of each sample in a signal by a number relative to a linear scale.

If the value of each sample is multiplied by a number less than 1, then the amplitude of the signal will be reduced. If the number is greater than 1, then the amplitude will be increased. If the number is 1, then the amplitude is unchanged. Audio engineers use the term, unity gain, to refer to a process where the amplitude is unchanged.

when we write computer code to perform a linear gain change, it is necessary to process the individual samples of a signal. one way to do this is to use a loop to index the individual elements of an array. as we access each sample, we can multiply…

# Loops

in programming, a loop is a control structure used for repeating commands several times. rather than having to type of the repeating commands each time, a programmer uses the loop to make writing the code more efficient and easier to read.

computers excel at repeating commands very quickly. therefore, the loop construct is very common in programming. we will use loops in several different ways when working with audio.

therefore, it is necessary to use keywords at the start and end of the loop. additionally, a counting variable is created to keep track of how many times…

comments allow a programmer to include text in their code that a computer will ignore, or not execute. initially, it might seem unnecessary to write text other than the required executed commands. there are several beneficial reasons why comments are a part of almost every programming language and why you should use them.

another reason to use comments is to temporarily stop the computer from executing a command without having to entirely remove the text. this way it is possible to save a command for future use, and quickly include it again by removing the comment.

the matlab symbol for creating a comment is…

# Current Folder

the matlab current folder is the working directory for the development environment. the current folder can be changed to different directories on your computer.

when writing a program, matlab will implicitly reference files contained in the current folder. if you are working with a sound file, matlab will search for the file contained in the current folder. it is possible to reference files outside of the current folder, but the location of the file must be explicitly provided.

# Workspace

the matlab workspace is the space in the computer’s memory where information is stored while working in the development environment. here, variables are stored when created and can also be deleted. several characteristics of variables are displayed in the workspace including the variable name, data type, and value.

as a programmer, it is important to be aware of which variables are in the workspace at different places in your code. referring to the workspace can help during the process of trouble-shooting code errors…

# Impulse Train

an impulse train is a signal that contains an impulse in every cycle. the signal starts a new cycle every time there is a new spike. one sample per cycle has a non-zero amplitude. all other samples have an amplitude of zero.

this signal is periodic because it repeats the same cycle. the fundamental frequency of the signal is based on the period of time between each impulse. spectrally, this signal has harmonics at both even and odd frequencies. all harmonics have…

# Triangle Wave

A triangle wave is a signal with amplitude increasing like a ramp for half a cycle and amplitude decreasing like a ramp for the other half a cycle. There is not a function in Matlab called triangle. However, a triangle wave can be synthesized by modifying the sawtooth function. The basic syntax for using the function is the following:

$latex [y] = sawtooth(2\cdot\pi\cdot f \cdot t,0.5)$

input variables:

f – frequency of the signal (scalar in Hz)

t – 买球有没有长期盈利的an array of time samples for a signal.

0.5 – 买球有没有长期盈利的for width where half the cycle is increasing amplitude and half the cycle is decreasing amplitude.

output variables:

y – an array containing a triangle-wave signal.

# Square Wave

$latex [y] = square(2\cdot\pi\cdot f \cdot t,duty)$

input variables:

f买球有没有长期盈利的 – frequency of the signal (scalar in Hz)

t – 买球有没有长期盈利的an array of time samples for a signal.

duty – 买球有没有长期盈利的for duty cycle. The percentage of a cycle which is positive from [0,100].

output variables:

y – 买球有没有长期盈利的an array containing a square-wave signal.

# Sine Function

periodic signals complete repetitive cycles. each point within a cycle can be described with cyclical units – either degrees or radians. a cycle in units of degrees starts at $latex {0}^{\circ}$ and finishes at $latex {360}^{\circ}$. equivalently, a cycle in units of radians starts at $latex 0$ and finishes at $latex 2\pi$. half a rotation is $latex {180}^{\circ}$ or $latex {\pi}$ radians. one quarter of a rotation is $latex {90}^{\circ}$ or $latex \frac{\pi}{2}$ radians, etc.

# Signal Synthesis

In other cases, it can be helpful to work with signals that were created as digital information. Any time a signal is created directly as digital information (or also as electricity), that signal can be described as a synthesized signal. In other words, synthesis is the process of creating a signal.

the nice thing about working with synthesized signals is we can create them to have desirable characteristics. this can be helpful when using “test signals” to analyze various audio effects (i.e. signal processing methods).

there are several common synthesized signals used in audio applications. this section demonstrates the synthesis…

# Signal Reverse

one method to process a digital signal is to rearrange the order of the samples contained in the signal. more specifically, to put the samples in the opposite, or backwards, order.

this creates a signal which has been reversed over time. the last sample becomes the first sample. the second-to-last sample becomes the second sample. this continues until the original first sample is placed as the last sample.

This effect produces some interesting results. One famous example can be heard in the guitar solos of Castles Made of Sand by Jimi Hendrix. This effect was originally created by feeding analog tape is the reverse order through a tape machine.

with digital signals, this effect can be created by indexing an array to extract the elements in a reverse order.

# Signal Splice

one of the most essential and basic edits is the signal splice. this involves splitting one signal into two or more parts. a similar task involves extracting a portion of a signal to create another signal.

# AudioWrite

The samples from an array can be converted and saved as an audio file using the built-in function: audiowrite.

the basic syntax for using the function is the following:

$latex audiowrite(filename,y,Fs)$

filename – a string containing the name of the file. Example: ‘testSignal.wav’

y – 买球有没有长期盈利的an array containing the samples of the audio signal.

Fs – a scalar of the sound file’s sampling rate.

further documentation for the function is available .

The samples from a digital audio file can be imported into Matlab by using a built-in function: audioread.

the basic syntax for using the function is the following:

$latex [y, Fs] = audioread(filename)$

input variable:

filename – a string containing the name of the file stored on the computer’s hard drive. Example: ‘testSignal.wav’

output variables:

y – an array containing the samples of the audio signal.

Fs – a scalar of the sound file’s sampling rate.

# Plot Function

a simple way to visualize the data in an array is to use the built-in, “plot” function for matlab. when this function is called, a new figure window will open and display a two-dimensional axes. the value of elements in the array are plotted on the vertical axis versus the element number along the horizontal axis.

The basic syntax for using the function is the following: $plot(y)$

y – an array to values

# Audio Signals

sound is vibration. it is created by the movement of a sound source. it travels through air (or another medium) by the movement of air molecules. it is captured with a receiver (a microphone or our ears) by the movement of a diaphragm.

There are several important characteristics of these vibrations. The rate at which these vibrations occur is called a signal’s frequency. The strength at which these vibrations occur is called a signal’s amplitude买球有没有长期盈利的. These concepts will be explored in much greater detail in subsequent posts.

audio (as a term) is more general…

# f(x) – Functions

mathematical functions describe the relationship between multiple things.

in our everyday lives, there are many examples of functions. the position on a map describes a location, north/south versus east/west. similarly, coordinates are used to describe a particular longitude and latitude.

With math, variables are used to represent these individual things. This is written generally as: y = f(x).

The previous equation can be read, “the variable, y, is a function, f, of the variable, x.” In other words, “y is a function of x.”

# Creating Arrays

each method has advantages and disadvantages. as a programmer, you should consider each option in different situations.

One efficient method to create arrays is based on using the colon operator (“:”) and another method is based on using the built-in function, linspace.

# Arrays

Just as strings are a type of variable where multiple text characters can be organized and grouped together, arrays are a type of variable where multiple numbers can be organized and grouped together.

Each individual number in an array is called an element.

the dimensions of the rectangular elements are described as rows and columns.

some arrays have multiple rows and multiple columns. another name for a multi-dimensional array is a matrix. one of the distinguishing factors…

# Text Strings

many computer programming languages (including matlab) interpret text information differently than numerical information.

text can be an individual character, like the letters in the alphabet. text can also be entire words or multiple words.

Regardless, when text is assigned to a variable, the data type of that variable is a string.

a string consists of text including: letters, symbols, and numbers. in this case, symbols and numbers are interpreted…

# Naming Conventions

When naming variables as a programmer, there are several rules which must be followed and several “best practices” which should be followed.

the matlab programming language has several restrictions for how variables can be named. variable names may be individual text characters or multiple text characters. variable names may contain numbers, but may not begin with a number. variable names may not contain spaces. variable names may not contain symbols such as: #, $, %, &, etc. there are several recommendations worth using when naming variables. use a variable name with a descriptive meaning whenever possible. think about the purpose of the variable and for what it will be used when determining a name. this will make your code easier to read, especially if you are having to review it months or years later. many programmers across many programming languages use a convention of character capitalization called: camel case. here, the first character in the variable name is lowercase… Read more # Variables computer programs are comprised of executed commands. when each command is executed the computer determines the result. 买球有没有长期盈利的typically it is helpful for the computer to remember the result by storing it in memory. this way the information can be used throughout the program. 买球有没有长期盈利的it might be as simple as storing the answer to a basic math equation. or it might be storing an audio file in memory for processing and mixing with other audio files. To organize and keep track of the information, the result of an executed command can be assigned to a variable. 买球有没有长期盈利的after a variable is created and assigned, it can be… Read more # Math Operators if you have ever had the experience of working with a calculator, then you are already familiar with some of the most important parts of programming a computer. when programming with audio, the mathematical operations of addition, subtraction, multiplication, and division are very important. 买球有没有长期盈利的in the matlab programming language, these operations can be executed by using the same symbols… Read more # Variable Types 买球有没有长期盈利的many programming languages have been designed so that computers can understand and store various types of information. this is helpful because people also categorize information. as an example, numbers and text are two distinct categories of information. 买球有没有长期盈利的sometimes it is advantageous for a person to use “3” instead of “three.” other times the opposite is beneficial. the same is true for a computer. additionally, some programming languages have specific categories of information based on content… Read more # Install Help here are some resources to help with the installation of matlab. mathworks provides for installation, licensing, and activation. 买球有没有长期盈利的here is a youtube tutorial for installing matlab on a operating system. a similar tutorial is available for the operating system… Read more # Programming Languages 买球有没有长期盈利的when programming a computer, you as the programmer tell a computer what to do. in order to communicate with your computer, it helps to be using the same language. a programming language is nothing more than a set of letters, numbers, and symbols that have meaning to a computer. a programmer can use the language to provide instructions that can be interpreted and implemented by a computer. 买球有没有长期盈利的computers can understand many programming languages. there are programming languages that were specifically created for music… Read more # Bi-quad Filter Function 买球有没有长期盈利的the bi-quadratic filter, usually called the bi-quad filter, is arguably the most important and widely used filter in audio signal processing. the same design can be modified to create many different filter types including a low-pass filter, high-pass filter, band-pass filter, low shelf, high shelf, peaking/bell, and all-pass filter. 买球有没有长期盈利的a bi-quad matlab function has been implemented and can be used to apply the desired filtering to a signal. the function can be downloaded… Read more # Feedback Filters besides feedforward filter effects, there are many filters that use feedback. this involves routing delayed samples of the output signal back to be combined with the input signal. feedback causes a frequency-dependent change in amplitude, which can be used for various types of filters. feedback filters are also described as infinite impulse response (iir) filters because feedback causes the system’s impulse response to theoretically last indefinitely. therefore, it is not possible to use convolution (conv) with iir filters. instead, we will use… Read more # Series Filters there are several different ways that filters can be combined together. one way is to put individual filters together in series, cascading one after the other. as an example, consider what would happen if a signal is fed through a low-pass filter followed by a high-pass filter. the question is: “what is the combined effect of using these filters together?” 买球有没有长期盈利的one of the filters reduces the amplitude of high frequencies and the other filter reduces the amplitude of low frequencies. this sounds a lot like a… Read more # Notch Filter 买球有没有长期盈利的a notch filter decreases the amplitude of frequencies in the mid-range of the spectrum. it allows the low frequencies and the high frequencies to pass through. audio engineers use this type of filter to cut out a problematic frequency. a notch filter can be implemented by modifying the low-pass filter effect. instead of using one sample of delay on the parallel path, the notch filter is created by using two samples of delay. a block diagram of the effect is shown… Read more # Low-Pass Filter a low-pass filter (lpf) is a basic type of spectral effect. it reduces the amplitude of high frequencies, but allows the low frequencies to pass through. studying how a lpf works and how it is implemented provides a foundation for learning about all types of spectral effects. 买球有没有长期盈利的the simplest digital lpf uses 1 sample of delay. by using the delay in parallel with a dry (unprocessed) signal, an interesting thing happens when the two paths are combined. By having two signals which get combined together at the output, we have set up “interference.” For high frequencies, this introduces destructive interference and the combined amplitude is decreased at the output. For low frequencies, there is constructive interference and the combined amplitude is… Read more # Basic Filter Effects 买球有没有长期盈利的there are many different types of spectral effects used in audio. these effects are typically used to change the amplitude of one frequency region in the spectrum by a different amount than another frequency region. These spectral effects can be described as filters because one frequency region gets filtered out while the other region does not. This section will focus on some of the basic filter effects. 买球有没有长期盈利的consider the low-pass filter (lpf), sometimes also called the high-cut filter. in this effect, the low frequencies pass through the filter without being changed in amplitude. however, the high frequencies are reduced in amplitude; they are filtered out. 买球有没有长期盈利的another type is the high-pass filter (hpf), or the low-cut filter. as the name suggests, the high frequencies pass… Read more # Feed-Back Echo 买球有没有长期盈利的one design approach to create an echo effect is to use feed-back delay. in this case, the output of the effect is fed back through a delay line to the input of the system. 买球有没有长期盈利的the use of feedback makes it possible to create multiple repetitions of the input signal. this is an important difference compared to the feed-forward echo, which only creates a single repetition on the delay line. with feedback, each time a repetition is created, it gets sent back through the delay to create another repetition. this process repeats over and over again. in theory, this can create an infinite number… Read more # Stereo Echo the stereo echo is an extension of other basic effects like the feed-forward echo and feed-back echo. the stereo version of these echo effects has different delay times for the left and right channels. this creates the perceptual impression the echo repetitions are happening at different places across the stereo field. 买球有没有长期盈利的to create the stereo echo, at least two delay blocks are required. the effect can also be much more complicated, similar to the multi-tap echo where each delay is panned to a unique position. A special type of stereo echo is the ping-pong echo. This effect has a specific repeated pattern… Read more # Impulse Response many audio effects with delay can be measured using a process called an impulse response (ir). for this measurement, the output of an audio effect is recorded for an impulse input signal. here is a using a digital audio workstation (daw) application. 买球有没有长期盈利的this input signal has an amplitude of zero for all samples except for the first sample, which has an amplitude of 1. therefore, an ir is a measurement of what happens to a single sample when it goes through the system by itself. 买球有没有长期盈利的an intuitive way to understand an ir is to consider its use with echo effects. these types of systems will delay the impulse to a different sample at a later point in time. an effect with more than one delayed repetition (i.e. feed-back echo or multi-tap echo) will have more than one delay impulse appearing in the ir. furthermore, a system’s ir is also used to represent, describe, and model… Read more # Feed-Forward Echo 买球有没有长期盈利的the feed-forward echo is a delay effect, which creates one repetition of the input signal. the delay time is typically within a range of 50 ms to 350+ ms. the result is a single, audible echo. 买球有没有长期盈利的although audio engineers usually think about delay in time units of seconds (or milliseconds), our computer creates delay based on units of samples. as programmers, we can give instructions to the computer to put the value of one sample at a different sample location. this process will create a time delay, and it is accomplished if we are clever about how we… Read more # Distortion Analysis there are many types of distortion effects used in audio. each type of distortion produces different results when processing signals. there are a couple different ways to analyze the differences between the distortion effects. one way is to visualize the output amplitude versus the input amplitude of the effect. in this case, a plot of the processing i/o characteristics is used. another way is to compare the harmonics created by processing a sine wave with the effect. this can be done using a spectrum analyzer to display the amplitude of the different frequencies in the distorted… Read more # Bit Reduction for digital signals, amplitude resolution (number of possible amplitude levels) is based on the number of bits used per sample. a bit is a place in memory for binary numbers (base 2) which can either be a 1 or a 0, just as a digit is a place which can hold a value from 0-9 for base-10 numbers. Bit Reduction is a type of distortion effect where the number of possible amplitude values of a signal is reduced. When used as an audio effect, bit reduction can also be called bit crushing… Read more # Hard Clipping hard-clipping is a type of distortion effect where the amplitude of a signal is limited to a maximum amplitude. this effect can be created in the analog or hardware world when a transistor is pushed to a maximum amplitude. at this amplitude, the transistor saturates and cannot output a signal above a specific level, so the input signal is clipped. this type of distortion effect can also be created using software. this is accomplished by detecting when the amplitude of a signal goes above a specified threshold. if the amplitude of the signal goes above the threshold, then the amplitude is assigned a new value (resulting in clipping). audio signals have… Read more # Half-wave Rectification rectification is a type of distortion effect where the negative amplitude values of a signal are distorted in different ways. for half-wave rectification, all negative amplitude values are changed to zero. This type of distortion is related to, but different from, full-wave rectification. 买球有没有长期盈利的one method to create half-wave rectification in our computer code is to use a conditional statement. here, we set up one condition for when the signal is greater than zero and a different condition for when the signal is less than or equal to zero. when the signal is positive, the output signal should equal the input signal. when the signal is negative, the output signal should equal zero regardless… Read more # Distortion Effects There are many audio effects created by multiplying and/or adding a scalar (single number) to each sample of a signal. Examples include: linear gain change, DC offset, polarity inversion, amplitude normalization, digital summing, amplitude fades, amplitude modulation, and stereo panning. Effects based on this type of processing are categorized as linear effects. The other category of effects is called non-linear effects. Non-linear processing is based on any method other than scalar multiplication and addition. Distortion audio effects process signals using a non-linear function. There are many audio effects that belong to the distortion category including: overdrive, fuzz, bit crushers, and aural exciters. Additionally, many audio technologies process signals in a non-linear manner such as guitar tube amplifiers, saturated analog tape, and transformers in an audio console. Distortion effects can also be created digitally… Read more # Logicals Another data type used in computer programs is the logical. This data type is used in commands associated with computer logic; in other words, when our computer evaluates something to be true or false. Therefore, the logical data type has only two possible values : 1 (true) and 0 (false). These values are used to represent the result of boolean expressions, comparing different variables, numbers, and strings in a program. 买球有没有长期盈利的logical operations perform a comparison to determine… Read more # Mid-side Decoding The second step of mid-side processing is decoding. This involves the process of turning the encoded “mid” and “sides” signals back into a conventional two-channel, left-right stereo signal. 买球有没有长期盈利的typically when using ms processing, some other additional type of processing (equalization, compression, etc.) is applied separately to either the “mid” or “sides” signals. then, it is the processed versions of the signals which get decoded. 买球有没有长期盈利的the following equations can be used… Read more # Auto Pan the auto-pan effect performs an automatic, repeating pattern with a virtual panning potentiometer. this creates the perception of a sound moving from side to side across the stereo field. typically, a low-frequency oscillator (lfo) signal is used to change the pan value. specifically the amplitude of the lfo at a given sample sets the pan value. different types of lfos will create different repeating patterns. common examples include a sine wave, triangle wave, and square wave. because the panning potentiometer is fundamentally an amplitude control, the auto-pan effect processes a signal by increasing the amplitude in one stereo channel and decreasing the amplitude in the other channel. as the effect continues, the lfo will… Read more # Sine-Law Panning A third type of panning function is Sine-Law Panning. As the name suggests, this type of panning is based on the sine function. Similar to linear and square-law panning, an amplitude value for the left channel and right channel of a stereo signal can be calculated based on the sine-law panning functions. Then a mono signal can be converted to a stereo signal by multiplying by the amplitude value… Read more # Square-Law Panning In addition to the linear panning functions, there are other mathematical functions to calculate the amplitude of each stereo channel based on the position of a panning potentiometer. Let’s now consider the Square-Law panning functions. The motivation for using the Square-Law functions is based on the perceived strength of the signal across different panning positions. By using the square-law functions, equal combined power between the channels is achieved. Whereas, the linear panning functions achieve equal combined amplitude. In many ways, listeners perceive the strength of the signal based on the power, rather than the amplitude. 买球有没有长期盈利的In other words, listeners will perceive the same signal strength regardless of panning position… Read more # Stereo Audio 买球有没有长期盈利的the two-channel stereo format is the most common format for audio signals. this format is used for most recorded music. additionally, most live-sound systems are set up to play back stereo sound. 买球有没有长期盈利的a stereo signal is comprised of two separate mono signals: one signal for a “left” speaker and one signal for a “right” speaker. 买球有没有长期盈利的the typical listener uses two ears when listening to music. whether the listener uses a pair of headphones or a pair of loudspeakers, a stereo signal provides the capability of presenting different signals to each of the listener’s ears. 买球有没有长期盈利的the benefit of stereo… Read more # Multiple Plots in many situations, it can be desirable to plot and compare several different functions at the same time. there are a few different options available in matlab to accomplish this task. Multiple plots can be displayed in their own separate figure windows by using the command: figure; between each instance the plot function is called. More explicitly, the commands figure(1), figure(2), figure(3), etc. can be used to assign a particular use of the plot function to a particular figure window. Multiple plots can be displayed in a single figure window by using several methods. First, simply adding additional input variables in the plot function will display multiple lines on the same axes. As an example… Read more # Line Specification The resulting visualization from the built-in plot function can be customized in several ways. One way is by setting the look of the actual line being drawn. Customizing this part of the plot is called changing the Line Specification. there are a few attributes of the line that can be set including the line color, style, and thickness. the following table describes many of the options available for setting the line color and style. The line thickness can be set by using the input parameter Line Width and then specifying… Read more # Amplitude Modulation when two signals are multiplied together, the amplitude of one signal modulates the amplitude of the other signal. in audio, it is common to use a low-frequency oscillator (lfo) as the modulator. the other input signal is commonly called the carrier signals. the amplitude of the lfo periodically increases and decreases the amplitude of the carrier signal. the frequency of the lfo has an important impact on the process. usually the frequency is selected to be less than 20 hz. another way to change the lfo is to modify… Read more # Multiplying Signals 买球有没有长期盈利的another way to combine signals together is by using element-wise multiplication. this can be used to create amplitude fades and also amplitude modulation for the tremolo effect. In Matlab, it necessary to use a period before the multiplication operator to specify the point-wise (or element-wise) multiplication. This is written: $y = x .* w$. For the signals, $x = \{ {x}_{1},{x}_{2},\hdots,{x}_{n} \}$ and $w = \{ {w}_{1},{w}_{2},\hdots,{w}_{n} \}$, the element-wise multiplication… Read more # Adding Signals 买球有没有长期盈利的digital signals can be “mixed” or “blended” by using digital summing. this process involves adding two or more signals together using element-wise indexing. 买球有没有长期盈利的the first sample of one signal is added to the first sample of another signal. the result represents the first sample of the output signal. this process is repeated for the second sample, and all subsequent samples in the signal. 买球有没有长期盈利的the end result is a single signal comprised of both original signals. this process is similar to the task an analog mixing console… Read more # RMS Normalization Another way to normalize the amplitude of a signal is based on the RMS amplitude. In this case, we will multiply a scaling factor, $a$, by the sample values in our signal to change the amplitude such that the result has the desired RMS level, $R$. if we know what the desired rms level should be, it is possible to figure out the scaling factor to perform a linear gain change. this is done by rearranging the equation used to calculate the rms level… Read more # Peak Normalization Normalizing the amplitude of a signal is to change the amplitude to meet a particular criterion. One type of normalization is to change the amplitude such that the signal’s peak magnitude equals a specified level. By convention in Matlab, the amplitude of an audio signal can span a range between -1 and +1. Therefore, the maximum magnitude (difference from 0) a signal can take is 1. This maximum value can be used as a reference level – called full scale (FS). As the reference level, it will have the decibel value: $0 \mbox{ } dBFS = 20 \cdot {log}_{10}(\frac{1}{1})$ A signal’s peak magnitude can be normalized to the value of 1 FS (0 dBFS). This process will scale the amplitude of all samples in a signal such that the peak magnitude has a value of 1. An expression to create a normalized output signal, out, by scaling the input signal, in买球有没有长期盈利的, is shown below: $out = \frac{1}{max(abs(in))} \cdot in$ The amplitude could also be normalized to any level relative to 0 dBFS. 买球有没有长期盈利的As an example… Read more # Decibel (dB) Scale 买球有没有长期盈利的one of the most common controls audio engineers use is the channel fader. it is used to increase or decrease the amplitude of a signal. the relative amount the amplitude is changed, and the units of the fader, are based on the decibel (db) scale. Previously, we looked at changing the amplitude of a signal based on a linear scale买球有没有长期盈利的. From a signal processing standpoint, we will program our computer to change the amplitude of a signal by multiplying by a scaler number. When writing software for an audio engineer to use, it is necessary to know how to interpret a change in amplitude based on the dB scale. Therefore, it is necessary to work with the relationship between the linear scale and the dB scale. An amplitude on the decibel scale, ${a}_{dB}$, can be determined from an amplitude on the linear scale, ${a}_{lin}$, using the relationship: ${a}_{dB} = 20 \cdot {log}_{10} (\frac{{a}_{lin}}{1})$. In reverse, the decibel scale can be converted to the linear scale using the relationship: ${a}_{lin} = {10}^{\frac{{a}_{dB}}{20}}$. A general rule of thumb audio engineers should know is, “doubling a signals amplitude is a $\sim6$ dB increase. Whereas, halving a signal’s amplitude… Read more # Polarity Inversion one common and basic way a signal can be processed is to invert the polarity. almost all audio mixing consoles have a button on individual channels to invert the polarity of the input signal. many software plug-ins which perform different kinds of processing, have a button to also invert the signal’s polarity. polarity inversion is a special case of the linear gain gain. in this case, the amplitude of the signal is multiplied by -1. therefore, the positive values become negative and the negative values become positive. Read more # Amplitude 买球有没有长期盈利的one of the most common ways an audio signal can be processed is by changing its amplitude. 买球有没有长期盈利的amplitude conceptually represents the strength of a signal. it is the force sound exerts on an environment. it is the level of sound pressure. 买球有没有长期盈利的a signal’s amplitude is related to whether it is perceived as being loud or quiet. therefore, this is an obvious characteristic of a signal to want to process. 买球有没有长期盈利的you have likely had an experience using some sort of volume knob or volume slider. in essence, this control allows you to change… Read more # Control Structures 买球有没有长期盈利的control structures are statements in a computer program which alter the order of executed commands. up to this point, we have written scripts where our computer starts on line 1 to execute commands from left to right, then moves to line 2, then line 3, and so on, in a sequential order. however, this doesn’t always have to be the case. As a programmer, there are several reasons why it would be helpful to be able to control and change this order of execution. First, if we want our computer to perform the same task many times, then we should be able to tell it to repeat certain commands. This concept in programming is called a loop. Second, if we want our computer to perform a task under certain conditions, then we should be able to tell it to test and respond to criteria. This concept in programming is called a conditional statement. Third, if we want to organize and construct a single piece of code to perform a specific task… Read more # Documentation matlab includes extensive documentation resources about the programming language and the built-in functions. this resource can be a very helpful reference while you are programming. the matlab documentation is available within the development environment under the ‘help’ tab of the menu bar. additionally, this same resource is available online from the matlab website. by accessing the documentation, it is unnecessary for a programmer to memorize the syntax for every function. rather, an experienced programmer is familiar with quickly searching and understanding the available resources to determine how to write their code. Read more # m-file 买球有没有长期盈利的a matlab m-file is a script of commands to be executed together. this is the method to write and group commands which work with each other to create a computer program. 买球有没有长期盈利的this file is saved to your computer’s hard drive, and can be loaded again in the future to perform the same commands. the file has an extension – “.m”, to indicate it is a matlab script. 买球有没有长期盈利的when an m-file is opened, it is located in the matlab editor tab. the script can be executed by pressing the “run” (green arrow) button, or by typing the name of the script in the command window. as a programmer, it is important to understand the order in which commands are executed in a script. generally, the order of execution is from top-to-bottom and left-to-right. the matlab m-file is an essential concept to learn and will be the primary way we will be working as we explore… Read more # Matlab Environment 买球有没有长期盈利的now that we have looked at the basics of working with audio in the matlab programming language, let’s explore more about the software development environment we are using for programming. 买球有没有长期盈利的learning a couple more things about matlab will make it possible to do more fun things with audio. 买球有没有长期盈利的up to this point, i have been demonstrating individual commands that can be executed in our programming language. 买球有没有长期盈利的however, computer programs are typically created by combining many commands together. in matlab, multiple commands can be grouped in a script… Read more # Sawtooth Wave 买球有没有长期盈利的a sawtooth wave is a signal with amplitude that increases like a ramp in each cycle. additionally, there are modified versions of the sawtooth wave in which the amplitude decreases like a ramp for part of a cycle. 买球有没有长期盈利的there is a function in matlab for synthesizing a sawtooth wave. the basic syntax for using the function is the following:$latex [y] = sawtooth(2\cdot\pi\cdot f \cdot t,width)$input variables: f – frequency of the signal (scalar in Hz) t – 买球有没有长期盈利的an array of time samples for a signal. width – for the width of each cycle when the amplitude is increasing like a ramp. This is a scalar value from [0,1]. 买球有没有长期盈利的output variables: y – 买球有没有长期盈利的an array containing a sawtooth-wave signal. 买球有没有长期盈利的further documentation… Read more # Sine Wave The sine function买球有没有长期盈利的 can be used to create a signal with a single frequency called a sine wave. This signal is commonly used in audio as a test signal to analyze various processing effects. there is a function in matlab for synthesizing a sine wave. the basic syntax for using the function is the following: 买球有没有长期盈利的$latex [y] = sin(2\cdot\pi\cdot f \cdot t)$买球有没有长期盈利的input variables: f买球有没有长期盈利的 – frequency of the signal (scalar in Hz) t – an array of time samples for a signal. 买球有没有长期盈利的output variables: y – 买球有没有长期盈利的an array containing a sine-wave signal. 买球有没有长期盈利的further documentation… Read more # Periodic Signals Many of the sounds we hear are periodic. When these sounds occur, vibrations repeat the same motion over and over again. One repetition of the vibration is called a cycle. Each cycle occurs over a consistent length of time called a period. Conceptually, a period is the time it takes for a signal to complete one cycle. To represent a signal’s period, we will use the greek letter tau买球有没有长期盈利的,$latex \tau$.$latex \tau = \frac{time}{1 cycle}$a related concept to period is a signal’s frequency, which is the number of cycles per second. therefore, frequency is the inverse of period. to represent a signal’s frequency, we will use the letter,$latex f$. the unit of frequency is called hertz$latex (hz)$.$latex f = \frac{cycles}{1 second}  Hz = \frac{1}{\tau}$Read more # Consolidate Signals 买球有没有长期盈利的two or more signals can be daisy-chained together, one after the other, by using the process of consolidating signals. the concept is to place the samples of multiple signals in sequential order. this process could also include adding extra silence before or after a signal. Signals can be consolidated together by using array concatenation. This process is the digital method of recreating what audio engineers could do with analog tape to adhere two separate pieces of tape together. One famous (and audible) example of editing tape together is on the song, Good Vibrations 买球有没有长期盈利的by the Beach Boys. During the recording of the song, the verse and chorus were performed separately. Afterwards, the engineer put the two parts together by physically adhering the two tapes. If you listen closely, you can hear the splice between each section. Read more # AudioInfo Information about a digital audio file can be recovered by using a built-in function: audioinfo. the basic syntax for using the function is the following:$latex info = audioinfo(filename)$input variable: filename – a string containing the name of the file. Example: ‘testSignal.wav’ output variables: info – 买球有没有长期盈利的a structure containing the following pieces of information about the file. info.Filename – a string of the sound file’s name. info.CompressionMethod – a string describing the method of data compression. info.NumChannels 买球有没有长期盈利的– a scalar describing whether the file is mono (1) or stereo (2). info.TotalSamples – a scalar representing the number of samples per channel. info.Duration 买球有没有长期盈利的– a scalar representing the length of the file in seconds. info.BitsPerSample 买球有没有长期盈利的– a scalar representing the bit depth of the file. further documentation for the function is available . Read more # Sound The samples of an audio signal stored in an array can be played back over your computer’s speakers using the built-in function: sound. 买球有没有长期盈利的the basic syntax for using the function is the following:$latex sound(y,Fs)\$

input variables:

y – an array containing the samples of the signal.

further documentation for the function is available .

# Signal Waveform

a signal’s waveform is a plot of its amplitude over time. this type of visualization is very common, used in almost every digital audio workstation (daw).

in some situations, it is helpful to visualize the time units of samples. in other situations, the time units of seconds is preferred. in either case, the waveform looks identical except the scale of the horizontal axis is changed.

To control the scale of the horizontal axis, the following syntax can be used for the built-in function: $plot(x,y)$

x – an array defining the time value of each sample of the signal (equal in length to the signal)

y – the array containing the signal’s sample values

# Digital Signals

Audio signals can be converted to digital information through a measurement process called sampling.

one common, and useful, digital representation of an audio signal records the amplitude at regular intervals of time. this representation is called pulse code modulation (pcm). here are a few links to find out more about pcm: , .

The number of amplitude measurements, or samples, per second is called the sampling rate. For audio, common sampling rates include…

# Amplitude

you have likely had an experience using some sort of volume knob or volume slider. in essence, this control allows you to change the amplitude of a signal.

# Signal Synthesis

in audio, it is common to work with signals that were originally created by acoustic vibrations and captured by a microphone.

In other cases, it can be helpful to work with signals that were created as digital information. Any time a signal is created directly as digital information (or also as electricity), that signal can be described as a synthesized signal. In other words, synthesis is the process of creating a signal.

the nice thing about working with synthesized signals is…

# Audio Basics

After understanding the basics of how a computer works with general information, it is possible to focus more specifically on audio information.

Even when working with audio, it can be helpful to keep in mind that computers process many types of information at a simple level. I mention this because I hope you do not feel intimidated about now taking the next step to working with audio. Audio is only slightly more complicated, but it is nothing you can’t handle if you are comfortable with numbers, strings, and arrays.

as you will see, digital audio signals are nothing more than numbers. it just so happens that there are a lot of things that we can do with audio when it is represented by numbers.

in this section, we will look at…

# Digital Signal Processing

there are many different processing techniques that have been developed for digital signals. some of these techniques accomplish similar tasks as analog circuits. some techniques accomplish tasks that would be very difficult to implement with analog circuits.

# Indexing Arrays

the individual elements in arrays are organized in a rectangular configuration. each element is placed into a particular row and column.

An individual element of an array can be referenced, or indexed, by specifying the row and column number.

a group of elements can be indexed by specifying all of their row and column numbers. there are several methods to do this, using a similar syntax for…

# Numbers

this is important and helpful when working with an audio signal, which is nothing more than a sequence of numbers.

the matlab programming language treats numerical information differently than other types of information. it is necessary for a programmer to understand this, and anticipate how a computer deals with numbers.

When a single number is assigned to a variable, it is called a scalar. Eventually we will also…

# Math Functions

Instead, the programming language has a built-in function which can be used to perform a square root. Rather than a symbol, the syntax requires a function name and a function input.

For instance, sqrt(9) is the command which can be used to perform the square root operation on the number 9. In this case, the function name is: sqrt. The function input is: 9.

besides square root, there are many other common functions built in…

# Matlab Environment

learning a couple more things about matlab will make it possible to do more fun things with audio.

# Error Statements

Every programming language has a set of rules, referred to as syntax, which must be follow for our computer to understand the instructions we create. Syntax is the proper method of putting together the letters, numbers, and symbols of a programming language to form meaningful statements or commands.

If we attempt to execute a command Matlab cannot interpret, then an error statement is created and displayed in the command window.

this statement is displayed in a red color and provides information about the problem with our command.

# Basic Computing

at a fundamental level, many of these complicated tasks are based on basic math: addition, subtraction, multiplication, and division.

the same is true for using a computer with audio. basic math can be used to accomplish many of the ways audio signals…

# Matlab

matlab is a desktop software application and programming language created by .

i believe it is a great platform to learn computer programming, especially if you are also interested in processing audio signals.

after learning the basics of programming in matlab, it is intuitive to learn other languages that can be used for other specific purposes.

furthermore, matlab is widely used. many companies in the audio industry use matlab internally. it is the ‘standard’ for proof-of-concept signal processing algorithm design. matlab is also taught in many engineering schools. therefore, if you want to learn computer programming with audio…

# Introduction

computers are at the center of almost everything related to audio these days. digital audio workstations (daw) are commonly used for recording music. more and more aspects of live performance are incorporating computers. audio effects plug-ins and virtual instruments are examples of computer software that can be used to process and synthesize sound. apps for mobile devices increase the portability, accessibility, and convenience of music making.

there is similarity across all of these examples – computers were intentionally programmed…