Fixed a few compiler warnings
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
AudioModel::AudioModel(QObject *parent) : QObject(parent)
|
AudioModel::AudioModel(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_impl_data = { nullptr, nullptr, 0, 1, {}, {}};
|
m_impl_data = { nullptr, nullptr, {0, 0, {}}, 1, {}, {}, 0.0};
|
||||||
m_impl_data.samples.reserve(4096);
|
m_impl_data.samples.reserve(4096);
|
||||||
m_impl_data.smoothed.reserve(2048);
|
m_impl_data.smoothed.reserve(2048);
|
||||||
|
|
||||||
@@ -212,11 +212,11 @@ void AudioModel::on_process(void *userdata)
|
|||||||
n_samples = buf->datas[0].chunk->size / sizeof(float);
|
n_samples = buf->datas[0].chunk->size / sizeof(float);
|
||||||
|
|
||||||
// convert channels to mono
|
// convert channels to mono
|
||||||
for(int index = 0; index < n_samples; index += n_channels)
|
for(uint32_t index = 0; index < n_samples; index += n_channels)
|
||||||
{
|
{
|
||||||
float average = 0;
|
float average = 0;
|
||||||
|
|
||||||
for(int channel = 0; channel < n_channels; channel++)
|
for(uint32_t channel = 0; channel < n_channels; channel++)
|
||||||
average += samples[index + channel];
|
average += samples[index + channel];
|
||||||
|
|
||||||
average /= n_channels;
|
average /= n_channels;
|
||||||
|
|||||||
@@ -2,50 +2,109 @@
|
|||||||
# it contains modifications from Neil Panda and myself
|
# it contains modifications from Neil Panda and myself
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shutil
|
||||||
# If they fail to convert, try only converting for 120,150 or 150 instead of 100 es
|
import argparse
|
||||||
# otherwise, debug the shader it self
|
|
||||||
|
|
||||||
# Paths
|
|
||||||
source_directory = 'processed'
|
|
||||||
output_directory = 'build'
|
|
||||||
|
|
||||||
# Ensure output directory exists
|
|
||||||
os.makedirs(output_directory, exist_ok=True)
|
|
||||||
|
|
||||||
# THIS WILL DELETE YOUR ORIGINAL FRAG AFTER COMPILING IF SET TO TRUE
|
# THIS WILL DELETE YOUR ORIGINAL FRAG AFTER COMPILING IF SET TO TRUE
|
||||||
DELETE_AFTER_COMPILATION = False
|
DELETE_AFTER_COMPILATION = False
|
||||||
|
|
||||||
# Iterate over all .frag files in the source directory
|
def parse_arguments():
|
||||||
for root, dirs, files in os.walk(source_directory):
|
parser = argparse.ArgumentParser(
|
||||||
for file in files:
|
description='A shader processor for ShaderToy',
|
||||||
if file.endswith('.frag'):
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
# Construct the full path to the source file
|
epilog="""
|
||||||
source_file_path = os.path.join(root, file)
|
Examples:
|
||||||
|
python ShaderToyProcessor.py -i ./src/deadly_halftones
|
||||||
# Construct new output path
|
"""
|
||||||
relative_path = os.path.relpath(root, source_directory)
|
)
|
||||||
new_root = os.path.join(output_directory, relative_path)
|
|
||||||
os.makedirs(new_root, exist_ok=True)
|
parser.add_argument('-i', '--input',
|
||||||
|
default='processed',
|
||||||
output_file_name = file.replace('.frag', '.frag.qsb')
|
help='Input directory to process')
|
||||||
output_file_path = os.path.join(new_root, output_file_name)
|
|
||||||
|
parser.add_argument('-v', '--verbose',
|
||||||
|
action='store_true',
|
||||||
|
help='Enable verbose output')
|
||||||
|
|
||||||
|
parser.add_argument('-o', '--output',
|
||||||
|
default='build',
|
||||||
|
help='Output Directory')
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
# Construct and execute the command
|
def main():
|
||||||
cmd = [
|
args = parse_arguments()
|
||||||
'/usr/lib/qt6/bin/qsb', '--glsl', '330', '--hlsl', '50', '--msl', '12',
|
|
||||||
'-o', output_file_path, source_file_path
|
if args.output:
|
||||||
]
|
output_directory = args.output
|
||||||
|
|
||||||
try:
|
if args.input:
|
||||||
subprocess.run(cmd, check=True)
|
source_directory = args.input
|
||||||
# If the command was successful, delete the source file
|
|
||||||
if (DELETE_AFTER_COMPILATION):
|
if args.verbose:
|
||||||
os.remove(source_file_path)
|
print(f"Input directory: {source_directory}")
|
||||||
print(f"Successfully converted and deleted: {file}")
|
print(f"Output directory: {output_directory}")
|
||||||
|
|
||||||
|
last_file = ""
|
||||||
|
|
||||||
|
# Ensure output directory exists
|
||||||
|
os.makedirs(output_directory, exist_ok=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Iterate over all .frag files in the source directory
|
||||||
|
for root, dirs, files in os.walk(source_directory):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith('.frag'):
|
||||||
|
last_file = file
|
||||||
|
|
||||||
|
# Construct the full path to the source file
|
||||||
|
source_file_path = os.path.join(root, file)
|
||||||
|
|
||||||
|
# Construct new output path
|
||||||
|
relative_path = os.path.relpath(root, source_directory)
|
||||||
|
new_root = os.path.join(output_directory, relative_path)
|
||||||
|
os.makedirs(new_root, exist_ok=True)
|
||||||
|
|
||||||
|
output_file_name = file.replace('.frag', '.frag.qsb')
|
||||||
|
output_file_path = os.path.join(new_root, output_file_name)
|
||||||
|
|
||||||
|
# Construct and execute the command
|
||||||
|
cmd = [
|
||||||
|
'/usr/lib/qt6/bin/qsb', '--glsl', '330', '--hlsl', '50', '--msl', '12',
|
||||||
|
'-o', output_file_path, source_file_path
|
||||||
|
]
|
||||||
|
|
||||||
|
subprocess.run(cmd, check=True)
|
||||||
|
# If the command was successful, delete the source file
|
||||||
|
if (DELETE_AFTER_COMPILATION):
|
||||||
|
os.remove(source_file_path)
|
||||||
|
if args.verbose:
|
||||||
|
print(f"Successfully converted and deleted: {file}")
|
||||||
|
elif args.verbose:
|
||||||
|
print(f"Successfully converted: {file}")
|
||||||
|
|
||||||
|
# Otherwise, just copy the file
|
||||||
else:
|
else:
|
||||||
print(f"Successfully converted: {file}")
|
file_path = os.path.join(root, file)
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
# If the command failed, do not delete the source file
|
# Construct new output path
|
||||||
print(f"Conversion failed for: {file}")
|
relative_path = os.path.relpath(root, source_directory)
|
||||||
|
new_root = os.path.join(output_directory, relative_path)
|
||||||
|
os.makedirs(new_root, exist_ok=True)
|
||||||
|
new_file_path = os.path.join(new_root, file)
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
print(f"Writing to: '{new_file_path}'")
|
||||||
|
|
||||||
|
shutil.copy(file_path, new_file_path)
|
||||||
|
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
# If the command failed, do not delete the source file
|
||||||
|
print(f"Conversion failed for: {last_file}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user