Yes. Unless you change the BitsPerSample, then audiowrite() of double precision data assumes that the data is in the range -1 to +1 and scales it by 32768 to create int16 internally, which is what gets written to the file.
The problem you are having is that you scaled by 32768 already, but you left it as class double, so audiowrite is going to scale it again, not knowing that you already scaled it.
Another approach is that you could just audiowrite new_y directly: that would automatically rescale the double to int16 to write to the file.
To clarify: for double precision writing to wav file, the data is automatically converted to int16, which is the most common internal representation for .wav files. This is handled transparently.
When you audioread() then by default it reads in the int16 and converts it to double precision for the user -- so users do not normally notice the internal representation of .wav since they asked to write double precision and when they read it back they get double precision.
If you want to see the actual integer values stored in the .wav file, you have to add the 'native' option to audioread()
yes, that should work, as it would trigger saving in double precision. However, the code
yInt = new_y * 32768;
strongly implies that you are converting to unsigned 16 bit integer.
When you read in the file with audioread(), it is likely (but not certain) that the "information content" is only 16 bits per sample. You do a computation to arrive at a scalar and divide all of the samples by that same scalar: the "information content" of each scalar would continue to be 16 bits. But you are writing out the results as 64 bits -- it is a waste of space.
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Translated by
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.