# Problem outputing an audio file in 24 bit

**URL:** <https://forum.csound.com/t/problem-outputing-an-audio-file-in-24-bit/1608>\
**Category:** General\
**Created:** [April 5, 2024, 3:52pm UTC](https://forum.csound.com/t/problem-outputing-an-audio-file-in-24-bit/1608 "2024-04-05T15:52:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![felix](https://forum.csound.com/letter_avatar_proxy/v4/letter/f/aeb1de/32.png) [@felix](https://forum.csound.com/u/felix)\
**Post date:** [April 5, 2024, 3:52pm UTC](https://forum.csound.com/t/problem-outputing-an-audio-file-in-24-bit/1608/1 "2024-04-05T15:52:00Z")

</div>

Hi !

I’m encoutering a problem with writting an audio file to the disk.

I want to have a mono file encoded in 24bit to use it in CDP analysing it with PVOC Anal and then use it in a program like Spectwin. To achieve this the two analysis files need to have the same bit definition or I get an error message.

My first sound used is written with reaper and the second one comes from csound. But whatever I try in the command line its always encoded in 16bits. My csd is executed from CsoundQt but I get the same thing when I execute it from a terminal.

Here is the begining of my csd:

-B 256 -b 128

-3  
–output=C:\Users\felix\Desktop\PAUL\_ET\_MELI\SONS\_TO\_INTERLEAVE\BassSynth\_2.wav

sr = 44100  
ksmps = 64  
nchnls = 1  
0dbfs = 1

Hope it’s not too confuse. I know it sounds dumb but it’s been one hour I’m stuck with that and I can’t understand the problem.

Have a good day,

Félix

---

<div class="post-metadata">

**Author:** ![eduardomoguillansky](https://forum.csound.com/user_avatar/forum.csound.com/eduardomoguillansky/32/437_2.png) [@eduardomoguillansky](https://forum.csound.com/u/eduardomoguillansky)\
**Post date:** [April 5, 2024, 5:13pm UTC](https://forum.csound.com/t/problem-outputing-an-audio-file-in-24-bit/1608/2 "2024-04-05T17:13:39Z")

</div>

–format=24bit

Use “csound --help” from the terminal or check the manual: [http://www.csounds.com/manual/html/CommandFlags.html](http://www.csounds.com/manual/html/CommandFlags.html)

---

<div class="post-metadata">

**Author:** ![felix](https://forum.csound.com/letter_avatar_proxy/v4/letter/f/aeb1de/32.png) [@felix](https://forum.csound.com/u/felix)\
**Post date:** [April 5, 2024, 5:32pm UTC](https://forum.csound.com/t/problem-outputing-an-audio-file-in-24-bit/1608/3 "2024-04-05T17:32:25Z")

</div>

Thanks for your response,

I already tried the flags: --fromat=24bit or -3 with no results

Also, when I don’t write the file extension explicitly and want to specify it using the --format=type flag the file is still written with no header.

As if the flags for the output on the disk weren’t working for me…

---

<div class="post-metadata">

**Author:** ![ST\_Music](https://forum.csound.com/user_avatar/forum.csound.com/st_music/32/239_2.png) [@ST\_Music](https://forum.csound.com/u/ST_Music)\
**Post date:** [April 6, 2024, 7:20am UTC](https://forum.csound.com/t/problem-outputing-an-audio-file-in-24-bit/1608/4 "2024-04-06T07:20:26Z")

</div>

That is rather odd. The following works perfectly for me on Android, Windows & Mac:

` -o filename.wav --format=24bit`

or

` -o filename.wav --format=float`

for 32 bit float.

If you still can’t get that to work you could try fout and if needed the monitor opcode. Here’s an ex:

```csound
<CsoundSynthesizer>
<CsOptions>
-odac
; -o filename.wav --format=24bit
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr Play
  iFreq ftgen 1, 0, 0, 2, 220, 440, 880
  aSig = oscil:a(line:a(.4,p3,0),tab:k(lfo(randomh:k(0,2,4),4,3),1))
  outs(aSig, aSig)
endin

instr Monitor, Record
  aL, aR monitor
; iformat = type * 10 + sample format
; 14 = wav, 16 bit
; 18 = wav, 24 bit
; 16 = wav, 32 bit float
  iFormat = 18
  fout "/dir/filename.wav", iFormat, aL, aR
endin

</CsInstruments>
<CsScore>
i"Play" 0 16
i"Monitor" 0 16
</CsScore>
</CsoundSynthesizer>

```
