Code Monkey home page Code Monkey logo

newshadeofpink's Introduction

March, 2016: If you're on an old version of Jekyll Now and run into a) build warnings or b) syntax highlighting issues caused by Jekyll 3 and GitHub Pages updates, just ✨update your _config.yml✨ and you'll be set!

Jekyll Now

Jekyll is a static site generator that's perfect for GitHub hosted blogs (Jekyll Repository)

Jekyll Now makes it easier to create your Jekyll blog, by eliminating a lot of the up front setup.

  • You don't need to touch the command line
  • You don't need to install/configure ruby, rvm/rbenv, ruby gems ☺️
  • You don't need to install runtime dependencies like markdown processors, Pygments, etc
  • If you're on Windows, this will make setting up Jekyll a lot easier
  • It's easy to try out, you can just delete your forked repository if you don't like it

In a few minutes you'll be set up with a minimal, responsive blog like the one below giving you more time to spend on writing epic blog posts!

Jekyll Now Theme Screenshot

Quick Start

Step 1) Fork Jekyll Now to your User Repository

Fork this repo, then rename the repository to yourgithubusername.github.io.

Your Jekyll blog will often be viewable immediately at https://yourgithubusername.github.io (if it's not, you can often force it to build by completing step 2)

Step 1

Step 2) Customize and view your site

Enter your site name, description, avatar and many other options by editing the _config.yml file. You can easily turn on Google Analytics tracking, Disqus commenting and social icons here too.

Making a change to _config.yml (or any file in your repository) will force GitHub Pages to rebuild your site with jekyll. Your rebuilt site will be viewable a few seconds later at https://yourgithubusername.github.io - if not, give it ten minutes as GitHub suggests and it'll appear soon

There are 3 different ways that you can make changes to your blog's files:

  1. Edit files within your new username.github.io repository in the browser at GitHub.com (shown below).
  2. Use a third party GitHub content editor, like Prose by Development Seed. It's optimized for use with Jekyll making markdown editing, writing drafts, and uploading images really easy.
  3. Clone down your repository and make updates locally, then push them to your GitHub repository.

_config.yml

Step 3) Publish your first blog post

Edit /_posts/2014-3-3-Hello-World.md to publish your first blog post. This Markdown Cheatsheet might come in handy.

First Post

You can add additional posts in the browser on GitHub.com too! Just hit the + icon in /_posts/ to create new content. Just make sure to include the front-matter block at the top of each new blog post and make sure the post's filename is in this format: year-month-day-title.md

Local Development

  1. Install Jekyll and plug-ins in one fell swoop. gem install github-pages This mirrors the plug-ins used by GitHub Pages on your local machine including Jekyll, Sass, etc.
  2. Clone down your fork git clone https://github.com/yourusername/yourusername.github.io.git
  3. Serve the site and watch for markup/sass changes jekyll serve
  4. View your website at http://127.0.0.1:4000/
  5. Commit any changes and push everything to the master branch of your GitHub user repository. GitHub Pages will then rebuild and serve your website.

Moar!

I've created a more detailed walkthrough, Build A Blog With Jekyll And GitHub Pages over at the Smashing Magazine website. Check it out if you'd like a more detailed walkthrough and some background on Jekyll. 🤘

It covers:

  • A more detailed walkthrough of setting up your Jekyll blog
  • Common issues that you might encounter while using Jekyll
  • Importing from Wordpress, using your own domain name, and blogging in your favorite editor
  • Theming in Jekyll, with Liquid templating examples
  • A quick look at Jekyll 2.0’s new features, including Sass/Coffeescript support and Collections

Jekyll Now Features

✓ Command-line free fork-first workflow, using GitHub.com to create, customize and post to your blog
✓ Fully responsive and mobile optimized base theme (Theme Demo)
✓ Sass/Coffeescript support using Jekyll 2.0
✓ Free hosting on your GitHub Pages user site
✓ Markdown blogging
✓ Syntax highlighting
✓ Disqus commenting
✓ Google Analytics integration
✓ SVG social icons for your footer
✓ 3 http requests, including your avatar

✘ No installing dependencies ✘ No need to set up local development
✘ No configuring plugins
✘ No need to spend time on theming
✘ More time to code other things ... wait ✓!

Questions?

Open an Issue and let's chat!

Other forkable themes

You can use the Quick Start workflow with other themes that are set up to be forked too! Here are some of my favorites:

Credits

Contributing

Issues and Pull Requests are greatly appreciated. If you've never contributed to an open source project before I'm more than happy to walk you through how to create a pull request.

You can start by opening an issue describing the problem that you're looking to resolve and we'll go from there.

I want to keep Jekyll Now as minimal as possible. Every line of code should be one that's useful to 90% of the people using it. Please bear that in mind when submitting feature requests. If it's not something that most people will use, it probably won't get merged. 💂‍♂️

newshadeofpink's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

newshadeofpink's Issues

Discussion on algorithm

This isn't a feature request/bug report; there's nothing to change here.

The core feature of this pink noise generator over Voss-McCartney is its usage of linear interpolation rather than no-interpolation. In addition, it does bit twiddling to both save space and make computation efficient.

First, the bit twiddling is indeed very efficient. Compared to my own algorithm, which does linear interpolation with two int64_t per bucket, Stenzel's algorithm uses two bits per bucket, which is 64x smaller. Stenzel spreads out a single PRNG call over 16 samples, while I call the PRNG every sample. Bit packing also saves an operation, since I have to keep track of a continuing velocity, while Stenzel's algorithm can add the inc and dec buckets directly. In practical terms, I benchmarked Stenzel's algorithm as 2x faster than mine. (Mine also uses a xoshiro256+ 64-bit RNG, rather than Stenzel's 32-bit LFSR.) So packing the state into bits is great.

As for linear interpolation, the disadvantage of using one bit per bucket is that it will be slightly inaccurate on a short-term basis. This is the same phenomenon as how Voss and Voss-McCartney are equivalent when integrated over an infinite time period, but different over short periods. This inaccuracy probably doesn't matter, but if it's important to you, you can instead use a 64-bit RNG, and extract 4 bits per bucket, with 16 buckets. 4 bits is likely enough to solve any issues, and 16 buckets is plenty.

Some people have remarked on "Velvet noise", with 1.6 bits per sample, as being smoother/better than regular Gaussian/uniform noise. I haven't listened to it, and I'm pretty skeptical from a mathematical viewpoint, but there may be something I'm missing. If it's really true, the same advantage should extend to Stenzel's 1 bit per bucket.

Stenzel's top bucket uses an FIR filter to smooth out the Nyquist response. This bucket is way more accurate than adding in white noise. If you are using pink noise for musical purposes, Nyquist at 44100 Hz sample rate is of no use, and it's better to have no signal there. So you might as well leave out this FIR bucket. If you are using pink noise for scientific purposes, then this is a well-constructed bucket with great properties.

The float hack used in the code uses a union of int and float to do bit twiddling. It's technically undefined, but sometimes compilers support it anyway. If you don't want to rely on this, you can use memcpy instead. In assembly, this memcpy results in a register move from an int register to a float register. I'm not sure what its impact on efficiency would be.

Effect of sample rate? Also Java port

Hi Stefan,

Just came across this, nice work! I do my programming in Java, so I made a Java version to investigate the algorithm. Code is below if of interest and contributed freely for any use. I made a slight change from your standard version, replacing the first zero entry in the pnmasks table by 1 << 7 to slightly reduce the low frequency extension and flatten off the spectrum at 5 Hz or so rather than 2.5 Hz, the aim being to keep generated levels a little more consistent across different interface low end rolloffs. I also adapted it to return single values rather than writing blocks of 16 samples.

Should there be an adaptation for different sample rates, different filter coefficient tables, perhaps?

/**
 * Pink noise generation using the algorithm by Stefan Stenzel https://github.com/Stenzel/newshadeofpink
 */
class PinkNoise {
    private static final float PINK_BIAS = 3.0f;
    
    // lookup for bitreversed masks
    // Replaced 1 << 7 by 0 to reduce low frequency extension slightly, 
    // spectrum levels off at approx 5 Hz rather than 2.5 Hz
	private static final int[] pnmask = {
           0,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x04 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
           2 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x04 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000, 
           0,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x04 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
           2 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x04 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,
        0x08 << 7,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000,0x0800,0x4000,0x2000,0x4000,0x1000,0x4000,0x2000,0x4000};
    private static final int[] otherMasks = {
        0, 0x40000,0x20000,0x40000,0x10000,0x40000,0x20000,0x40000,0x08000,0x40000,0x20000,0x40000,0x10000,0x40000,0x20000,0x40000};
    // Lookup tables for 12-tap FIR filter with these coefficients:
    private static final float[] FIR = {
        1.190566f, 0.162580f, 0.002208f, 0.025475f, -0.001522f, 0.007322f, 
        0.001774f, 0.004529f, -0.001561f, 0.000776f, -0.000486f, 0.002017f};
    // 1st precalculated FIR lookup table, also for bias correction
	private static final float[] pfira = new float[64];
    // 2nd precalculated FIR lookup table
	private static final float[] pfirb = new float[64]; 
	private static int instance_cnt; // used for decorrelation in case of multiple instances
    
	private int lfsr; // linear feedback shift register
	private int inc;  // increment for all noise sources (bits)
	private int dec;  // decrement for all noise sources
    private int accui; // int interpretation of accu
	private int pnCount; // index to pnmask[]
    private int otherCount; // index to otherMasks

    private static float F(float cf, int m, int shift) {
        return 0.0625f * cf * (2 * ((m) >>> shift & 1) - 1);
    }
    
    private static float FA(int n) {
        float result = F(FIR[0], n, 0);
        for (int i = 1; i < 6; i++) {
            result += F(FIR[i], n, i);
        }
        return result - PINK_BIAS;
    }

    private static float FB(int n) {
        float result = F(FIR[6], n, 0);
        for (int i = 1; i < 6; i++) {
            result += F(FIR[6+i], n, i);
        }
        return result;
    }
    
    static {
        for (int n = 0; n < 64; n++) {
            pfira[n] = FA(n);
            pfirb[n] = FB(n);
        }
    }
    
    private float pink(int bitmask){
        int bit = lfsr >> 31;            // spill random to all bits
        dec &= ~bitmask;                 // blank old decrement bit
        lfsr <<= 1;                      // shift lfsr
        dec |= inc & bitmask;            // copy increment to decrement bit
        inc ^= bit & bitmask;            // new random bit
        float sample = Float.intBitsToFloat(accui); // get value as float  
        accui  += inc - dec;             // integrate   
        lfsr ^= bit & 0x46000001;        // update lfsr
        return sample                    // save output and ...
             + pfira[lfsr & 0x3F]        // add 1st half FIR & subtract bias
             + pfirb[lfsr>>6 & 0x3F];    // add 2nd half precalculated FIR
    }
    
    float nextValue(){
        int mask;
        if (otherCount == 0){
            mask = pnmask[pnCount];
            pnCount = (pnCount + 1) & 0x0ff;
        }else{
            mask = otherMasks[otherCount];
        }
        otherCount = (otherCount + 1) & 0x0f;
        return pink(mask);
    }
    
    PinkNoise(){
        lfsr  = 0x5EED41F5 + instance_cnt++;        // seed for lfsr, decorrelate multiple instances    
        accui = Float.floatToRawIntBits(PINK_BIAS);
        pnCount = 0;                                // counter from zero    
        inc   = 0x04CCCC;                           // balance initial states to avoid DC 
        dec   = 0x04CCCC;        
    }
    
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.