(Sep-24-2019, 03:25 PM)xBlackHeartx Wrote: This pysynth looks interesting, but which file am I supposed to download? The only module I've ever installed is pygame, and with that I had to enter a command in my computer's command prompt.install the same way
pip install pysynth
(Sep-24-2019, 03:25 PM)xBlackHeartx Wrote: As for game files, honestly, I prefer everything to be contained within the code of the game.
(Sep-24-2019, 03:25 PM)xBlackHeartx Wrote: I would also prefer to be able to synthesize music from within my programs themselves.I would much prefer to use GIMP to draw images at a faster rate than coding them and load the images. Same with music and sounds. That is about what most people do that i know of. 99 out of 100 people do it this way in a game. The only time i have seen people do it the other way was software, not a game. And even then it has a save function to write it to disk. I have also found out that when passing programs to the public requires building exe's. And the more things you import the more problems that occur in building exe's. So i try to reduce the number of 3rd party libraries as uch as possible. One of those is just including files with the program such as images, sounds, and music.
But i am sure what you want is doable. You just need to find the right software to do what you want. Im sure there is a 3rd party lib somewhere in pypi. There has to have been someone who made a package that wants to do similar to what you are doing. Got this off another Google search for python synthesizer
A video using Numpy for a synthesizer. His first video in the series create a wav files, but maybe he does not later in the series.
https://www.youtube.com/watch?v=6nzN7xnDSLU
https://github.com/akey7/numpy-audio-synth
You can use NumPy and sounddevice 3rd party library installed the same way with pip.
import numpy as np # download import sounddevice as sd # download import time stream = [] # Main Controls sps = 44100 # DON'T CHANGE carrier_hz = 440.0 duration_s = 1.0 atten = 0.3 def amplitudeMod(t_samples, carrier): # Modulate the amplitude of the carrier ac = 0.2 # amplitude 0 = min, 1 = max ka = 1.0 # range of change 0.1 = less, 1.0 = most modulator_hz = 0.0 # frequency of modulation 20hz max modulator = np.sin(2 * np.pi * modulator_hz * t_samples / sps) envelope = ac * (1.0 + ka * modulator) return carrier * envelope def frequencyMod(t_samples, sps): # Modulate the frequency of the carrier k = 50.0 # range of change 0.1 = less, ?? = most modulator_hz = 10.0 # frequency of modulation carrier2 = 2 * np.pi * t_samples * carrier_hz / sps modulator = k * np.sin(2 * np.pi * t_samples * modulator_hz / sps) return np.cos(carrier2 + modulator) # Create carrier wave t_samples = np.arange(duration_s * sps) carrier = np.sin(2 * np.pi * carrier_hz * t_samples / sps) choice = input("1) Play sine\n2) Play amplitude modulation\n3) Play frequency modulation\n;") if choice == "1": output = carrier if choice == "2": output = amplitudeMod(t_samples, carrier) if choice == "3": output = frequencyMod(t_samples, sps) # Output output *= atten sd.play(output, sps) sd.wait() sd.stop()Another option....
https://ipython-books.github.io/117-crea...-notebook/
another option....
https://github.com/nwhitehead/pyfluidsynth
Recommended Tutorials: