Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:35 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Putting PLAY LOAD SOUND to work.

Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 04:35am 25 Jul 2024
Copy link to clipboard 
Print this post

For sound effects MOD is excellent but resource hungry, sawtooth, triangle and square waves only have odd** harmonics so are not the most pleasant. Sine is dull.

PLAY LOAD SOUND can provide any mix of harmonics so here is a program that goes up to the eighth harmonic.

** In physics and mathematics the fundamental frequency is also the first harmonic as the equations are a little simpler that way while many musicians regard 2 x fundamental as the first.
This uses the latter as I had trouble with PLAY LOAD SOUND accepting OPTION BASE 1.
It generates 3 test tones that you can easily modify to your own preference. Changing the phase shifts makes a difference to the shape of the wave on the scope but to me, little difference to the sound.

' Print "Create array for PLAY LOAD SOUND v02.bas"
Option base 0

Dim integer PLS01(1023), harmonics01(1,7) = (1000,0, 500,-90, 0,0, 400,-45, 0,0 ,300,-30, 0,0, 200,-12)
Dim integer PLS02(1023), harmonics02(1,7) = (1000,0, 0,0, 0,0, 0,0, 0,0 ,0,0, 0,0, 0,0)
Dim integer PLS03(1023), harmonics03(1,7) = (0,0, 1000,0, 0,0, 0,0, 0,0 ,0,0, 0,0, 0,0)
'harmonics array has 8 pairs of amplitude & phase shift (degrees - of fundamental F) values
' the first is the fundamental followed by the harmonics in ascending order.
Print "Wait a while for the arrays to be calculatyed" :Print

PLS_maker PLS01(), harmonics01() :Print "array 01 filled"
PLS_maker PLS02(), harmonics02() :Print "array 02 filled"
PLS_maker PLS03(), harmonics03() :Print "array 03 filled" :Print

Play LOAD SOUND PLS01()
Play SOUND 1, B, U, 440, 25
Print "array 01 now playing, even harmonics"
Pause 5000
Play STOP

Play LOAD SOUND PLS02()
Play SOUND 2, B, U, 440, 25
Print "array 02 now playing, fundamental only"
Pause 5000
Play STOP

Play LOAD SOUND PLS03()
Play SOUND 3, B, U, 440, 25
Print "array 03 now playing, fundamental supressed - 2nd harmonic only"


Print :Print "Press ctrl-C to stop"
Do
'Your program here
Loop


Sub PLS_maker PLSout%(), harmonics%()

 Local float PLS(4095), minin, maxin
 Local integer PLSs(4095), n, m

 For m=0 To 7
'  Print m, harmonics%(0,m),, harmonics%(1,m)/180
   For n=0 To 4095
    Inc PLS(n), harmonics%(0,m) * Sin(n * (m+1) * Pi/2023 + Pi*harmonics%(1,m)/180)
   Next
 Next

 Math WINDOW PLS(), 0, 4095, PLSs(), minin, maxin
'  Print "Peak to Peak value "; maxin - minin

 Memory PACK PLSs(), PLSout%(), 4096, 16

End Sub

Set the first amplitude to any convenient value such as 100 or 1000 to make it easier to see the relative size of the others.
Math WINDOW will resize the P-P amplitude in the final array to the max. allowed.
Edited 2024-07-25 15:03 by phil99
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4223
Posted: 05:19am 25 Jul 2024
Copy link to clipboard 
Print this post

Nice work phill,

This is a good example how to use the command. I never played with it before,so this is a teaser.

Volhout
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 857
Posted: 05:41am 25 Jul 2024
Copy link to clipboard 
Print this post

Hey Phil, you just reminded me of a post that I forgot to make.


A short while ago, a couple of our members were lamenting about having the skills and resources but no projects.

I don't have the time or I would be doing something that is definitely needed by solo musicians and other performers who can no-longer justify a full band (cost/floor-space/drunken-drummers, etc.).

Backing tracks have been around forever but are regarded by many as sounding tacky. However, professional-quality tracks are available where the instruments are separated and become their own audio files. This is much better because a performer might only need/want the bass/drums and maybe a backing guitar/vocals etc.

So. We download these individual tracks and using a DAW (digital audio workstation) such as Audacity (I prefer the new, totally free Cakewalk), we create/modify these files to suit our performance and eventually mix-down to mp3.

The problem is that; the mix is fixed. It might sound great at one venue but not-so-great at another. Ideally we want to be able to adjust the levels of each "instrument" to suit the venue's acoustics.

I'm thinking about a PicoMite-per-track (I guess there is the option of two mono tracks-per-PicoMite).

Maybe a pot or a rotary encoder to set levels, etc.

Pretty certain that for the duration of a song, wouldn't be a problem to keep the PicoMites in sync.

Most musicians are luddites who don't want to be messing around with tablets and laptops on stage.

Wish I had the time  

One source of backing tracks It takes a bit of time to download each instrument individually but this flexibility is great because the results can be much more realistic.

Edit: Oops, maybe this isn't quite on-topic.
Edited 2024-07-25 15:46 by PhenixRising
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 11:27pm 28 Jul 2024
Copy link to clipboard 
Print this post

A much simpler way to get even harmonics:-
> freq = 440
> Play SOUND 1, B, S, freq, 25 : Play SOUND 2, B, T, freq*2, 15
>

DOH!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024