Why .wav file is not saved for some Sample Rate values?

The following code is used for exporting a sound ( .wav format), and is part of a whole program created for generating sounds at any frequency and timbre,
the issue is that the code EXPORTS pretty FINE when the variable: samplerat <=6000,
however,
no matter the AudioEncoding used, it never save the .wav file when the variable: samplerat > 6000, and mathematica give neither any warning nor error message, at all, it is just that it does not save the file, that’s it.

I am stucked on this and cannot find the reason.
Let me remark this again: “No matter the AudioEncoding used”, no doubts about it,
Real64, Real32, Integer 32, etc., whatever.

(I increased the virtual ram memory on my computer but it does not help.)
The size of the .wav audio files when using samplerat= 6000 is just about 36KB, which
is frankly extremely short (because they are just the sound of a guitar string at any frequency)

Follows the code for the exporting the .wav file:


soundtoexport = 
 Sound[Play[soundnotef, {t, 0, soundtime}, Compiled -> True, 
   PlayRange -> All, SampleRate -> samplerat], SoundVolume -> 1],


soundfilename = 
 Export[StringJoin["c:/0/", "Sound",  ".wav"], soundtoexport, 
  AudioEncoding -> "Integer16", SampleRate -> samplerat]

Many thanks in advance for any help or tip on this matter,
Best regards
Domingo

I forgot to mention, that using samplerate=8000 the sound (soundtoexport ) is succesfully produced, however the line


soundfilename = Export[StringJoin[“c:/0/”, “Sound”, “.wav”], soundtoexport, AudioEncoding → “Integer16”, SampleRate → samplerat]


does not work anymore¡.
and if I use samplerate = 6000 then it is succesfully produced and saved.

In short I will say use a rate it “likes” do not try to “buck the system”.

Are you using Win10 or Apple Mojave?

Try this. Check help on Export and .wav type. It should describe options. The options say what features the export (binary or function) supports for the given platform.

I have not checked data rates but I know .wav is a Microsoft format that is a “stolen .au” (Sun audio) and may also have limited playback rates. You may have to check standards on Win10 .wav and assume Mathematica must follow the same limitations. Import/Export functions in Mathematica are not fully documented - the documentation would be too long.

Hi John,
Many thanks for your so kind comments,
I had read through the wolfram reference and relating rates it only says:
“Not all codecs support arbitrary sample rates and channel specifications.”
That’s it.
Anyway, thanks and best regards.