Code Monkey home page Code Monkey logo

beatmix's People

Contributors

simonapiz avatar

Watchers

 avatar

beatmix's Issues

Bonus function

Bonus

As a bonus, you can choose to implement a function in script.js to play multiple synthesizer tones at once by writing:

  • function getNeighborPads
    a function called getNeighborPads that accepts an x, y, and a size parameter. In the application, these values refer to the synth grid: x and y zero-indexed from the bottom left of the grid, and size is a number representing the number of rows/columns in the square.
    getNeighborPads should return an array of neighbors, each in the form [xValue, yValue].
    Neighbors are the squares immediately to the left, right, above, and below of a grid position.

To work on the bonus with tests, you will need to remove their pending status. Open the test/test.js and edit the line that begins xdescribe('BONUS: getNeighborPads() function' (it should be around line 360 in the test file). If you delete the x (so that the line simply starts with describe( and save the test file before re-running, your bonus tests will now be active.

function toggleDrum

it takes two arguments:

  • a string representing the array name ('kicks', 'snares', 'hiHats', or 'rideCymbals'),
  • and an index number.

This function should flip the boolean value in the correct array at the specified index.

function presetHandler.

This function will be called from within your server to get an existing preset or create/update a preset.
presetHandler takes up to three arguments.

  • The first argument is a string representing the request type: 'GET' or 'PUT'.
  • The second argument is the array index of the presets array.
  • For 'PUT' requests, a third argument, newPresetArray will also be passed in, representing the new drum preset array to save at that index.
  • presetHandler should return an array. This array will have one or two elements depending on how it is called. If presetHandler is called with an invalid index, it should return an array with 404 as the first element, meaning that that array index is Not Found. If index is valid, the first element of the return array should be 200, meaning the request was OK.
  • If presetHandler is called a method that is not 'GET' or 'PUT', it should return an array with 400 as the first element, meaning that it was a Bad Request.
    If the index was valid, presetHandler should also return a second element in the array. for 'GET' requests, that element should be the preset array at that array index. For 'PUT' requests, it should save the newPresetArray to that index and then also return it as the second element.

Implementation Detail

Implementation Details

To complete this project, your code will need to contain the following in public/js/script.js:

  • Four variables to represent the arrays of drum pads. These arrays are named after the drums they represent:

    • kicks,
    • snares,
    • hiHats,
    • rideCymbals.

    These arrays should all have a length of 16 and be filled with false.

  • A function called #2 that takes two arguments:

    • a string representing the array name ('kicks', 'snares', 'hiHats', or 'rideCymbals'),
    • and an index number.
      This function should flip the boolean value in the correct array at the specified index.
  • #3
    A function named clear that takes an array name string and sets all values in the correct array to false.

  • #4
    A function named invert that takes an array name string and flips the boolean value of all elements in the correct array.

In addition, you will write some server-side code to handle saving and retrieving drum machine presets in presetHandler.js:

  • #5
    This function will be called from within your server to get an existing preset or create/update a preset.
    presetHandler takes up to three arguments.
    • The first argument is a string representing the request type: 'GET' or 'PUT'.
    • The second argument is the array index of the presets array.
    • For 'PUT' requests, a third argument, newPresetArray will also be passed in, representing the new drum preset array to save at that index.
    • presetHandler should return an array. This array will have one or two elements depending on how it is called. If presetHandler is called with an invalid index, it should return an array with 404 as the first element, meaning that that array index is Not Found. If index is valid, the first element of the return array should be 200, meaning the request was OK.
      If presetHandler is called a method that is not 'GET' or 'PUT', it should return an array with 400 as the first element, meaning that it was a Bad Request.
    • If the index was valid, presetHandler should also return a second element in the array. for 'GET' requests, that element should be the preset array at that array index. For 'PUT' requests, it should save the newPresetArray to that index and then also return it as the second element.

If you are testing presets with the app itself, you will need to stop and re-start your server to see the changes you write in presetHandler.js take effect.

function clear

A function named clear that takes an array name string and sets all values in the correct array to false.

function invert

A function named invert that takes an array name string and flips the boolean value of all elements in the correct array.

Test Code

Testing

As you work, check your work! While you're working in script.js, you should only need to refresh your browser to see changes, but once your move to writing code in presetHandler.js, you will need to restart your server to test out your work. To stop your server running, use the Ctrl + C key command in your terminal and start it again with npm run start.

A testing suite has been provided for you, checking for all essential functionality and edge cases. To run these tests, first open the root project directory in your terminal. Then run npm install to install all necessary testing dependencies (you will only need to do this step once). Finally, run npm run test. You will see a list of tests that ran with information about whether or not each test passed. After this list, you will see more specific output about why each failing test failed.

As you implement functionality, run the tests to ensure you are creating correctly named variables and functions that return the proper values. The tests will additionally help you identify edge cases that you may not have anticipated when first writing the functions.

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.