File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1643,14 +1643,31 @@ define(function (require) {
1643
1643
1644
1644
/**
1645
1645
* Save a p5.SoundFile as a .wav file. The browser will prompt the user
1646
- * to download the file to their device.
1646
+ * to download the file to their device. To upload a file to a server, see
1647
+ * <a href="/docs/reference/#/p5.SoundFile/getBlob">getBlob</a>
1647
1648
*
1648
1649
* @method save
1649
1650
* @param {String } [fileName] name of the resulting .wav file.
1651
+ * @example
1652
+ * <div><code>
1653
+ * var inp, button, mySound;
1654
+ * var fileName = 'cool';
1655
+ * function setup() {
1656
+ * mySound = loadSound('assets/doorbell.mp3');
1657
+ *
1658
+ * btn = createButton('click to save file');
1659
+ * btn.position(0, 0);
1660
+ * btn.mouseClicked(handleMouseClick);
1661
+ * }
1662
+ *
1663
+ * function handleMouseClick() {
1664
+ * mySound.save(fileName);
1665
+ * }
1666
+ * </code></div>
1650
1667
*/
1651
1668
p5 . SoundFile . prototype . save = function ( fileName ) {
1652
1669
const dataView = convertToWav ( this . buffer ) ;
1653
- p5 . prototype . writeFile ( [ dataView ] , fileName , 'wav' ) ;
1670
+ p5 . prototype . saveSound ( [ dataView ] , fileName , 'wav' ) ;
1654
1671
} ;
1655
1672
1656
1673
/**
You can’t perform that action at this time.
0 commit comments