이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
File audio flac error
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)