現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
File audio flac error
1 回表示 (過去 30 日間)
古いコメントを表示
Ferz14
2016 年 1 月 22 日
How to create file audio in flac format? I have used audiowrite but it hasn't worked. The error is described as "Warning: Data clipped when writing file. > In audiowrite>clipInputData (line 396) In audiowrite (line 176) " Can you solve this problem please? Thank you!
2 件のコメント
Geoff Hayes
2016 年 1 月 22 日
Ferz14 - you are observing a warning and not an error or is there a problem with the audio file?
See Walter's answer at http://www.mathworks.com/matlabcentral/answers/257223-audiowrite-clipping-warning-issue for an explanation of the warning.
Ferz14
2016 年 1 月 22 日
Thank you! I need to create a sine wave with amplitude=5 but I can't do it. I've tried in wav format but in this way amplitude values are clipped to the range –1.0 <= y < +1.0. Could you explain me how to do?
回答 (1 件)
Walter Roberson
2016 年 1 月 23 日
You could write out an audio file with amplitude 5, but it would have to be integer 5, representing 5/255 of maximum amplitude (uint8) or 5/32767 of maximum amplitude (int16) or 5/(2^31-1) of maximum amplitude (int32)
If you are writing a floating point value, then the value always represents fraction of the maximum; if you were able to represent a value 5 times the maximum then the clearly the maximum would be high enough to encompass that 5 times value, so by way of contradiction the value cannot exceed 1.0 in floating point.
24 件のコメント
Ferz14
2016 年 1 月 23 日
編集済み: Walter Roberson
2016 年 1 月 23 日
Thank you! But I don't understand where I'm wrong.
This is my code :
amp=5;
fs=4800;
duration=10;
freq=5000;
values=0:1/fs:duration;
a=amp*sin(2*pi*freq*values);
Could you explain me where I'm wrong please?
Walter Roberson
2016 年 1 月 23 日
編集済み: Walter Roberson
2016 年 1 月 23 日
In .wav files as .flac files, an amplitude of 1.0 means "move the speaker cone as out as it can go", and an amplitude of -1.0 means "move the speaker cone as far in as it will go." An amplitude of 5.0 would then have to mean "move the speaker cone five times further out than it can go".
Audio files do not hold information about absolute magnitudes such as "5 volts peak to peak" or "5 mm" or "5 decibels": they hold relative magnitudes, relative to 1.0 being "maximum".
What is wrong with your code is your expectation that audio files store absolute information.
If you want to store absolute information instead of relative information, then you need to use a different kind of file, such as using save(), or xlswrite(), or using fopen()/fwrite()/fclose() to create a binary file.
Ferz14
2016 年 1 月 23 日
But I need to create a file audio that I send to my DAQ board. So I can only create a file audio with amplitude=1, can't I? Thank you!
Walter Roberson
2016 年 1 月 23 日
DAQ boards seldom receive audio files. DAQ boards usually receive data samples without going through the step of creating an audio file. If you do not go through an audio file then you can send up to the maximum value your DAQ channel supports. Typically that would be a 16 bit integer or a 32 bit integer or a 32 bit single precision number, but it varies with how the channel is configured.
But, Yes, if your DAQ is one of the few that does need an audio file, then the maximum value you can send is equivalent to 1.0 . Whether the file will actually represent it as single precision or not is going to depend on the exact parameters you pass to wavwrite() or audiowrite(). And then on the other side of your DAQ, you would set up your amplifier so that the 1.0 came out as 5 of whatever units you are looking for.
I have never encountered a DAQ that needed an audio file. The closest I have encountered is that on early SGI workstations, the sound subsystem took μLaw encoded samples -- which was a per-sample format, not a file.
Ferz14
2016 年 1 月 23 日
Thanks for your help!! The sine wave was a test but I must send a digital trigger with amplitude=5. One last question, how I can set up my amplifier so that the 1.0 come out as 5? Thank you so much!!
Walter Roberson
2016 年 1 月 23 日
Digital triggers are not audio files! You just create the samples the way you did already, and send them out on a channel that is configured to expect single precision or double precision.
However, generally speaking it is only analog channels that expect floating point, with digital channels expecting bits
The situation is a bit different if you are using Instrument Control toolbox to talk to an instrument, rather than talking to a DAQ board.
Ferz14
2016 年 1 月 23 日
I wrote the program in c to sample an analog input with a digital trigger. So, I create a binary file then I send it out on a channel that I configured in my code. Or I use addDigitalChannel. Is it right? Thank you and sorry for my numerous questions.
Walter Roberson
2016 年 1 月 24 日
Is the intention that the DAQ board will convert to analog, such as for playing out a speaker? If so then you will want to add an analog output
Ferz14
2016 年 1 月 25 日
I have a file audio that I send to my DAQ board. I need a digital trigger so I have in output 125000 samples of my analog input. How can do it? I have the program in c where I configured analog/digital channel. The program works but I don't know how to create digital trigger and how to send trigger to my DAQ board. Thank you so much!
Walter Roberson
2016 年 1 月 25 日
We need to know how many bits wide the digital trigger is, and what the encoding format is for what is being sent to it.
Please note that "trigger" is usually used for the case where a particular value is used to initiate or terminate an action, such as to trigger a motor to start or stop. A digital trigger is usually only a single bit wide. If you are sending values that will be interpreted as data, such as brightness level or amplitude for a speaker, then that would be referred to as a "sample" rather than a "trigger".
What kind of DAQ are you using? And what will the DAQ do with the data you send it?
Ferz14
2016 年 1 月 25 日
I'm using NI USB-6210. The DAQ start to sample the input at the rising edge of trigger.
Walter Roberson
2016 年 1 月 25 日
Is the point to tell the DAQ to sample 125000 inputs?? If so then the "file audio" would have nothing to do with that, especially not for a digital trigger. Now if you had a DAQ which is triggered by the rising edge of an analog signal and your amp*sin(2*pi*freq*values) is all about constructing that analog signal, that would be more understandable... but I suspect unnecessary.
Ferz14
2016 年 1 月 25 日
I send to my DAQ an analog input. The DAQ start to sample the input at the rising edge of digital trigger. But I don't know how to create the digital trigger and how to send trigger to my DAQ. Sorry but I'm very confused.
Walter Roberson
2016 年 1 月 25 日
The NI USB-6210 is directly supported by the Data Acquisition Toolbox, which will take care of the details of reading samples if you configure it with addAnalogInputChannel()
Ferz14
2016 年 1 月 25 日
So I create a session, and use the addAnalogInputChannel and addDigitalOutputChannel. Then I can acquire multiple scans with another command. It's right?
Walter Roberson
2016 年 1 月 25 日
You do not need the addDigitalOutputChannel for this, I am pretty sure. Let the DAQ Toolbox take care of whatever triggering it needs when you acquire data;
Ferz14
2016 年 1 月 25 日
But my work is create a rectangular pulse and send it to my DAQ. Do you know how can do it? Otherwise I use addAnalogInputChannel and addTriggerCOndition. It's right? Thank you
Walter Roberson
2016 年 1 月 25 日
I really doubt that you need to send a pulse to your DAQ. If that were the case, then the DAQ would have to be somewhere remote from you, and you would need a second DAQ to generate the pulse to send to the DAQ you are referring to.
If it is your NI USB-6210 that is connected directly to your computer, and you want to do analog to digital conversion at the NI USB-6210, then the startForeground / startBackground will communicate over the USB to tell the DAQ to do the sampling.
Communication over the USB is always digital, a packet of data; you cannot send a pulse through the USB port. Exactly what needs to be transferred to the NI USB-6210 to tell it to start collecting data is irrelevant: what-ever the protocol is, the DAQ will hide it from you.
The computer (running MATLAB) sends commands to the DAQ; the DAQ responds by configuring itself or by starting to record and transfer data to be transferred digitally over the USB to the computer.
addTriggerCondition has to do with something fairly different: it is for the situation where you do not always want to be recording input data, and instead want the recording to start only when a particular external condition is met, such as a voltage exceeding a certain value.
Ferz14
2016 年 1 月 25 日
So I create a session and use addAnalogInputChannel and then I use startBackground to start the operation. But, in this way, no sampling begins at the rising edge of the digital trigger. Where is the digital trigger? I don't understand.
Walter Roberson
2016 年 1 月 25 日
What part of the documentation for that device leads you to understand that you need to have the computer generate a pulse before the device will digitize?
Ferz14
2016 年 1 月 25 日
I don't understand how the DAQ observe the digital trigger. How I send the trigger?
Walter Roberson
2016 年 1 月 25 日
Why do you think you need a trigger? What document are you looking at?
Ferz14
2016 年 1 月 25 日
Because my work is to sample an analog input at the rising edge of the digital trigger. I send a file audio (a sine wave) and my DAQ samples the signal when receives the trigger. What am I doing wrong? Thanks.
参考
カテゴリ
Help Center および File Exchange で Audio I/O and Waveform Generation についてさらに検索
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)