Skip to content

Add octave shift example#110

Merged
bramtayl merged 3 commits into
JuliaAudio:masterfrom
JeffFessler:octave-shift
Mar 22, 2022
Merged

Add octave shift example#110
bramtayl merged 3 commits into
JuliaAudio:masterfrom
JeffFessler:octave-shift

Conversation

@JeffFessler

Copy link
Copy Markdown
Member

This PR provides an example of performing a real-time octave (down) shift using a crude FFT approach.
I did not see any examples that show audio processing of an input stream and writing the results to an output stream and I wanted to have an illustration of that for students in my course.

This is independent of #107 though of course they both work on the examples/ directory.

@codecov

codecov Bot commented Mar 19, 2022

Copy link
Copy Markdown

Codecov Report

Merging #110 (ef0cfcb) into master (78a0a99) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #110   +/-   ##
=======================================
  Coverage   97.38%   97.38%           
=======================================
  Files           2        2           
  Lines         344      344           
=======================================
  Hits          335      335           
  Misses          9        9           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78a0a99...ef0cfcb. Read the comment docs.

@bramtayl

bramtayl commented Mar 21, 2022

Copy link
Copy Markdown
Member

Wow, this looks great! It would good to have it only run for a specific amount of time, so we can eventually run it in CI. The pattern I've used in #107 was

@sync begin
    @async while !done
        # refresh the plot
    end
    sleep(seconds)
    done = true
end

There might be better ways to do this.

@bramtayl

Copy link
Copy Markdown
Member

PS, do you want to join as a maintainer?

@JeffFessler

Copy link
Copy Markdown
Member Author

PS, do you want to join as a maintainer?

Yes, I would be happy to help in that way. I don't know anything about libportaudio but can help on the Julia side. Thanks!

@JeffFessler JeffFessler marked this pull request as draft March 21, 2022 16:15
@JeffFessler

Copy link
Copy Markdown
Member Author

Ok, I implemented the suggested @async model, which was a nice trick for me to learn.
Perhaps another way would be to calculate the number of loop iterations from the duration and the buffer length and the sample size:
Niters = Int(seconds * sampling_rate / N)

I might slightly prefer that way, because it will look less mysterious to beginnners.
Do you have a preference?

@bramtayl

Copy link
Copy Markdown
Member

Do you have a preference?

Nope, whatever works!

@JeffFessler JeffFessler marked this pull request as ready for review March 21, 2022 22:21
@JeffFessler

Copy link
Copy Markdown
Member Author

Ok, I went with the loop approach and added a bit more documentation and now it is ready for review.

@bramtayl

Copy link
Copy Markdown
Member

This looks good to me!

1 similar comment
@bramtayl

Copy link
Copy Markdown
Member

This looks good to me!

@bramtayl bramtayl merged commit 24acc02 into JuliaAudio:master Mar 22, 2022
@JeffFessler JeffFessler deleted the octave-shift branch March 22, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants