Add files via upload
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Vincent Rozenberg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,67 @@
|
||||
# WAV Recording Time Calculator WordPress Plugin
|
||||
|
||||
A WordPress plugin that provides a calculator for determining WAV recording time based on storage capacity and audio settings. This tool helps audio professionals and enthusiasts calculate recording duration for their WAV files based on various technical parameters.
|
||||
|
||||
## Features
|
||||
|
||||
- Calculate recording time based on:
|
||||
- SD Card/Storage size (GB)
|
||||
- Sample rate (48 kHz, 96 kHz, 192 kHz)
|
||||
- Bit depth (16-bit, 24-bit, 32-bit)
|
||||
- Unlimited number of tracks
|
||||
- Real-time calculations
|
||||
- Displays:
|
||||
- Total recording time
|
||||
- Data rate (Kbps and Mbps)
|
||||
- Storage required per hour
|
||||
- Responsive design with dark mode support
|
||||
- Clean, professional interface
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download the plugin files
|
||||
2. Upload the plugin folder to the `/wp-content/plugins/` directory
|
||||
3. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
|
||||
## Usage
|
||||
|
||||
Add the calculator to any post or page using the shortcode:
|
||||
|
||||
```
|
||||
[wav_calculator]
|
||||
```
|
||||
|
||||
## Technical Details
|
||||
|
||||
The calculator takes into account:
|
||||
- Storage capacity in gigabytes (GB)
|
||||
- Sample rates: 48 kHz, 96 kHz, 192 kHz
|
||||
- Bit depths: 16-bit, 24-bit, 32-bit
|
||||
- Multi-track support with no upper limit
|
||||
|
||||
Calculations are performed using the following formula:
|
||||
- Total bytes = Card size in GB * 1,000,000,000
|
||||
- Bytes per second = (Sample rate * 1000) * (Bit depth / 8) * Number of tracks
|
||||
- Total seconds = Total bytes / Bytes per second
|
||||
|
||||
The calculator provides real-time updates and includes data rate calculations in both Kbps and Mbps, as well as storage requirements per hour of recording.
|
||||
|
||||
## Requirements
|
||||
|
||||
- WordPress 5.0 or higher
|
||||
- PHP 7.0 or higher
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
|
||||
## Author
|
||||
|
||||
Created by Vincent Rozenberg
|
||||
- Website: [vincentrozenberg.com](https://vincentrozenberg.com)
|
||||
|
||||
## Notes
|
||||
|
||||
- Storage cards typically have slightly less usable space than their advertised capacity due to file system overhead
|
||||
- The calculator assumes uncompressed WAV format
|
||||
- Calculations are theoretical and may vary slightly in real-world usage
|
||||
@@ -0,0 +1,399 @@
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
}
|
||||
|
||||
.wav-calculator-container {
|
||||
background-color: #ffffff;
|
||||
padding: 24px;
|
||||
border-radius: 0px;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.wav-calculator-title {
|
||||
color: #000000;
|
||||
margin-bottom: 24px;
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
letter-spacing: -0.2px;
|
||||
}
|
||||
|
||||
.wav-calculator-input-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wav-calculator-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #000000;
|
||||
font-weight: 400;
|
||||
font-size: 13px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.wav-calculator-input {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-radius: 0px;
|
||||
font-size: 16px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-input:focus {
|
||||
outline: none;
|
||||
border-color: #000000;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.wav-calculator-results {
|
||||
margin-top: 24px;
|
||||
padding: 20px;
|
||||
background-color: #fafafa;
|
||||
border-radius: 0px;
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.wav-calculator-result-item {
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.wav-calculator-result-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.wav-calculator-result-item strong {
|
||||
color: #000000;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-button {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-button input[type="radio"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-button label {
|
||||
display: block;
|
||||
padding: 12px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-radius: 0px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-button input[type="radio"]:checked + label {
|
||||
background-color: #000000;
|
||||
color: white;
|
||||
border-color: #000000;
|
||||
}
|
||||
|
||||
.wav-calculator-select-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wav-calculator-select-button {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wav-calculator-select-button input[type="radio"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wav-calculator-select-button label {
|
||||
display: block;
|
||||
padding: 12px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-radius: 0px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.wav-calculator-select-button input[type="radio"]:checked + label {
|
||||
background-color: #000000;
|
||||
color: white;
|
||||
border-color: #000000;
|
||||
}
|
||||
|
||||
.wav-calculator-input-with-unit {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wav-calculator-input-with-unit input {
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
.wav-calculator-unit {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
color: #666666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wav-calculator-invalid {
|
||||
border-color: #999999;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.wav-calculator-invalid + .wav-calculator-unit {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.wav-calculator-invalid:focus {
|
||||
border-color: #999999;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-container {
|
||||
background-color: #111111;
|
||||
border-color: #333333;
|
||||
}
|
||||
|
||||
.wav-calculator-title, .wav-calculator-label {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-input {
|
||||
background-color: #111111;
|
||||
border-color: #333333;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-input:focus {
|
||||
border-color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-results {
|
||||
background-color: #1a1a1a;
|
||||
border-color: #333333;
|
||||
}
|
||||
|
||||
.wav-calculator-result-item {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
.wav-calculator-result-item strong {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-button label,
|
||||
.wav-calculator-select-button label {
|
||||
background-color: #111111;
|
||||
border-color: #333333;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-radio-button input[type="radio"]:checked + label,
|
||||
.wav-calculator-select-button input[type="radio"]:checked + label {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
border-color: #ffffff;
|
||||
}
|
||||
|
||||
.wav-calculator-unit {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.wav-calculator-invalid {
|
||||
border-color: #666666;
|
||||
background-color: #1a1a1a;
|
||||
}
|
||||
|
||||
.wav-calculator-invalid + .wav-calculator-unit {
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="wav-calculator-container">
|
||||
<h1 class="wav-calculator-title">WAV Recording Time Calculator</h1>
|
||||
|
||||
<div class="wav-calculator-input-group">
|
||||
<label class="wav-calculator-label">SD Card Size</label>
|
||||
<div class="wav-calculator-input-with-unit">
|
||||
<input type="number" id="wavCalculatorCardSize" class="wav-calculator-input" min="1" value="32" placeholder="Size in GB">
|
||||
<span class="wav-calculator-unit">GB</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="wav-calculator-label">Sample Rate</label>
|
||||
<div class="wav-calculator-radio-group">
|
||||
<div class="wav-calculator-radio-button">
|
||||
<input type="radio" id="wavCalculatorRate48" name="wavCalculatorSampleRate" value="48" checked>
|
||||
<label for="wavCalculatorRate48">48 kHz</label>
|
||||
</div>
|
||||
<div class="wav-calculator-radio-button">
|
||||
<input type="radio" id="wavCalculatorRate96" name="wavCalculatorSampleRate" value="96">
|
||||
<label for="wavCalculatorRate96">96 kHz</label>
|
||||
</div>
|
||||
<div class="wav-calculator-radio-button">
|
||||
<input type="radio" id="wavCalculatorRate192" name="wavCalculatorSampleRate" value="192">
|
||||
<label for="wavCalculatorRate192">192 kHz</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="wav-calculator-label">Bit Depth</label>
|
||||
<div class="wav-calculator-select-group">
|
||||
<div class="wav-calculator-select-button">
|
||||
<input type="radio" id="wavCalculatorBit16" name="wavCalculatorBitDepth" value="16">
|
||||
<label for="wavCalculatorBit16">16-bit</label>
|
||||
</div>
|
||||
<div class="wav-calculator-select-button">
|
||||
<input type="radio" id="wavCalculatorBit24" name="wavCalculatorBitDepth" value="24" checked>
|
||||
<label for="wavCalculatorBit24">24-bit</label>
|
||||
</div>
|
||||
<div class="wav-calculator-select-button">
|
||||
<input type="radio" id="wavCalculatorBit32" name="wavCalculatorBitDepth" value="32">
|
||||
<label for="wavCalculatorBit32">32-bit</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wav-calculator-input-group">
|
||||
<label class="wav-calculator-label">Number of Tracks</label>
|
||||
<input type="number" id="wavCalculatorTracks" class="wav-calculator-input" min="1" value="1">
|
||||
</div>
|
||||
|
||||
<div class="wav-calculator-results">
|
||||
<div class="wav-calculator-result-item">
|
||||
<span>Recording Time (<span id="wavCalculatorCardSizeDisplay">32</span> GB):</span>
|
||||
<strong id="wavCalculatorRecordingTime">--</strong>
|
||||
</div>
|
||||
<div class="wav-calculator-result-item">
|
||||
<span>Data Rate:</span>
|
||||
<strong id="wavCalculatorDataRate">--</strong>
|
||||
</div>
|
||||
<div class="wav-calculator-result-item">
|
||||
<span>Storage per Hour:</span>
|
||||
<strong id="wavCalculatorStorageRequired">--</strong>
|
||||
</div>
|
||||
<div class="wav-calculator-result-item">
|
||||
Note: Storage cards have slightly less usable space than their advertised capacity due to file system overhead. Plan accordingly when recording near maximum capacity.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
class WavCalculator {
|
||||
calculateRecordingTime(cardSizeGB, sampleRate, bitDepth, tracks = 1) {
|
||||
const totalBytes = cardSizeGB * 1000000000;
|
||||
const bytesPerSecond = (sampleRate * 1000) * (bitDepth / 8) * tracks;
|
||||
const totalSeconds = totalBytes / bytesPerSecond;
|
||||
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = Math.floor(totalSeconds % 60);
|
||||
|
||||
const dataRateKbps = (bytesPerSecond * 8) / 1000;
|
||||
const dataRateMbps = dataRateKbps / 1000;
|
||||
|
||||
const storagePerHour = (bytesPerSecond * 3600) / 1000000000;
|
||||
|
||||
return {
|
||||
hours,
|
||||
minutes,
|
||||
seconds,
|
||||
formattedTime: `${hours}h ${minutes}m ${seconds}s`,
|
||||
dataRateKbps: dataRateKbps.toFixed(1),
|
||||
dataRateMbps: dataRateMbps.toFixed(2),
|
||||
storagePerHour: storagePerHour.toFixed(2)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const wavCalculator = new WavCalculator();
|
||||
|
||||
function wavCalculatorUpdateCalculation() {
|
||||
const cardSize = parseFloat(document.getElementById('wavCalculatorCardSize').value);
|
||||
const sampleRate = parseInt(document.querySelector('input[name="wavCalculatorSampleRate"]:checked').value);
|
||||
const bitDepth = parseInt(document.querySelector('input[name="wavCalculatorBitDepth"]:checked').value);
|
||||
const tracks = parseInt(document.getElementById('wavCalculatorTracks').value);
|
||||
|
||||
const cardSizeInput = document.getElementById('wavCalculatorCardSize');
|
||||
const tracksInput = document.getElementById('wavCalculatorTracks');
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!cardSize || cardSize <= 0) {
|
||||
cardSizeInput.classList.add('wav-calculator-invalid');
|
||||
isValid = false;
|
||||
} else {
|
||||
cardSizeInput.classList.remove('wav-calculator-invalid');
|
||||
document.getElementById('wavCalculatorCardSizeDisplay').textContent = cardSize;
|
||||
}
|
||||
|
||||
if (!tracks || tracks < 1) {
|
||||
tracksInput.classList.add('wav-calculator-invalid');
|
||||
isValid = false;
|
||||
} else {
|
||||
tracksInput.classList.remove('wav-calculator-invalid');
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
document.getElementById('wavCalculatorRecordingTime').textContent = '--';
|
||||
document.getElementById('wavCalculatorDataRate').textContent = '--';
|
||||
document.getElementById('wavCalculatorStorageRequired').textContent = '--';
|
||||
return;
|
||||
}
|
||||
|
||||
const result = wavCalculator.calculateRecordingTime(cardSize, sampleRate, bitDepth, tracks);
|
||||
|
||||
document.getElementById('wavCalculatorRecordingTime').textContent = result.formattedTime;
|
||||
document.getElementById('wavCalculatorDataRate').textContent =
|
||||
`${result.dataRateKbps} Kbps (${result.dataRateMbps} Mbps)`;
|
||||
document.getElementById('wavCalculatorStorageRequired').textContent =
|
||||
`${result.storagePerHour} GB/hour`;
|
||||
}
|
||||
|
||||
document.getElementById('wavCalculatorCardSize').addEventListener('input', wavCalculatorUpdateCalculation);
|
||||
document.getElementById('wavCalculatorTracks').addEventListener('input', wavCalculatorUpdateCalculation);
|
||||
|
||||
document.querySelectorAll('input[name="wavCalculatorSampleRate"]').forEach(radio => {
|
||||
radio.addEventListener('change', wavCalculatorUpdateCalculation);
|
||||
});
|
||||
|
||||
document.querySelectorAll('input[name="wavCalculatorBitDepth"]').forEach(radio => {
|
||||
radio.addEventListener('change', wavCalculatorUpdateCalculation);
|
||||
});
|
||||
|
||||
wavCalculatorUpdateCalculation();
|
||||
</script>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Vincent's WAV Recording Time Calculator
|
||||
* Plugin URI: https://vincentrozenberg.com/
|
||||
* Description: A calculator for determining WAV recording time based on storage capacity and audio settings.
|
||||
* Version: 1.0.0
|
||||
* Author: Vincent Rozenberg
|
||||
* Author URI: https://vincentrozenberg.com
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
if (!defined('WPINC')) {
|
||||
die;
|
||||
}
|
||||
|
||||
function wav_calculator_shortcode() {
|
||||
// Get the path to the HTML file
|
||||
$file_path = plugin_dir_path(__FILE__) . 'wav-calculator-mono.php';
|
||||
|
||||
// Read the file content
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Return the file content
|
||||
return $content;
|
||||
}
|
||||
|
||||
add_shortcode('wav_calculator', 'wav_calculator_shortcode');
|
||||
Reference in New Issue
Block a user