# Send wav file using udp node

**URL:** <https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030>\
**Category:** General\
**Created:** [16 September 2024 19:30 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030 "2024-09-16T19:30:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [16 September 2024 19:30 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/1 "2024-09-16T19:30:21Z")

</div>

Hello everyone!  
So I have a wav file that I want to send via udp. How can it be? Thank you very much for the answers! I'm trying this, but it doesn't work:

```auto
[{"id":"6e4886616b135e02","type":"inject","z":"f41a27cc00143f05","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":330,"y":780,"wires":[["436ceb41482997b2"]]},{"id":"436ceb41482997b2","type":"file in","z":"f41a27cc00143f05","name":"","filename":"/home/xy/UDP_I2S/xy.wav","filenameType":"str","format":"stream","chunk":false,"allProps":false,"x":520,"y":780,"wires":[["65b5debe20a1b53c"]]},{"id":"da9165b28ec524b9","type":"inject","z":"f41a27cc00143f05","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"str","x":1010,"y":840,"wires":[["65b5debe20a1b53c"]]},{"id":"65b5debe20a1b53c","type":"sox-record","z":"f41a27cc00143f05","name":"","buttonStart":"msg","inputs":1,"inputSource":"fromInput","manualSource":"","inputEncoding":"signed-integer","inputChannels":"2","inputRate":"44100","inputBits":16,"byteOrder":"-L","encoding":"signed-integer","channels":"2","rate":"44100","bits":16,"gain":"0","buffer":"1024","showDuration":false,"durationType":"forever","durationLength":"0","silenceDetection":"nothing","silenceDuration":"2.0","silenceThreshold":"2.0","outputFormat":"stream","manualPath":"1","debugOutput":false,"x":1190,"y":780,"wires":[["a5b74c1f7531d507"],[]]},{"id":"a5b74c1f7531d507","type":"udp out","z":"f41a27cc00143f05","name":"","addr":"192.168.28.151","iface":"","port":"40000","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":1460,"y":780,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [16 September 2024 19:48 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/2 "2024-09-16T19:48:34Z")

</div>

not sure what the sox node is used for here - but you should be able to just wire the output for the file node to the udp node.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 September 2024 19:49 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/3 "2024-09-16T19:49:33Z")

</div>

Unless this is a streaming format - you don't!

UDP has no guarantee of packet order, so you will likely get corrupted files + UDP has a max packet length, and your routing equipment, can decide to drop packets also.

Use TCP for this kind of transfer, unless you are streaming the WAV (in which case you will need to transcode I think)

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [16 September 2024 19:57 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/4 "2024-09-16T19:57:58Z")

</div>

An INMP441 microphone is connected to an ESP32 PoE, I send it via UDP, a python code receives it and then saves it as a wav file. I want to send this wav file from node red via udp

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 September 2024 20:07 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/5 "2024-09-16T20:07:32Z")

</div>

As mentioned by @dceejay

Just wire the `read file` node output to the `udp out` node - but again, because UDP is stateless, and has no `ACK` you may need to devise your own checksum routines to ensure the file is in intact at the other end - if its critical to your application.

You could UDP the checksum, and check it at the other end after the transfer.

Whilst.... unlikely (sorry I know i'm back tracking) - it's absolutely possible for packet loss or the order of packets to become out of sync when using UDP

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [16 September 2024 20:10 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/6 "2024-09-16T20:10:41Z")

</div>

udp : Error: send EMSGSIZE 192.168.5.151:40000

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 September 2024 20:13 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/7 "2024-09-16T20:13:04Z")

</div>

You need to cut the buffer into pieces (more so with UDP), and send them in chunks

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [16 September 2024 20:19 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/8 "2024-09-16T20:19:11Z")

</div>

Well, I'm still not enough for that 😔

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 September 2024 20:22 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/9 "2024-09-16T20:22:41Z")

</div>

> [@azxo1](#):
>
> I send it via UDP, a python code receives it and then saves it as a wav file

The reason ☝ works...

Is because (well at least I am guessing) the python code is receiving a "stream" of small bytes from the mic signal - and not a **massive** file blob.

Sorry, I would help further, but I'm done for the day - hopefully others can chip in

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 December 2024 20:29 UTC](https://discourse.nodered.org/t/send-wav-file-using-udp-node/91030/11 "2024-12-15T20:29:02Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
