A python module to broadcast radio waves with your Raspberry Pi.
Project description
PiWave
PiWave is a Python module designed to manage and control your Raspberry Pi radio using the pi_fm_rds utility. It allows you to easily convert audio files to WAV format and broadcast them at a specified frequency with RDS (Radio Data System) support.
Features
- Converts audio files to WAV format.
- Broadcasts WAV files using the
pi_fm_rdsutility. - Configurable broadcast frequency, PS (Program Service), RT (Radio Text), and PI (Program Identifier).
- Supports looping of playback.
- Detailed logging for debug mode.
- Supports streaming from URLs.
- Better error handling and event callbacks.
- Non-blocking playback with threading.
Hardware Installation
To use PiWave for broadcasting, you need to set up the hardware correctly. This involves connecting an antenna or cable to the Raspberry Pi's GPIO pin.
-
Connect the Cable or Antenna:
- Attach a cable or an antenna to GPIO 4 (Pin 7) on the Raspberry Pi.
- Ensure the connection is secure to avoid any broadcasting issues.
-
GPIO Pinout:
- GPIO 4 (Pin 7) is used for the broadcasting signal.
- Ensure that the cable or antenna is properly connected to this pin for optimal performance.
Installation
[!WARNING] Warning: Using PiWave involves broadcasting signals which may be subject to local regulations and laws. It is your responsibility to ensure that your use of PiWave complies with all applicable legal requirements and regulations in your area. Unauthorized use of broadcasting equipment may result in legal consequences, including fines or penalties.
Liability: The author of PiWave is not responsible for any damage, loss, or legal issues that may arise from the use of this software. By using PiWave, you agree to accept all risks and liabilities associated with its operation and broadcasting capabilities.
Please exercise caution and ensure you have the proper permissions and knowledge of the regulations before using PiWave for broadcasting purposes.
Auto Installer
For a quick and easy installation, you can use the auto installer script. Open a terminal and run:
curl -sL https://setup.piwave.xyz/ | sudo bash
This command will download and execute the installation script, setting up PiWave and its dependencies automatically.
[!NOTE] To uninstall, use the following command:
curl -sL https://setup.piwave.xyz/uninstall | sudo bash
Manual Installation
To install PiWave manually, follow these steps:
-
Clone the repository and install:
pip install git+https://github.com/douxxtech/piwave.git --break-system-packages
-
Dependencies:
PiWave requires the
ffmpegandffprobeutilities for file conversion and duration extraction. Install them using:sudo apt-get install ffmpeg
-
PiFmRds:
PiWave uses PiFmRds to work. Make sure you have installed it before running PiWave.
Usage
Basic Usage
-
Importing the module:
from piwave import PiWave
-
Creating an instance:
piwave = PiWave( frequency=90.0, ps="MyRadio", rt="Playing great music", pi="ABCD", loop=True, debug=True, silent=False, on_track_change=lambda file, index: print(f"Now playing: {file}"), on_error=lambda error: print(f"Error occurred: {error}") )
-
Adding files to the playlist:
files = ["path/to/your/audiofile.mp3", "http://example.com/stream.mp3"] piwave.add_files(files)
-
Starting playback:
piwave.play() # or files = ["path/to/your/audiofile.mp3", "http://example.com/stream.mp3"]; piwave.play(files)
-
Stopping playback:
piwave.stop()
-
Pausing and resuming playback:
piwave.pause() piwave.resume()
-
Skipping tracks:
piwave.next_track() piwave.previous_track()
-
Changing frequency:
piwave.set_frequency(95.0)
-
Getting status:
status = piwave.get_status() print(status)
Configuration
frequency: The broadcast frequency in MHz (default: 90.0).ps: Program Service name (up to 8 characters, default: "PiWave").rt: Radio Text (up to 64 characters, default: "PiWave: The best python module for managing your pi radio").pi: Program Identifier (up to 4 characters, default: "FFFF").loop: Whether to loop playback of files (default: False).debug: Enable detailed debug logging (default: False).silent: Disables every log output (default: False).on_track_change: Callback function when the track changes (default: None).on_error: Callback function when an error occurs (default: None).
Error Handling
- Raspberry Pi Check: The program verifies if it is running on a Raspberry Pi. It exits with an error message if not.
- Root User Check: The program requires root privileges to run. It exits with an error message if not run as root.
- Executable Check: The program automatically finds the
pi_fm_rdsexecutable or prompts the user to manually provide its path if it cannot be found.
License
PiWave is licensed under the GNU General Public License (GPL) v3.0. See the LICENSE file for more details.
Contributing
Contributions are welcome! Please submit a pull request or open an issue on GitHub for any bugs or feature requests.
Thank you for using PiWave!
Made with <3 by Douxx
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file piwave-2.0.7.tar.gz.
File metadata
- Download URL: piwave-2.0.7.tar.gz
- Upload date:
- Size: 25.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566f6d20412c43ad2eabf73a01880c70a752a4cc278388633325c34be2303e9f
|
|
| MD5 |
68dc746b03d74d0b7f8d945adef4f5df
|
|
| BLAKE2b-256 |
dcfe56a0fbf4026c160f57cbef330b80fc8883e658f2a4f26f310cb883f65687
|
Provenance
The following attestation bundles were made for piwave-2.0.7.tar.gz:
Publisher:
python-publish.yml on douxxtech/piwave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piwave-2.0.7.tar.gz -
Subject digest:
566f6d20412c43ad2eabf73a01880c70a752a4cc278388633325c34be2303e9f - Sigstore transparency entry: 417162439
- Sigstore integration time:
-
Permalink:
douxxtech/piwave@74dcf7f8b11e02d698070c5fd54fa4c6ed2a9b78 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/douxxtech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@74dcf7f8b11e02d698070c5fd54fa4c6ed2a9b78 -
Trigger Event:
push
-
Statement type:
File details
Details for the file piwave-2.0.7-py3-none-any.whl.
File metadata
- Download URL: piwave-2.0.7-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5346854f98a1ded9c70f5ffaf6157d83ab6720efc5414410540574f8caf6ed4
|
|
| MD5 |
d86c46f62484b426d7b8052a35e4aa69
|
|
| BLAKE2b-256 |
27dd8134221f2d9448c565a761a93da6203781af4ed3d10b6bdf580dfe03dce8
|
Provenance
The following attestation bundles were made for piwave-2.0.7-py3-none-any.whl:
Publisher:
python-publish.yml on douxxtech/piwave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piwave-2.0.7-py3-none-any.whl -
Subject digest:
a5346854f98a1ded9c70f5ffaf6157d83ab6720efc5414410540574f8caf6ed4 - Sigstore transparency entry: 417162477
- Sigstore integration time:
-
Permalink:
douxxtech/piwave@74dcf7f8b11e02d698070c5fd54fa4c6ed2a9b78 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/douxxtech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@74dcf7f8b11e02d698070c5fd54fa4c6ed2a9b78 -
Trigger Event:
push
-
Statement type: