sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* Sine wave in an envelope
@ 2020-06-03 11:38 Darryl Lewis
  2020-06-03 14:33 ` Dr. Thomas Tensi
  0 siblings, 1 reply; 9+ messages in thread
From: Darryl Lewis @ 2020-06-03 11:38 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 326 bytes --]

Is there a way using sox to generate and modulate a sine wave with another sine wave.

So that the first sine wave plays in the envelope of the second,   similar to this image
https://d2mvzyuse3lwjc.cloudfront.net/doc/en/UserGuide/images/Envelope/400px-PID1643_envelope.png?v=0

Thanks in advance.
--

Darryl Lewis


[-- Attachment #1.2: Type: text/html, Size: 2879 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-03 11:38 Sine wave in an envelope Darryl Lewis
@ 2020-06-03 14:33 ` Dr. Thomas Tensi
  2020-06-03 15:05   ` Darryl Lewis
  2020-06-07 21:05   ` Jeff Learman
  0 siblings, 2 replies; 9+ messages in thread
From: Dr. Thomas Tensi @ 2020-06-03 14:33 UTC (permalink / raw)
  To: sox-users

Hello Darryl,


you wrote:
 > [modulate a sine wave with another in SoX?]

What you could do as an easy approach is modulate a sine wave with a
tremolo. Assume a target bit depth of 24bit, a sample rate of 44.1kHz, a
carrier of 1500Hz with a length of 20s and a modulation of 0.5Hz with a
depth of 100%

   sox -n -b 24 -r 44100 test.wav synth 20 sine 1500 tremolo 0.5 100

Tremolo can only do a sine modulation with a fixed phase of 90°.

Even more powerful is the cascading of synth effects. Same logic, the
carrier is amplitude-modulated by a sine with 0.5Hz with the same 20s
length:

   sox -n -b 24 -r 44100 test.wav synth 20 sine 1500 synth 20 sine amod 0.5

If you don't want a full modulation (from 0 to 100%), you can add a
dc-offset to the second waveform.

Hope this helps!


       Best regards,

                 Thomas


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-03 14:33 ` Dr. Thomas Tensi
@ 2020-06-03 15:05   ` Darryl Lewis
  2020-06-03 15:13     ` Dr. Thomas Tensi
  2020-06-07 21:05   ` Jeff Learman
  1 sibling, 1 reply; 9+ messages in thread
From: Darryl Lewis @ 2020-06-03 15:05 UTC (permalink / raw)
  To: sox-users


Thanks Dr Tensi,
Those examples are fantasic and give me a great base to work from.
 
Kind regards
Darryl

On 4/6/20, 12:34 am, "Dr. Thomas Tensi" <t.tensi@gmx.de> wrote:

    Hello Darryl,


    you wrote:
     > [modulate a sine wave with another in SoX?]

    What you could do as an easy approach is modulate a sine wave with a
    tremolo. Assume a target bit depth of 24bit, a sample rate of 44.1kHz, a
    carrier of 1500Hz with a length of 20s and a modulation of 0.5Hz with a
    depth of 100%

       sox -n -b 24 -r 44100 test.wav synth 20 sine 1500 tremolo 0.5 100

    Tremolo can only do a sine modulation with a fixed phase of 90°.

    Even more powerful is the cascading of synth effects. Same logic, the
    carrier is amplitude-modulated by a sine with 0.5Hz with the same 20s
    length:

       sox -n -b 24 -r 44100 test.wav synth 20 sine 1500 synth 20 sine amod 0.5

    If you don't want a full modulation (from 0 to 100%), you can add a
    dc-offset to the second waveform.

    Hope this helps!


           Best regards,

                     Thomas


    _______________________________________________
    Sox-users mailing list
    Sox-users@lists.sourceforge.net
    https://lists.sourceforge.net/lists/listinfo/sox-users


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-03 15:05   ` Darryl Lewis
@ 2020-06-03 15:13     ` Dr. Thomas Tensi
  0 siblings, 0 replies; 9+ messages in thread
From: Dr. Thomas Tensi @ 2020-06-03 15:13 UTC (permalink / raw)
  To: sox-users

Hello Darryl,


you wrote:
 > [Dr Tensi...]

I am always flattered when somebody uses my academic title, but here in
a forum my first name is good enough. So I am fine with "Thomas".

 > Those examples are fantasic and give me a great base to work from.

Fine, if the examples help you.  Feel free to ask, if you need further
assistance.


	Best regards,

		Thomas (!)

--
Dr. Thomas Tensi, Paganinistraße 60, 81247 München


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-03 14:33 ` Dr. Thomas Tensi
  2020-06-03 15:05   ` Darryl Lewis
@ 2020-06-07 21:05   ` Jeff Learman
  2020-06-08 11:11     ` Dr. Thomas Tensi
  1 sibling, 1 reply; 9+ messages in thread
From: Jeff Learman @ 2020-06-07 21:05 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1750 bytes --]

Hi, I'm trying to do a very similar thing but modulating the audio from a
file.  I want to produce a stereo tremolo by using the sine amod effect,
out of phase on the left and right channels.
LEN=0
OFFSET=0
PHASE=0
PHASE2=180
The following works for mono, producing the desired tremolo in mono:  sox
rd73_064__E4_082.flac x.flac synth $LEN $OFFSET $PHASE 2 sine amod 0.5
I thought the following would work for stereo: sox rd73_064__E4_082.flac
x.flac synth $LEN $OFFSET $PHASE2 2 sine amod $LEN $OFFSET $PHASE2

but I get a parameter error.  Any suggestions?

Thanks!

On Wed, 3 Jun 2020 at 10:34, Dr. Thomas Tensi <t.tensi@gmx.de> wrote:

> Hello Darryl,
>
>
> you wrote:
>  > [modulate a sine wave with another in SoX?]
>
> What you could do as an easy approach is modulate a sine wave with a
> tremolo. Assume a target bit depth of 24bit, a sample rate of 44.1kHz, a
> carrier of 1500Hz with a length of 20s and a modulation of 0.5Hz with a
> depth of 100%
>
>    sox -n -b 24 -r 44100 test.wav synth 20 sine 1500 tremolo 0.5 100
>
> Tremolo can only do a sine modulation with a fixed phase of 90°.
>
> Even more powerful is the cascading of synth effects. Same logic, the
> carrier is amplitude-modulated by a sine with 0.5Hz with the same 20s
> length:
>
>    sox -n -b 24 -r 44100 test.wav synth 20 sine 1500 synth 20 sine amod 0.5
>
> If you don't want a full modulation (from 0 to 100%), you can add a
> dc-offset to the second waveform.
>
> Hope this helps!
>
>
>        Best regards,
>
>                  Thomas
>
>
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users
>

[-- Attachment #1.2: Type: text/html, Size: 2440 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-07 21:05   ` Jeff Learman
@ 2020-06-08 11:11     ` Dr. Thomas Tensi
  2020-06-08 12:20       ` Jeff Learman
  0 siblings, 1 reply; 9+ messages in thread
From: Dr. Thomas Tensi @ 2020-06-08 11:11 UTC (permalink / raw)
  To: sox-users

Hello Jeff,


you wrote:
 > > [similar problem as amplitude modulating a sine wave]
 > I want to produce a stereo tremolo by using the sine amod
 > effect, out of phase on the left and right channels.

I am not sure whether this can be done in one command, but you could
modulate the channels into left and right mono versions and combine
(merge) the file into a stereo file. I assume that your source is in mono?
To paraphrase your solution:

-----
INFILE=rd73_064__E4_082.flac
OUTFILE=x.flac
tempfileLeft=left.flac
tempfileRight=right.flac

LEN=0
OFFSET=0
phaseLeft=0
phaseRight=180

# sox command fragments
tremPrefix=synth $LEN $OFFSET
tremSuffix=2 sine amod 0.5

sox $INFILE $tempfileLeft  $tremPrefix $phaseLeft  $tremSuffix
sox $INFILE $tempfileRight $tremPrefix $phaseRight $tremSuffix
sox -M $tempfileLeft $tempfileRight $OUTFILE
-----

Is this what you wanted?


         Best regards,

                 Thomas


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-08 11:11     ` Dr. Thomas Tensi
@ 2020-06-08 12:20       ` Jeff Learman
  2020-06-08 15:13         ` Dr. Thomas Tensi
  2020-06-08 19:24         ` Jeff Learman
  0 siblings, 2 replies; 9+ messages in thread
From: Jeff Learman @ 2020-06-08 12:20 UTC (permalink / raw)
  To: thomas, sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1589 bytes --]

Thanks.  Actually I'll have both mono and stereo cases, but was asking
about the stereo case.  Of course I can split the stereo into two mono
files.  I was hoping to do it in one line, which was the real question here
-- the synth effect documentation says it can operate differently on
different channels but I couldn't figure how to make that work.

Jeff

On Mon, 8 Jun 2020 at 07:13, Dr. Thomas Tensi <t.tensi@gmx.de> wrote:

> Hello Jeff,
>
>
> you wrote:
>  > > [similar problem as amplitude modulating a sine wave]
>  > I want to produce a stereo tremolo by using the sine amod
>  > effect, out of phase on the left and right channels.
>
> I am not sure whether this can be done in one command, but you could
> modulate the channels into left and right mono versions and combine
> (merge) the file into a stereo file. I assume that your source is in mono?
> To paraphrase your solution:
>
> -----
> INFILE=rd73_064__E4_082.flac
> OUTFILE=x.flac
> tempfileLeft=left.flac
> tempfileRight=right.flac
>
> LEN=0
> OFFSET=0
> phaseLeft=0
> phaseRight=180
>
> # sox command fragments
> tremPrefix=synth $LEN $OFFSET
> tremSuffix=2 sine amod 0.5
>
> sox $INFILE $tempfileLeft  $tremPrefix $phaseLeft  $tremSuffix
> sox $INFILE $tempfileRight $tremPrefix $phaseRight $tremSuffix
> sox -M $tempfileLeft $tempfileRight $OUTFILE
> -----
>
> Is this what you wanted?
>
>
>          Best regards,
>
>                  Thomas
>
>
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users
>

[-- Attachment #1.2: Type: text/html, Size: 2261 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-08 12:20       ` Jeff Learman
@ 2020-06-08 15:13         ` Dr. Thomas Tensi
  2020-06-08 19:24         ` Jeff Learman
  1 sibling, 0 replies; 9+ messages in thread
From: Dr. Thomas Tensi @ 2020-06-08 15:13 UTC (permalink / raw)
  To: sox-users

Hello Jeff,


you wrote:
 > Actually I'll have both mono and stereo cases, but was asking
 > about the stereo case.  Of course I can split the stereo into two mono
 > files.  I was hoping to do it in one line, which was the real question
 > here -- the synth effect documentation says it can operate differently
 > on different channels but I couldn't figure how to make that work.

Okay, I see what you mean in the documentation for "synth" where it says
"Audio for each channel in a multi-channel audio file can be synthesised
independently".

Hmm.  I haven't checked the code, but my gut feeling is that this
multiple channel setting of the synth effect only works for _creating_
waves in different channels.

As soon as you don't have "create" as the combine operation (in your
case it is "amod)" it is hard to find out for sox whether the combine
operator should apply to the input or some previous waveform.

In general and in my opinion, sox is not very good at doing some
specific processing on single channels of an input file as in your case.
  One similar example would be a parallel compression ("New York City
compression") where a compressed signal is combined with the original:
as far as I know this only can be done with a temporary file.


          Best regards,

                  Thomas


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Sine wave in an envelope
  2020-06-08 12:20       ` Jeff Learman
  2020-06-08 15:13         ` Dr. Thomas Tensi
@ 2020-06-08 19:24         ` Jeff Learman
  1 sibling, 0 replies; 9+ messages in thread
From: Jeff Learman @ 2020-06-08 19:24 UTC (permalink / raw)
  To: thomas, sox-users


[-- Attachment #1.1: Type: text/plain, Size: 2040 bytes --]

Ah, got it sorted:

LEN=0
OFFSET=0
LPHASE=40
RPHASE=90
FREQ=.75

For mono file:
    sox in.flac out.flac remix 1 1 synth $LEN $OFFSET $LPHASE sine amod
$FREQ $OFFSET $RPHASE sine amod $FREQ
For stereo file:
    sox in.flac out.flac synth $LEN $OFFSET $LPHASE sine amod $FREQ $OFFSET
$RPHASE sine amod $FREQ

Jeff

On Mon, 8 Jun 2020 at 08:20, Jeff Learman <jjlearman@gmail.com> wrote:

> Thanks.  Actually I'll have both mono and stereo cases, but was asking
> about the stereo case.  Of course I can split the stereo into two mono
> files.  I was hoping to do it in one line, which was the real question here
> -- the synth effect documentation says it can operate differently on
> different channels but I couldn't figure how to make that work.
>
> Jeff
>
> On Mon, 8 Jun 2020 at 07:13, Dr. Thomas Tensi <t.tensi@gmx.de> wrote:
>
>> Hello Jeff,
>>
>>
>> you wrote:
>>  > > [similar problem as amplitude modulating a sine wave]
>>  > I want to produce a stereo tremolo by using the sine amod
>>  > effect, out of phase on the left and right channels.
>>
>> I am not sure whether this can be done in one command, but you could
>> modulate the channels into left and right mono versions and combine
>> (merge) the file into a stereo file. I assume that your source is in mono?
>> To paraphrase your solution:
>>
>> -----
>> INFILE=rd73_064__E4_082.flac
>> OUTFILE=x.flac
>> tempfileLeft=left.flac
>> tempfileRight=right.flac
>>
>> LEN=0
>> OFFSET=0
>> phaseLeft=0
>> phaseRight=180
>>
>> # sox command fragments
>> tremPrefix=synth $LEN $OFFSET
>> tremSuffix=2 sine amod 0.5
>>
>> sox $INFILE $tempfileLeft  $tremPrefix $phaseLeft  $tremSuffix
>> sox $INFILE $tempfileRight $tremPrefix $phaseRight $tremSuffix
>> sox -M $tempfileLeft $tempfileRight $OUTFILE
>> -----
>>
>> Is this what you wanted?
>>
>>
>>          Best regards,
>>
>>                  Thomas
>>
>>
>> _______________________________________________
>> Sox-users mailing list
>> Sox-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/sox-users
>>
>

[-- Attachment #1.2: Type: text/html, Size: 3036 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-08 19:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 11:38 Sine wave in an envelope Darryl Lewis
2020-06-03 14:33 ` Dr. Thomas Tensi
2020-06-03 15:05   ` Darryl Lewis
2020-06-03 15:13     ` Dr. Thomas Tensi
2020-06-07 21:05   ` Jeff Learman
2020-06-08 11:11     ` Dr. Thomas Tensi
2020-06-08 12:20       ` Jeff Learman
2020-06-08 15:13         ` Dr. Thomas Tensi
2020-06-08 19:24         ` Jeff Learman

sox-users@lists.sourceforge.net unofficial mirror

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/sox-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 sox-users sox-users/ https://public-inbox.org/sox-users \
		sox-users@lists.sourceforge.net
	public-inbox-index sox-users

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.audio.sox
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.audio.sox
	nntp://news.gmane.io/gmane.comp.audio.sox
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/sox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git