In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use Octave to read and write audio files in linux, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Octave is a software similar to Matlab on Linux. It has a large number of functions and commands to support sound acquisition, recording, playback and digital processing of audio signals. It is used in entertainment applications, research, medicine and other scientific fields. In this tutorial, we will use version 4.0.0 of Octave to read audio files on Ubuntu, and then simulate the use of audio signals in various situations by generating signals and playing them.
Environmental preparation
First install octave, run the following command on the Ubuntu terminal to add Octave PPA, and then install Octave.
Sudo apt-add-repository ppa:octave/stable sudo apt-get update sudo apt-get install octave
Step 1: open Octave
In this step, we click the software icon to open Octave, and we can select the work path by clicking the drop-down button.
Step 2: audio information
Use the audioinfo command to view information about the audio file you want to process.
> > info = audioinfo ('testing.ogg')
Step 3: read the audio file
In this tutorial, I will use the ogg file to read the properties of this file, such as sampling, audio type (stereo and mono), number of channels, and so on. It is important to declare that all commands used in the tutorial are executed in the Octave terminal window. First, we have to assign the ogg file to a variable. Note: the file must be in the working path of Octave.
> > file='yourfile.ogg' > > [M, fs] = audioread (file)
Where M is an one-column or two-column matrix, depending on the number of channels, fs is the sampling rate.
You can read the audio file by doing the following:
> [y, fs] = audioread (filename, samples) > > [y, fs] = audioread (filename, datatype) > > [y, fs] = audioread (filename, samples, datatype)
Samples specifies the start and end frames, and datatype specifies the type of data to be returned. You can set values for all variables:
> > samples = [1, fs) > > [y, fs] = audioread (filename, samples)
Data type:
> > [YJEONFs] = audioread (filename,'native')
If the value is "native", its data type depends on how the data is stored in the audio file.
Step 4: write operation of audio file
Create a new ogg file:
We will create an ogg file from a cosine. The sampling rate is 44100 times per second, and this file is sampled for at least 10 seconds. The frequency of the cosine signal is 440 Hz.
> > filename='cosine.ogg'; > > fs=44100; > > tacti0VlGULTHANG FSPLO10; > > wimp2The pirates 440ft; > > signal=cos (w); > > audiowrite (filename, signal, fs)
This creates a 'cosine.ogg' file in the work path, which contains cosine signals.
Playing the 'cosine.ogg' file' will produce a 440Hz tone, which happens to be the'A 'tone in music theory. If you need to see the values saved in the file, you must use the 'audioread' function to read the file. In subsequent tutorials, we will see how to read an audio file in two channels.
Step 5: play the audio file
Octave has a default audio player that you can test with. Use the following function:
> > [yjingfs] = audioread ('yourfile.ogg'); > player=audioplayer (yjingfs, 8) scalar structure containing the fields: BitsPerSample = 8 CurrentSample = 0 DeviceID =-1 NumberOfChannels = 1 Running = off SampleRate = 44100 TotalSamples = 236473 Tag = Type = audioplayer UserData = [] (0x0) > play (player) Thank you for reading this article carefully. I hope the article "how to use Octave to read and write audio files in linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.