使用Rust写如下程序,用到主要crate有realfft、hound。
读入音频/home/bczhc/Music/2.wav,其总采样点数为N。对左右声道分别实数dft,fft点数为N。
对输出的结果进行降采样,设置一个缩放系数,比如为2.0,那就分配一个新的频域采样数组长度为N/2.0,然后把原fft结果降采样映射到新数组,不能有truncate,也就是新数组第一个元素是旧数组第一个元素,新数组最后一个元素就是旧的最后一个。
把新数组idft成新的音频,输出到/home/bczhc/out.wav,idft点数为新数组的长度。
左右声道的处理部分抽取成函数。缩放系数置为常量。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 没有支持流式压缩/解压缩 | |
| /// | |
| /// 手动实现,未使用bitvec bitstream-io 等库,练习作品,还有很多优化空间、、 | |
| #![feature(file_buffered)] | |
| use byteorder::{ReadBytesExt, WriteBytesExt, LE}; | |
| use clap::Parser; | |
| use std::cmp::{Ordering, Reverse}; | |
| use std::collections::{BinaryHeap, HashMap}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <optional> | |
| #include <vector> | |
| using namespace std; | |
| using Symbol = string; | |
| class Node { | |
| public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! Mainly wrote by Gemini. | |
| use anyhow::{Context, Result}; | |
| use clap::Parser; | |
| use hound::{SampleFormat, WavReader, WavSpec, WavWriter}; | |
| use num_complex::Complex64; | |
| use rustfft::FftPlanner; | |
| use std::env; | |
| use std::f64::consts::TAU; | |
| use std::path::PathBuf; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // [dependencies] | |
| // macroquad = "0.4.14" | |
| // palette = "0.7.6" | |
| use macroquad::hash; | |
| use macroquad::prelude::*; | |
| use macroquad::ui::{root_ui, widgets}; | |
| use palette::{FromColor, Hsl, Srgb}; | |
| fn window_conf() -> Conf { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct VertexInput { | |
| @location(0) pos: vec2<f32>, | |
| }; | |
| struct VertexOutput { | |
| @builtin(position) clip_position: vec4<f32>, | |
| }; | |
| @vertex | |
| fn vs_main(model: VertexInput) -> VertexOutput { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>利萨茹艺术生成器 - https://github.com/bczhc/Lissajous-curves/blob/master/a.htm 进化版</title> | |
| <style> | |
| :root { | |
| --bg-color: #0a0a0c; | |
| --panel-bg: rgba(255, 255, 255, 0.05); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <canvas width="500px" height="500px"></canvas> | |
| <script> | |
| async function loadShader(url) { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env rust-script | |
| //! ```cargo | |
| //! [dependencies] | |
| //! rexif = "0.7.5" | |
| //! serde_json = "1.0.145" | |
| //! ``` | |
| use std::env; | |
| use rexif::{ExifTag, TagValue}; | |
| fn main() { |
NewerOlder