Skip to main content
31 votes

Python decibel meter-accurate?

Indent your code with a PEP8-compliant IDE or linter; it's a perfect mess right now. Move your global code into functions and maybe classes. There are two good use cases for classes here - one for a ...
Reinderien's user avatar
  • 65.3k
20 votes

Python program to scramble MP3 audio

Consider what happens if a user closes the "Load MP3" dialog without picking a file. In that case, filepath would get set to ...
Sara J's user avatar
  • 3,737
16 votes

Python program to scramble MP3 audio

There is quite some room for improvement, both in the overall architecture and style and in the logic that you use: Architecture and style Separate logic from presentation You have a single class ...
gazoh's user avatar
  • 3,349
13 votes

A struct for recording audio samples

This is very much C-style code: the only thing that qualifies it as C++ is the fact that you use new and delete[] rather than <...
200_success's user avatar
11 votes

Python program to scramble MP3 audio

First off, this is quite an interesting project for a beginner, well done on getting it working. Other people have mentioned a lot of the issues with our code style, however to expand on a few points: ...
DeathIncarnate's user avatar
10 votes
Accepted

Speech Recognition Part 1: Generate Training Data

I have to admit that I have no idea what the purpose of the code is (never worked with speech recognition) but I know a little bit Python so I can give some advise on the code itself. Performance ...
MSeifert's user avatar
  • 740
8 votes
Accepted

Split mp3 of album into individual tracks

I'll consider answering your last question (at least at the moment) about subprocess.run(). There's a similar method you can use for this kind of situations named ...
Grajdeanu Alex's user avatar
7 votes

Speech Recognition Part 1: Generate Training Data

PyAudio doesn't seem to have a with interface, however you should add that interface to your class. PEP 343 explains why it was added to Python, but it mostly comes ...
Peilonrayz's user avatar
  • 43.5k
7 votes
Accepted

Python Sound visualizer

Nice. Here are some observations: consider using an IntEnum: This helps remove "magic" numbers from the source code. (A year from now, will you remember that <...
RootTwo's user avatar
  • 10.2k
6 votes
Accepted

Play audio files when buttons are clicked in Simon Says

Duplicate Code Duplicate code is generally considered a bad practice since making a change to one version could require a change to all the versions. It's easier to maintain your code if design ...
Joshua Dawson's user avatar
6 votes

Play audio files when buttons are clicked in Simon Says

I recommend removing the inline onclick event handlers from your HTML document for a cleaner separation of markup and logic / JavaScript similarly to how you ...
le_m's user avatar
  • 1,925
6 votes
Accepted

Python Text-To-Speech program

DRY Apply the DRY (Do not Repeat Yourself) method. For instance, the check to remove the file. Since it's being called in two places, we can make this a function. I've re-written your code in a more ...
double_j's user avatar
  • 248
6 votes
Accepted

Modulating an oscillator by gain, pitch, and offset

counting flops Let's unpack the inner loop, where all the work is being done. I am repeating the whole thing here, wrapping to 80 columns and adding some indentation to make it easier to read. ...
enigmaticPhysicist's user avatar
6 votes
Accepted

Modular synthesizer framework for C++

This was fun code to play with and to review. I haven't played with a modular synth for about forty years. Here are some things that may help you improve your code. Consider hiding data Right now ...
Edward's user avatar
  • 66.6k
5 votes
Accepted

Speech Recognition Part 2: Classifying Data

Most of your comments aren't that great. Commenting about PEP8 compliance shouldn't be needed, and saying you're instantiating an object before doing it duplicates the amount we have to read for no ...
Peilonrayz's user avatar
  • 43.5k
5 votes
Accepted

Karplus Strong pluck generation

I was trying to improve your generate function and stumbled on a potential bug. You continuously update the buffer by adding two following values. This should be ...
Graipher's user avatar
  • 41.1k
5 votes

Karplus Strong pluck generation

Congratulations You mostly follows standards which is good. You also have good documentation which is great. All in all the code reads well and is easily understandable. Style-wise, I just have some ...
301_Moved_Permanently's user avatar
5 votes
Accepted

A baby monitor using a Raspberry Pi to send push notifications when triggered by noise

Bash ...
Peter Taylor's user avatar
  • 24.2k
5 votes

Modulating an oscillator by gain, pitch, and offset

Don't define pi and twopi yourself. They should be available from math.h as M_PI and M_2_PI if you're in the GNU stack. Defining ...
Reinderien's user avatar
  • 65.3k
5 votes
Accepted

C++ WAVE file reader: library-like structure, safety, readability

Ensure correct order of constructor member initializers My compiler warns me that in the constructors of Waveread, m_cachePos ...
G. Sliepen's user avatar
  • 61.7k
4 votes

Karplus Strong pluck generation

for i in range(nsamples): samples[i] = buf[i % N] avg = damping * 0.5 * (buf[i % N] + buf[(1 + i) % N]) buf[i % N] = avg There's some definite ...
Peter Taylor's user avatar
  • 24.2k
4 votes

Music player written in Python using PyQt

It can be a pleasure to whip something up in an hour on the plane. This code could be improved by using pylint. The most obvious improvements appear to be minimize and structure the instance ...
user650881's user avatar
4 votes
Accepted

Random MP3 Selector and Player

I would improve the following things: move the parsing argument part into a separate function (extract method) define descriptions and helps in multiline string constants use ...
alecxe's user avatar
  • 17.3k
4 votes

A struct for recording audio samples

There's not very much difference between structs and classes in C++. structs can have ...
user1118321's user avatar
  • 11.8k
4 votes
Accepted

Convert FLAC files to MP3 in parallel on Ubuntu

shellcheck It is always a good plan to run your code through shellcheck.net. This only reveals a couple of issues: Your -j$(nproc) should be quoted to avoid word ...
chicks's user avatar
  • 2,861
4 votes

Convert FLAC files to MP3 in parallel on Ubuntu

Please tell me you aren't running ffmpeg and other commands habitually as root! As a regular user, you need sudo to install ...
200_success's user avatar
4 votes

Hiding message within an audio file with entropy detection

If it is your first project, why choose an outdated version of Python to start with. Python 3 release was about 10 years ago and yet you chose to use Python 2. Anyway, there is not much you need to ...
301_Moved_Permanently's user avatar
4 votes
Accepted

The sheet music of Morning Mood

There's a lot of boilerplate in LilyPond to put all the parts together. In your case, you used: ...
200_success's user avatar
4 votes

Modulating an oscillator by gain, pitch, and offset

General overview I found this hard to follow. The logic is scattered across several coupled classes without a clear idea of a specific single responsibility for each class. The class, function and ...
Toby Speight's user avatar
  • 81.7k
4 votes
Accepted

Terminal interface audio player based on VLC & Curses

Your code is pretty good. You have some Pythonic style problems like on_press should have two blank lines before it, mypy probably would complain about ...
Peilonrayz's user avatar
  • 43.5k

Only top scored, non community-wiki answers of a minimum length are eligible