pcm

Android中播放DSD音乐

♀尐吖头ヾ 提交于 2020-01-14 04:49:27
Github上有个简单的Alsa DSD测试程序,可以播放DSD,地址位于:https://github.com/zonque/alsa-dsd-player 细看其代码,发现有ALSA_FORMAT_SND_PCM_FORMAT_DSD_U8的定义,详情如下: #if 1 /* 8-bit DSD */ #define ALSA_FORMAT SND_PCM_FORMAT_DSD_U8 #define SAMPLE_SIZE (sizeof(uint8_t) * 2) #define SAMPLE_RATE_DIV 1 #else /* 16-bit DSD */ #define ALSA_FORMAT SND_PCM_FORMAT_DSD_U16 #define SAMPLE_SIZE (sizeof(uint16_t) * 2) #define SAMPLE_RATE_DIV 2 #endif 那么在Android中能运行这个测试程序吗?ALSA_FORMAT_SND_PCM_FORMAT_DSD_U8似乎是亮点,之前没有看到过。尝试在Android的源码中寻找它的定义,没找到。但是在标准的alsa-lib中找到了: typedef enum _snd_pcm_format { 125 SND_PCM_FORMAT_UNKNOWN = -1, 127 SND_PCM

How to play non-PCM file or convert it to PCM on the fly ?

Deadly 提交于 2020-01-11 09:32:24
问题 The following code works with some wav files, but with others I get, "InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files." var webClient = new WebClient(); webClient.DownloadFile(url, fileName); var fileSound = new SoundPlayer(fileName); fileSound.PlaySync(); Is there a way to programmatically check if a wav file is "bad" (not a PCM wave file) and then convert it as necessary? What is odd is that the code works in the legacy Delphi app - all of the

How to play non-PCM file or convert it to PCM on the fly ?

早过忘川 提交于 2020-01-11 09:32:14
问题 The following code works with some wav files, but with others I get, "InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files." var webClient = new WebClient(); webClient.DownloadFile(url, fileName); var fileSound = new SoundPlayer(fileName); fileSound.PlaySync(); Is there a way to programmatically check if a wav file is "bad" (not a PCM wave file) and then convert it as necessary? What is odd is that the code works in the legacy Delphi app - all of the

Unity处理MP3流播放

拟墨画扇 提交于 2020-01-10 08:19:46
Unity处理MP3流播放 PCMReaderCallback回调 Unity音频数据是通过AudioClip去处理的,它提供了PCMReaderCallback回调,用于加载流音频数据。它的声明如下: public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream, AudioClip.PCMReaderCallback pcmreadercallback); public delegate void PCMReaderCallback(float[] data); PCMReaderCallback中的PCM指的是音频数据格式,下面会讲到。在stream模式下,lengthSamples表示播放时,每次循环处理的sample数,这会影响到回调参数data的大小。回调函数参数data就是需要填充的音频数据,它的格式是PCM,data的长度可以由lengthSamples * channels计算出来。 值得注意的是,PCMReaderCallback执行环境不一定,它是由Unity回调的,可能是主线程,也可能是子线程。所以当它卡住的时候,可能会卡掉整个应用。 PCM格式 PCM是Pulse Code Modulation的缩写

audio volume normalization [closed]

痞子三分冷 提交于 2020-01-09 11:26:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am writing a music player and I want to normalize the audio volume across different songs. I could think of some different ways to do this, e.g.: Go through all PCM samples (assume floating point from -1 to 1) and select the m = max(abs(sample)). Then apply the factor 1/m to all the PCM samples. This would

多媒体文件格式(五):PCM / WAV 格式

こ雲淡風輕ζ 提交于 2020-01-06 21:30:00
一、名词解析 PCM(Pulse Code Modulation)也被称为脉码编码调制,PCM中的声音数据没有被压缩,它是由模拟信号经过采样、量化、编码转换成的标准的数字音频数据。采样转换方式参考下图进行了解: 音频采样包含以下几大要素: 1. 采样率 采样率表示音频信号每秒的数字快照数。该速率决定了音频文件的频率范围。采样率越高,数字波形的形状越接近原始模拟波形。低采样率会限制可录制的频率范围,这可导致录音表现原始声音的效果不佳。根据奈奎斯特采样定理,为了重现给定频率,采样率必须至少是该频率的两倍。例如,一般CD唱片的采样率为每秒 44,100 个采样,因此可重现最高为 22,050 Hz 的频率,此频率刚好超过人类的听力极限 20,000 Hz。 图中A是低采样率的音频信号,其效果已经将原始声波进行了扭曲,B则是完全重现原始声波的高采样率的音频信号。 数字音频常用的采样率如下: 2. 位深度 位深度决定动态范围。采样声波时,为每个采样指定最接近原始声波振幅的振幅值。较高的位深度可提供更多可能的振幅值,产生更大的动态范围、更低的噪声基准和更高的保真度。 位深度越高,提供的动态范围越大。 二、PCM 在上面的名词解析中我们应该对PCM有了一定的理解和认识,下面我们将对PCM做更多的讲解。 1. PCM音频数据存储方式 如果是单声道的文件,采样数据按时间的先后顺序依次存入

Compress WAV PCM to Microsoft GSM 6.10 Audio Codec using C#

和自甴很熟 提交于 2020-01-06 04:32:47
问题 Does any one know how to convert a uncompressed wave file in PCM format to a wav file compressed in GSM 6.10 Audio Codec? 回答1: Try How to convert to Gsm Wav file static void ToWavWithGsm() { string fileName = @"e:\Down\male.wav"; WaveReader wr = new WaveReader(File.OpenRead(fileName)); IntPtr format = wr.ReadFormat(); IntPtr formatGsm = AudioCompressionManager.GetCompatibleFormat(format, AudioCompressionManager.Gsm610FormatTag); byte[] dataGsm = AudioCompressionManager.ToFormat(wr, formatGsm)

lame,把ios录音转换为mp3格式

房东的猫 提交于 2020-01-04 21:29:09
在ios设备中进行录音,录音文件的格式为caf。但这种格式在很多设备中没法播放。为了适应终端的播放功能,特将caf转换为mp3格式文件来使用。 在录制caf文件时,需要使用双通道,否则在转换为MP3格式时,声音不对。caf录制端的设置为: NSMutableDictionary * recordSetting = [ NSMutableDictionary dictionary ]; [recordSetting setValue :[ NSNumber numberWithInt : kAudioFormatLinearPCM ] forKey : AVFormatIDKey ]; // [recordSetting setValue :[ NSNumber numberWithFloat : 8000.0 ] forKey : AVSampleRateKey ];//采样率 [recordSetting setValue :[ NSNumber numberWithInt : 2 ] forKey : AVNumberOfChannelsKey ];//声音通道, 这里必须为双通道 [recordSetting setValue :[ NSNumber numberWithInt : AVAudioQualityLow ] forKey :

How can I get frequency data from PCM using FFT

纵饮孤独 提交于 2020-01-01 03:11:38
问题 I have an array of audio data I am passing to a reader: recorder.read(audioData,0,bufferSize); The instantiation is as follows: AudioRecord recorder; short[] audioData; int bufferSize; int samplerate = 8000; //get the buffer size to use with this audio record bufferSize = AudioRecord.getMinBufferSize(samplerate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT)*3; //instantiate the AudioRecorder recorder = new AudioRecord(AudioSource.MIC,samplerate, AudioFormat.CHANNEL

JLayer Mono Mp3 to PCM decoding

折月煮酒 提交于 2019-12-30 12:23:48
问题 I am currently working on mp3 decoding with javalayer 1.1. So I want to receive the raw PCM data from my 44100 Hz, 16bit, Mp3s. It is perfectly working fine with stereo mp3s, but i have strange issues with mono mp3s. Here some code. InputStream data = c.getResources().openRawResource(resId); Bitstream bitstream = new Bitstream(data); Decoder decoder = new Decoder(); while(thereIsData) { Head frameHeader = bitstream.readFrame(); SampleBuffer buffer = (SampleBuffer) decoder.decodeFrame