GithubHelp home page GithubHelp logo

elehobica / pico_spdif_recorder Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 1.92 MB

S/PDIF WAV recorder on microSD card for Raspberry Pi Pico

License: BSD 2-Clause "Simplified" License

C++ 14.52% CMake 0.57% C 84.91%
microsd raspberry-pi-pico rp2040 spdif wav-recorder raspberry-pi-pico-w

pico_spdif_recorder's Introduction

Raspberry Pi Pico spdif_recorder

PCB Front

Overview

  • Hi-Res recorder from S/PDIF input to WAV files on microSD card
  • Bit resolution: 16bit or 24bit (2ch)
  • Sampling frequency: 44.1 KHz, 48.0 KHz, 88.2 KHz, 96.0 KHz (, 176.4 KHz, 192 KHz)
  • Recording only, no monitoring or playback functions

Supported Board and Peripheral Devices

  • Raspberry Pi Pico or Raspberry Pi Pico W (rp2040)
  • S/PDIF Coaxial or TOSLINK Rx module (DLR1160 or equivalent)
  • microSD cards (recommend SD-XC, V30 cards)

Pin Assignment & Connection

Circuit Diagram

S/PDIF Rx

Pico Pin # GPIO Function Connection
20 GP15 DATA from S/PDIF data

Note:

  • For Coaxial input or switchable inputs between Coaxial and TOSLINK, refer to pico_spdif_rx

microSD card

Pico Pin # Pin Name Function microSD Pin Name microSD Pin #
4 GP2 SPI0_SCK CLK 5
5 GP3 SPI0_TX CMD 3
6 GP4 SPI0_RX DAT0 7
7 GP5 SPI0_CSn CD/DAT3 2
8 GND GND VSS 6
36 3V3(OUT) 3.3V VDD 4

Note:

  • As for the wire length between Pico and SD card, short wiring as possible is desired, otherwise errors such as Mount error and Write fail will occur.

Button/Switch (Optional)

Pico Pin # GPIO Function Connection
9 GP6 Input 16bit/24bit switch
10 GP7 Input Start/Stop button

How to build

  • See "Getting started with Raspberry Pi Pico"
  • Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
  • Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH and PICO_EXAMPLES_PATH
  • Confirmed with Pico SDK 2.0.0
> git clone -b 2.0.0 https://github.com/raspberrypi/pico-sdk.git
> cd pico-sdk
> git submodule update -i
> cd ..
> git clone -b sdk-2.0.0 https://github.com/raspberrypi/pico-examples.git
>
> git clone -b sdk-2.0.0 https://github.com/raspberrypi/pico-extras.git
> 
> git clone -b main https://github.com/elehobica/pico_spdif_recorder.git
> cd pico_spdif_recorder
> git submodule update -i
> cd ..

Windows

  • Build is confirmed in Developer Command Prompt for VS 2022 and Visual Studio Code on Windows environment
  • Confirmed with cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
  • Lanuch "Developer Command Prompt for VS 2022"
> cd pico_spdif_recorder
> mkdir build && cd build
> cmake -G "NMake Makefiles" ..
> nmake

Linux

$ cd pico_spdif_recorder
$ mkdir build && cd build
$ cmake ..
$ make -j4

Upload

  • Put "pico_spdif_recorder.uf2" on RPI-RP2 drive

Serial command interface

  • Serial interface is available from USB port of Raspberry Pi Pico.
Key Function
Space Recording Start Standby / Recording Stop
r Resolution change 16bit/24bit (default: 16bit)
s Manual split
b Auto blank split on/off (default: on)
v Verbose for monitoring messages
c Clear WAV file suffix to 1
w Configure Wi-Fi (for Raspberry Pi Pico W only)
h Help

Recording start/stop/split features

  • Standby recording start while silence and auto start when sound detected
  • Auto stop and standby restart when long blank detected
  • Auto split of WAV file when short blank detected
  • Manual immediate split of WAV file without gap

LED indicator

  • Slow blink: Recording is on-going.
  • Fast blink: Background file proceses to close previous file and prepare next file are on-going. During this term, no command requests can be accepted.
  • Repeated Slow blink and Fast blink: indicating errors (see log on serial console.)

microSD card

Card recommendation for Hi-Res recording

  • Due to the limitation of single bit SPI interface driven by Raspberry Pi Pico, even with highest class microSD cards (as of 2024), recording in 24bit 176.4 KHz or 192.0 KHz is challenging. It will sometimes causes the drops of audio sampling data. The bandwidth status can be monitored in Verbose mode.
  • The most severe situation for bandwidth is to start suceeeding track recording when previous long-time track more than 20 minutes has to be closed.
  • With following recommended microSD cards, recording in 24bit 96.0 KHz will be stable as far as experimentally confirmed.
  • Format micorSD card in exFAT with official SD Card Formatter before usage.
# Vendor Product Name Part Number Comment
1 Samsung PRO Plus 256GB MB-MD256SA 24bit/192KHz is worth trying for non-long-time tracks. 24bit/96KHz is stable.
2 SanDisk Extreme PRO 256GB SDSQXCD-256G-GN6MA 24bit/192KHz is too challenging. 24bit/96KHz is stable.

File timestamp

  • File timestamp is synchronized to NTP if using Raspberry Pi Pico W and connected to Wi-Fi.
  • Otherwise, timestamp starts from 0:00 a.m. Jan. 1st, 2024 (UTC+0).
  • exFAT format (thus, > 64GB SD-XC cards) is recommended to reflect timezone.
  • In case of FAT32 format, timestamp cannot reflect timezone, therefore, it's always shown as UTC+0 time.

Card trouble shooting

  • In case of card mount error or fundamental access errors, please confirm with FatFs test

pico_spdif_recorder's People

Contributors

elehobica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kaidokert

pico_spdif_recorder's Issues

Provide schematic for coaxial connection

The circuit picture shows the pin assignments and connections for a DLR1160 optical RX module, but there is no such thing for a coaxial (RCA female) connector.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.