├── LICENSE ├── README.md ├── RealtimeMusicVisualizer ├── RealtimeMusicVisualizer.h └── RealtimeMusicVisualizer.ino └── libraries └── ffft ├── ffft.S └── ffft.h /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Realtime Music Visualizer for Arduino 2 | 3 | Firmware for the nootropic design realtime music visualizer circuit. 4 | 5 | Install libraries/ffft in your Arduino sketchbook libraries folder. 6 | 7 | Requires the [Adafruit NeoPixel library](https://github.com/adafruit/Adafruit_NeoPixel). 8 | Your directory structure should look like this: 9 | 10 | ``` 11 | your_sketchbook 12 | | 13 | +--libraries 14 | | | 15 | | +--ffft 16 | | | 17 | | +--Adafruit_NeoPixel 18 | | 19 | +--RealtimeMusicVisualizer 20 | | 21 | +--RealtimeMusicVisualizer.h 22 | +--RealtimeMusicVisualizer.ino 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /RealtimeMusicVisualizer/RealtimeMusicVisualizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Lumazoid realtime music visualizer board firmware 3 | Copyright (C) 2015 Michael Krumpus, nootropic design, LLC 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef RTMV_H 20 | #define RTMV_H 21 | 22 | #if (ARDUINO >= 100) 23 | #include 24 | #else 25 | #include 26 | #include 27 | #endif 28 | 29 | typedef struct { 30 | uint8_t baseColor; 31 | uint8_t age; 32 | uint8_t magnitude; 33 | uint8_t rnd; 34 | } peak_t; 35 | 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /RealtimeMusicVisualizer/RealtimeMusicVisualizer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Realtime music visualizer for LED strips 3 | Copyright (C) 2016 Michael Krumpus, nootropic design, LLC 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "RealtimeMusicVisualizer.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | //#define DEBUG 27 | #define ADC_CHANNEL 0 28 | #define N_BANDS 8 29 | #define N_FRAMES 5 30 | #define N_PEAKS 25 31 | #define LED_STRIP_PIN 6 32 | 33 | #define N_LEDS 120 34 | #define CUTOFF_BAND 2 35 | #define SINGLE_DIRECTION false 36 | #define MAX_BRIGHTNESS 255 37 | #define MIN_COLOR_CHANGE_COUNT 5 38 | #define MAX_COLOR_CHANGE_COUNT 10 39 | 40 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(120, LED_STRIP_PIN, NEO_GRB + NEO_KHZ800); 41 | 42 | peak_t peaks[N_PEAKS]; 43 | uint8_t peakIndex = 0; 44 | uint8_t newPeakFlags = 0; 45 | uint8_t randColor[] = {0, 0}; 46 | uint8_t randColorCount[] = {0, 0}; 47 | 48 | 49 | // FFT_N = 128 50 | int16_t capture[FFT_N]; // Audio capture buffer 51 | complex_t bfly_buff[FFT_N]; // FFT "butterfly" buffer 52 | uint16_t spectrum[FFT_N / 2]; // Spectrum output buffer 53 | 54 | volatile byte samplePos = 0; // Buffer position counter 55 | float brightnessScale = MAX_BRIGHTNESS / 255.0; 56 | uint8_t MAX_AGE; 57 | 58 | byte 59 | bandPeakLevel[8], // Peak level of each band 60 | bandPeakCounter = 0, // Frame counter for delaying the fall of the band peak 61 | bandPeakDecay = 6, // peak decreases by 1 every bandPeakDecay frames. Larger value is slower decay 62 | bandCount = 0; // Frame counter for storing past band data 63 | int 64 | band[8][N_FRAMES], // band levels for the prior N_FRAMES frames 65 | minLvlAvg[8], // For dynamic adjustment of low & high ends of graph, 66 | maxLvlAvg[8], // pseudo rolling averages for the prior few frames. 67 | bandDiv[8]; // Used when filtering FFT output to 8 bands 68 | 69 | // declare all control variables here so we can more easily measure memory consumption 70 | uint8_t i, j, noiseThreshold, *data, nBins, binNum, weighting, c; 71 | uint16_t minLvl, maxLvl; 72 | int16_t level, sum; 73 | 74 | const uint8_t PROGMEM noiseFloor[64] = {8, 6, 6, 5, 3, 4, 4, 4, 3, 4, 4, 3, 2, 3, 3, 4, 2, 1, 2, 1, 3, 2, 3, 2, 1, 2, 3, 1, 2, 3, 4, 4, 3, 2, 2, 2, 2, 2, 2, 1, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4}; 75 | const uint8_t PROGMEM eq[64] = {255, 175, 218, 225, 220, 198, 147, 99, 68, 47, 33, 22, 14, 8, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 76 | const uint8_t PROGMEM bandBinCounts[] = {2, 4, 5, 8, 11, 17, 25, 37}; 77 | const uint8_t PROGMEM bandBinStarts[] = {1, 1, 2, 3, 5, 7, 11, 16}; 78 | const uint8_t PROGMEM band0weights[] = {181, 40}; 79 | const uint8_t PROGMEM band1weights[] = {19, 186, 38, 2}; 80 | const uint8_t PROGMEM band2weights[] = {11, 176, 118, 16, 1}; 81 | const uint8_t PROGMEM band3weights[] = {5, 55, 165, 164, 71, 18, 4, 1}; 82 | const uint8_t PROGMEM band4weights[] = {3, 24, 89, 139, 148, 118, 54, 20, 6, 2, 1}; 83 | const uint8_t PROGMEM band5weights[] = {2, 9, 29, 70, 125, 172, 185, 162, 118, 74, 41, 21, 10, 5, 2, 1, 1}; 84 | const uint8_t PROGMEM band6weights[] = {1, 4, 11, 25, 49, 83, 121, 156, 180, 185, 174, 149, 118, 87, 60, 40, 25, 16, 10, 6, 4, 2, 1, 1, 1}; 85 | const uint8_t PROGMEM band7weights[] = {1, 2, 5, 10, 18, 30, 46, 67, 92, 118, 143, 164, 179, 185, 184, 174, 158, 139, 118, 97, 77, 60, 45, 34, 25, 18, 13, 9, 7, 5, 3, 2, 2, 1, 1, 1, 1}; 86 | const uint8_t PROGMEM * const bandWeights[] = {band0weights, band1weights, band2weights, band3weights, band4weights, band5weights, band6weights, band7weights}; 87 | 88 | 89 | void setup() { 90 | randomSeed(analogRead(1)); 91 | memset(bandPeakLevel, 0, sizeof(bandPeakLevel)); 92 | memset(band, 0, sizeof(band)); 93 | 94 | for (i = 0; i < N_BANDS; i++) { 95 | binNum = pgm_read_byte(&bandBinStarts[i]); 96 | nBins = pgm_read_byte(&bandBinCounts[i]); 97 | 98 | minLvlAvg[i] = 0; 99 | maxLvlAvg[i] = 512; 100 | data = (uint8_t *)pgm_read_word(&bandWeights[i]); 101 | for (bandDiv[i] = 0, j = 0; j < nBins; j++) { 102 | bandDiv[i] += pgm_read_byte(&data[j]); 103 | } 104 | } 105 | 106 | for (i = 0; i < N_PEAKS; i++) { 107 | peaks[i].age = 0; 108 | peaks[i].magnitude = 0; 109 | } 110 | if (SINGLE_DIRECTION) { 111 | MAX_AGE = N_LEDS + (N_LEDS / 4); 112 | } else { 113 | MAX_AGE = (N_LEDS / 2) + (N_LEDS / 8); 114 | } 115 | 116 | DIDR0 = 1 << ADC_CHANNEL; // Turn off digital input for ADC pin 117 | 118 | sei(); // Enable interrupts 119 | 120 | strip.begin(); 121 | strip.show(); // Initialize all pixels to 'off' 122 | 123 | TIMSK0 = 0; // Timer0 off 124 | startSampling(); 125 | 126 | #ifdef DEBUG 127 | Serial.begin(115200); 128 | Serial.println(getMemory()); 129 | #endif 130 | } 131 | 132 | void loop() { 133 | // While the ADC interrupt is enabled, wait. The program is still gathering 134 | // audio samples in the capture buffer. 135 | while (ADCSRA & _BV(ADIE)) { 136 | // wait... 137 | } 138 | 139 | // The sampling interrupt has finished filling the buffer, so show the 140 | // output we computed last time around the loop. This sends the data to 141 | // the LED strip. 142 | strip.show(); 143 | 144 | // Perform the FFT algorithm to convert samples to complex numbers. 145 | fft_input(capture, bfly_buff); 146 | 147 | // Now that we've updated the LED strip and processed the audio samples 148 | // with FFT, we can resume the collection of audio samples in the sample 149 | // buffer. The interrupt service routine (ISR) will run while we compute 150 | // the next LED output based on the audio samples we captured. 151 | startSampling(); 152 | 153 | // Perform the rest of the FFT computation: 154 | fft_execute(bfly_buff); // Process complex data 155 | fft_output(bfly_buff, spectrum); // Complex -> spectrum 156 | 157 | // Now call this to analyze the audio. See comments in this function 158 | // for details. 159 | analyzeAudioSamples(); 160 | 161 | // The peak values for each of the 8 bands has been computed. A bit 162 | // in the 8-bit value newPeakFlags indicates whether the analysis 163 | // found a *new* peak in the band. 164 | for (i = 0; i <= CUTOFF_BAND; i++) { 165 | 166 | // If a new peak was found in band i... 167 | if (newPeakFlags & (1 << i)) { 168 | // Map the peak value to a magnitude in range [0,255]. We pass 169 | // in the band number because the mapping is different for 170 | // different bands. 171 | uint8_t magnitude = getMagnitude(i, bandPeakLevel[i]); 172 | 173 | // A nonzero magnitude means that the peak value is large enough to do 174 | // something visually with it. We ignore small peaks. 175 | if (magnitude > 0) { 176 | // We want to store the information about the peak in a 177 | // peak_t structure. 178 | // When we actually draw a visualization, the peak_t structures 179 | // in peaks[] represent the "visually active" band peaks. 180 | 181 | // Look through the list of peak structures 'peaks' for an 182 | // unused one. 183 | for (j = 0; j < N_PEAKS; j++) { 184 | if (peaks[j].magnitude == 0) { 185 | // unused peak found 186 | peakIndex = j; 187 | break; 188 | } 189 | } 190 | // If an unused one not found, we use the last one that was 191 | // used (peakIndex). 192 | 193 | // Initialize the structure. 194 | peaks[peakIndex].age = 0; 195 | // a random component for a visualzation to use. For example, 196 | // to shift the color a small amount. 197 | peaks[peakIndex].rnd = random(255); 198 | peaks[peakIndex].baseColor = getRandomBaseColor(peaks[peakIndex].rnd); 199 | peaks[peakIndex].magnitude = magnitude; 200 | } 201 | } 202 | } 203 | 204 | // Clear the last frame. 205 | strip.clear(); 206 | 207 | // Draw the peaks on the LED strip. 208 | doVisualization(); 209 | } // end loop() 210 | 211 | void analyzeAudioSamples() { 212 | // The peaks in each band need to decay so that new peaks can happen later. 213 | // The value bandPeakDecay determines how fast they decay. Currently set to 6, 214 | // so every 6th time through the main loop, each band peak decays by 1. 215 | // If it decays too fast (original value was 3), then there are too many peaks 216 | // detected and display is messy. Too few and you'll miss some real audio peaks 217 | // that should be displayed. 218 | if (++bandPeakCounter >= bandPeakDecay) { 219 | bandPeakCounter = 0; 220 | for (i = 0; i <= CUTOFF_BAND; i++) { 221 | if (bandPeakLevel[i] > 0) { 222 | bandPeakLevel[i]--; 223 | } 224 | } 225 | } 226 | 227 | // Remove noise and apply EQ levels. This is from the Piccolo project. 228 | for (i = 0; i < FFT_N / 2; i++) { 229 | noiseThreshold = pgm_read_byte(&noiseFloor[i]); 230 | if (spectrum[i] < noiseThreshold) { 231 | spectrum[i] = 0; 232 | } else { 233 | spectrum[i] -= noiseThreshold; 234 | uint8_t eqVal = pgm_read_byte(&eq[i]); 235 | if (eqVal > 0) { 236 | spectrum[i] = ( ( spectrum[i] * (256L - eqVal)) >> 8); 237 | } 238 | } 239 | } 240 | 241 | // Downsample spectrum output to 8 bands. 242 | newPeakFlags = 0; 243 | for (i = 0; i <= CUTOFF_BAND; i++) { 244 | data = (uint8_t *)pgm_read_word(&bandWeights[i]); 245 | binNum = pgm_read_byte(&bandBinStarts[i]); 246 | nBins = pgm_read_byte(&bandBinCounts[i]); 247 | for (sum = 0, j = 0; j < nBins; j++) { 248 | sum += spectrum[binNum++] * pgm_read_byte(&data[j]); 249 | } 250 | band[i][bandCount] = sum / bandDiv[i]; 251 | minLvl = maxLvl = band[i][0]; 252 | for (j = 1; j < N_FRAMES; j++) { // Get range of prior frames 253 | if (band[i][j] < minLvl) minLvl = band[i][j]; 254 | else if (band[i][j] > maxLvl) maxLvl = band[i][j]; 255 | } 256 | if ((maxLvl - minLvl) < 8) maxLvl = minLvl + 8; 257 | minLvlAvg[i] = (minLvlAvg[i] * 7 + minLvl) >> 3; // Dampen min/max levels 258 | maxLvlAvg[i] = (maxLvlAvg[i] * 7 + maxLvl) >> 3; // (fake rolling average) 259 | 260 | // Second fixed-point scale based on dynamic min/max levels: 261 | level = 5L * (band[i][bandCount] - minLvlAvg[i]) / 262 | (long)(maxLvlAvg[i] - minLvlAvg[i]); 263 | 264 | if (level < 0L) c = 0; 265 | else if (level > 20) c = 20; 266 | else c = (uint8_t)level; 267 | 268 | if (c > bandPeakLevel[i]) { 269 | bandPeakLevel[i] = c; // New peak found for this frequency band. 270 | newPeakFlags = newPeakFlags | (1 << i); // set new peak flag for this band 271 | } 272 | } 273 | 274 | if (++bandCount >= N_FRAMES) bandCount = 0; 275 | 276 | } 277 | 278 | void doVisualization() { 279 | float ageScale, b; 280 | uint32_t color; 281 | uint8_t r; 282 | 283 | for (i = 0; i < N_PEAKS; i++) { 284 | if (peaks[i].magnitude > 0) { 285 | // peak is visually active 286 | 287 | // The age of the visual peak will be used to determine brightness. 288 | ageScale = (float)(1.0 - ((float)peaks[i].age / (float)MAX_AGE)); 289 | 290 | // If brightness has been altered by a parameter, scale everything further. 291 | // Get the right color for this peak's band and adjust the brightness. 292 | color = adjustBrightness(getColor(peaks[i].baseColor, peaks[i].rnd), ageScale * brightnessScale); 293 | 294 | // Calculate horizontal position relative to starting point. 295 | // The first term is a value from 0.0 to 1.0 indicating speed. 296 | // It is a function of the peak's magnitude. 297 | // Minimum speed is 0.5 (127.0 / 255.0). Maximum is 1.0 (255.0 / 255.0); 298 | // So speed is how many LEDs does it "move" every step. Multiply this by 299 | // the peak's age to get the position. 300 | uint8_t pos; 301 | if (peaks[i].magnitude > 150) { 302 | pos = peaks[i].age; 303 | } else { 304 | pos = ((127 + (peaks[i].magnitude / 2)) / 255.0) * peaks[i].age; 305 | } 306 | 307 | if (!SINGLE_DIRECTION) { 308 | // Draw one right of center and one left of center. 309 | strip.setPixelColor((N_LEDS / 2) + pos, color); 310 | strip.setPixelColor(((N_LEDS / 2) - 1) - pos, color); 311 | } else { 312 | // Draw pixel relative to 0 313 | strip.setPixelColor(pos, color); 314 | } 315 | 316 | // Increment age 317 | peaks[i].age++; 318 | 319 | // If too old, retire this peak, making it available again. 320 | if (peaks[i].age > MAX_AGE) { 321 | peaks[i].magnitude = 0; 322 | continue; 323 | } 324 | 325 | if ((pos >= ((N_LEDS / 2) - 1)) && (!SINGLE_DIRECTION)) { 326 | // Off the edge of the strip. This peak can now be returned to the pool 327 | // of peak structures that are available for use. 328 | peaks[i].magnitude = 0; 329 | } 330 | if ((pos >= (N_LEDS-1)) && (SINGLE_DIRECTION)) { 331 | // Off the edge of the strip. This peak can now be returned to the pool 332 | // of peak structures that are available for use. 333 | peaks[i].magnitude = 0; 334 | } 335 | } 336 | } 337 | } 338 | 339 | // Get a random color. There are 2 random colors that change over 340 | // time depending on MIN_COLOR_CHANGE_COUNT and MAX_COLOR_CHANGE_COUNT. 341 | // This gives a 2-color scheme that changes over time. 342 | uint8_t getRandomBaseColor(uint8_t r) { 343 | if ((r % 2) == 0) { 344 | if (randColorCount[0]-- == 0) { 345 | randColorCount[0] = random(MIN_COLOR_CHANGE_COUNT, MAX_COLOR_CHANGE_COUNT+1); 346 | randColor[0] = random(255); 347 | } 348 | return randColor[0]; 349 | } else { 350 | if (randColorCount[1]-- == 0) { 351 | randColorCount[1] = random(MIN_COLOR_CHANGE_COUNT, MAX_COLOR_CHANGE_COUNT+1); 352 | randColor[1] = random(255); 353 | } 354 | return randColor[1]; 355 | } 356 | 357 | } 358 | 359 | // Map a color index in range [0-255] to a color. 360 | // This is a uniform colorspace over 8 base colors: 361 | // [red, orange, yellow, green, cyan, blue, magenta, white] 362 | uint32_t getColor(uint8_t index, uint8_t rnd) { 363 | byte r, g, b; 364 | 365 | index += (rnd >> 5); // introduce random variation in the color. 366 | byte f = (index % 32) * 8; // fractional part of color component 367 | switch (index / 32) { 368 | case 0: // red 369 | r = 255; 370 | g = f >> 1; 371 | b = 0; 372 | break; 373 | case 1: // orange 374 | r = 255; 375 | g = 127 + (f >> 1); 376 | b = 0; 377 | break; 378 | case 2: // yellow 379 | r = 255 - f; 380 | g = 255; 381 | b = 0; 382 | break; 383 | case 3: // green 384 | r = 0; 385 | g = 255; 386 | b = f; 387 | break; 388 | case 4: // cyan 389 | r = 0; 390 | g = 255 - f; 391 | b = 255; 392 | break; 393 | case 5: // blue 394 | r = f; 395 | g = 0; 396 | b = 255; 397 | break; 398 | case 6: // magenta 399 | r = 255 - f / 2; 400 | g = f / 2; 401 | b = 255 - f / 2; 402 | break; 403 | case 7: // white 404 | r = 127 + f / 2; 405 | g = 127 - f / 2; 406 | b = 127 - f / 2; 407 | break; 408 | } 409 | 410 | if (MAX_BRIGHTNESS < 255) { 411 | // scale by brightnessScale; 412 | // optimize for 255 and 0 cases to avoid floating point multiply 413 | if (r == 255) { 414 | r = MAX_BRIGHTNESS; 415 | } else { 416 | if (r > 0) { 417 | r = ((float)r * brightnessScale); 418 | } 419 | } 420 | if (g == 255) { 421 | g = MAX_BRIGHTNESS; 422 | } else { 423 | if (g > 0) { 424 | g = ((float)g * brightnessScale); 425 | } 426 | } 427 | if (b == 255) { 428 | b = MAX_BRIGHTNESS; 429 | } else { 430 | if (b > 0) { 431 | b = ((float)b * brightnessScale); 432 | } 433 | } 434 | } 435 | return strip.Color(r, g, b); 436 | } 437 | 438 | 439 | // Map the band peak level to a magnitude in range [0,255]. 440 | // This mapping depends on band number because different bands have different 441 | // characteristics. 442 | uint8_t getMagnitude(uint8_t band, uint8_t peakValue) { 443 | uint8_t peakMin, peakMax; 444 | switch (band) { 445 | case 0: 446 | // bass bands are really strong, so don't show anything with peak value 447 | // smaller than 8. They can have high values, so anything bigger than 20 is 448 | // maximum magnitude. 449 | peakMin = 8; 450 | peakMax = 20; 451 | break; 452 | case 1: 453 | peakMin = 8; 454 | peakMax = 20; 455 | break; 456 | case 2: // fall through... 457 | case 3: 458 | case 4: 459 | case 5: 460 | // These middle bands need a little more sensitivity, so allow values as low 461 | // as 4 to be represented visually. 462 | // These bands never go that high, so let's say that value of 8 is the high end. 463 | peakMin = 4; 464 | peakMax = 8; 465 | break; 466 | case 6: 467 | case 7: 468 | // High bands are not so sensitive and go a bit higher in practice. 469 | peakMin = 6; 470 | peakMax = 12; 471 | break; 472 | } 473 | 474 | // If below min, then return 0 so we don't do anything visually. 475 | if (peakValue < peakMin) { 476 | return 0; 477 | } 478 | // Constrain to range [peakMin,peakMax] 479 | peakValue = constrain(peakValue, peakMin, peakMax); 480 | 481 | // Map to range [1,255] for all bands. 482 | return map(peakValue, peakMin, peakMax, 1, 255); 483 | } 484 | 485 | 486 | // Configure the ADC to be free-running. It samples constantly and calls the ISR when 487 | // a new conversion is ready to be recorded. 488 | void startSampling() { 489 | samplePos = 0; // Reset sample counter 490 | // Init ADC free-run mode; f = ( 16MHz/prescaler ) / 13 cycles/conversion 491 | ADMUX = ADC_CHANNEL; // Channel sel, right-adj, use AREF pin 492 | // Start a conversion. We want to discard the first conversion after 493 | // changing the voltage reference reference. 494 | ADCSRB = 0; 495 | ADCSRA = _BV(ADEN) | // ADC enable 496 | _BV(ADSC); // ADC start 497 | 498 | // Wait until conversion finishes. 499 | while (ADCSRA & _BV(ADSC)); 500 | 501 | // Now start auto-triggered conversions with interrupt enabled. 502 | ADCSRA = _BV(ADEN) | // ADC enable 503 | _BV(ADSC) | // ADC start 504 | _BV(ADATE) | // Auto trigger 505 | _BV(ADIE) | // Interrupt enable 506 | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); // 128:1 / 13 = 9615 Hz 507 | } 508 | 509 | 510 | // Audio-sampling interrupt. This is invoked automatically whenever an ADC 511 | // conversion is ready. 512 | ISR(ADC_vect) { 513 | static const int16_t noiseThreshold = 4; // ignore small voltage variations. 514 | 515 | // the sample is available in the ADC register 516 | int16_t sample = ADC; // 0-1023 517 | 518 | capture[samplePos] = 519 | ((sample > (512 - noiseThreshold)) && 520 | (sample < (512 + noiseThreshold))) ? 0 : 521 | sample - 512; // Sign-convert for FFT; -512 to +511 522 | 523 | if (++samplePos >= FFT_N) { 524 | // The sample buffer is full, so disable the interrupt 525 | ADCSRA &= ~_BV(ADIE); 526 | } 527 | } 528 | 529 | // Scale brightness of a color. 530 | uint32_t adjustBrightness(uint32_t c, float amt) { 531 | 532 | // pull the R,G,B components out of the 32bit color value 533 | uint8_t r = (uint8_t)(c >> 16); 534 | uint8_t g = (uint8_t)(c >> 8); 535 | uint8_t b = (uint8_t)c; 536 | 537 | // Scale 538 | r = r * amt; 539 | g = g * amt; 540 | b = b * amt; 541 | 542 | // Pack them into a 32bit color value again. 543 | return strip.Color(r, g, b); 544 | } 545 | 546 | -------------------------------------------------------------------------------- /libraries/ffft/ffft.S: -------------------------------------------------------------------------------- 1 | ;-----------------------------------------------------------------------------; 2 | ; Fixed-point FFT routines for megaAVRs (C)ChaN, 2005 3 | ;-----------------------------------------------------------------------------; 4 | ; * This program is opened under license policy of following trems. 5 | ; 6 | ; Copyright (C) 2005, ChaN, all right reserved. 7 | ; 8 | ; * This program is a free software and there is NO WARRANTY. 9 | ; * No restriction on use. You can use, modify and redistribute it for 10 | ; personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. 11 | ; * Redistributions of source code must retain the above copyright notice. 12 | ; 13 | ;-----------------------------------------------------------------------------; 14 | ; 15 | ; void fft_input (const int16_t *array_src, complex_t *array_bfly); 16 | ; void fft_execute (complex_t *array_bfly); 17 | ; void fft_output (complex_t *array_bfly, uint16_t *array_dst); 18 | ; 19 | ; : Wave form to be processed. 20 | ; : Complex array for butterfly operations. 21 | ; : Spectrum output buffer. 22 | ; 23 | ; These functions must be called in sequence to do a DFT in FFT algorithm. 24 | ; fft_input() fills the complex array with a wave form to prepare butterfly 25 | ; operations. A hamming window is applied at the same time. 26 | ; fft_execute() executes the butterfly operations. 27 | ; fft_output() re-orders the results, converts the complex spectrum into 28 | ; scalar spectrum and output it in linear scale. 29 | ; 30 | ; The number of points FFT_N is defined in "ffft.h" and the value can be 31 | ; power of 2 in range of 64 - 1024. 32 | ; 33 | ;----------------------------------------------------------------------------; 34 | ; 16bit fixed-point FFT performance with MegaAVRs 35 | ; (Running at 16MHz/internal SRAM) 36 | ; 37 | ; Points: Input, Execute, Output, Total: Throughput 38 | ; 64pts: .17ms, 2.0ms, 1.2ms, 3.4ms: 19.0kpps 39 | ; 128pts: .33ms, 4.6ms, 2.4ms, 7.3ms: 17.5kpps 40 | ; 256pts: .66ms, 10.4ms, 4.9ms, 15.9ms: 16.1kpps 41 | ; 512pts: 1.3ms, 23.2ms, 9.7ms, 34.2ms: 14.9kpps 42 | ; 1024pts: 2.7ms, 51.7ms, 19.4ms, 73.7ms: 13.9kpps 43 | ;----------------------------------------------------------------------------; 44 | 45 | 46 | .nolist 47 | #define FFFT_ASM 48 | #include "ffft.h" 49 | .list 50 | 51 | #if FFT_N == 1024 52 | #define FFT_B 10 53 | #elif FFT_N == 512 54 | #define FFT_B 9 55 | #elif FFT_N == 256 56 | #define FFT_B 8 57 | #elif FFT_N == 128 58 | #define FFT_B 7 59 | #elif FFT_N == 64 60 | #define FFT_B 6 61 | #else 62 | #error Wrong setting of FFT_N. 63 | #endif 64 | 65 | 66 | ;----------------------------------------------------------------------------; 67 | ; Constant Tables 68 | 69 | .global tbl_window 70 | tbl_window: ; tbl_window[] = ... (This is a Hamming window) 71 | #if FFT_N == 1024 72 | .dc.w 2621, 2621, 2622, 2623, 2625, 2628, 2631, 2635, 2639, 2644, 2649, 2655, 2662, 2669, 2676, 2685 73 | .dc.w 2693, 2703, 2713, 2723, 2734, 2746, 2758, 2771, 2784, 2798, 2812, 2827, 2843, 2859, 2876, 2893 74 | .dc.w 2910, 2929, 2948, 2967, 2987, 3008, 3029, 3050, 3073, 3095, 3119, 3142, 3167, 3192, 3217, 3243 75 | .dc.w 3270, 3297, 3325, 3353, 3382, 3411, 3441, 3471, 3502, 3533, 3565, 3598, 3631, 3664, 3698, 3733 76 | .dc.w 3768, 3804, 3840, 3877, 3914, 3952, 3990, 4029, 4068, 4108, 4148, 4189, 4230, 4272, 4314, 4357 77 | .dc.w 4401, 4444, 4489, 4534, 4579, 4625, 4671, 4718, 4765, 4813, 4861, 4910, 4959, 5009, 5059, 5110 78 | .dc.w 5161, 5213, 5265, 5317, 5370, 5424, 5478, 5532, 5587, 5642, 5698, 5754, 5811, 5868, 5926, 5984 79 | .dc.w 6042, 6101, 6160, 6220, 6280, 6341, 6402, 6464, 6525, 6588, 6651, 6714, 6777, 6841, 6906, 6970 80 | .dc.w 7036, 7101, 7167, 7234, 7300, 7368, 7435, 7503, 7571, 7640, 7709, 7779, 7849, 7919, 7989, 8060 81 | .dc.w 8132, 8203, 8275, 8348, 8420, 8493, 8567, 8641, 8715, 8789, 8864, 8939, 9015, 9090, 9166, 9243 82 | .dc.w 9320, 9397, 9474, 9552, 9630, 9708, 9787, 9866, 9945, 10024, 10104, 10184, 10264, 10345, 10426, 10507 83 | .dc.w 10588, 10670, 10752, 10834, 10917, 10999, 11082, 11166, 11249, 11333, 11417, 11501, 11586, 11670, 11755, 11840 84 | .dc.w 11926, 12011, 12097, 12183, 12269, 12355, 12442, 12529, 12616, 12703, 12790, 12878, 12966, 13054, 13142, 13230 85 | .dc.w 13318, 13407, 13496, 13584, 13674, 13763, 13852, 13942, 14031, 14121, 14211, 14301, 14391, 14481, 14572, 14662 86 | .dc.w 14753, 14844, 14935, 15026, 15117, 15208, 15299, 15391, 15482, 15574, 15665, 15757, 15849, 15940, 16032, 16124 87 | .dc.w 16216, 16308, 16400, 16493, 16585, 16677, 16769, 16862, 16954, 17046, 17139, 17231, 17324, 17416, 17509, 17601 88 | .dc.w 17694, 17786, 17879, 17971, 18064, 18156, 18248, 18341, 18433, 18526, 18618, 18710, 18802, 18895, 18987, 19079 89 | .dc.w 19171, 19263, 19355, 19447, 19539, 19630, 19722, 19814, 19905, 19997, 20088, 20179, 20271, 20362, 20453, 20543 90 | .dc.w 20634, 20725, 20815, 20906, 20996, 21086, 21176, 21266, 21356, 21446, 21535, 21625, 21714, 21803, 21892, 21980 91 | .dc.w 22069, 22157, 22246, 22334, 22422, 22509, 22597, 22684, 22772, 22859, 22945, 23032, 23118, 23204, 23290, 23376 92 | .dc.w 23462, 23547, 23632, 23717, 23802, 23886, 23970, 24054, 24138, 24222, 24305, 24388, 24471, 24553, 24635, 24717 93 | .dc.w 24799, 24880, 24962, 25042, 25123, 25203, 25283, 25363, 25443, 25522, 25601, 25679, 25758, 25836, 25913, 25991 94 | .dc.w 26068, 26144, 26221, 26297, 26373, 26448, 26523, 26598, 26673, 26747, 26820, 26894, 26967, 27040, 27112, 27184 95 | .dc.w 27256, 27327, 27398, 27469, 27539, 27609, 27678, 27747, 27816, 27884, 27952, 28020, 28087, 28154, 28220, 28286 96 | .dc.w 28352, 28417, 28482, 28546, 28610, 28674, 28737, 28800, 28862, 28924, 28985, 29046, 29107, 29167, 29227, 29286 97 | .dc.w 29345, 29404, 29462, 29519, 29576, 29633, 29689, 29745, 29800, 29855, 29910, 29963, 30017, 30070, 30123, 30175 98 | .dc.w 30226, 30277, 30328, 30378, 30428, 30477, 30526, 30574, 30622, 30669, 30716, 30762, 30808, 30854, 30899, 30943 99 | .dc.w 30987, 31030, 31073, 31115, 31157, 31198, 31239, 31280, 31319, 31359, 31397, 31436, 31473, 31511, 31547, 31583 100 | .dc.w 31619, 31654, 31689, 31723, 31756, 31790, 31822, 31854, 31885, 31916, 31947, 31976, 32006, 32034, 32063, 32090 101 | .dc.w 32117, 32144, 32170, 32196, 32220, 32245, 32269, 32292, 32315, 32337, 32359, 32380, 32400, 32420, 32440, 32459 102 | .dc.w 32477, 32495, 32512, 32528, 32545, 32560, 32575, 32590, 32603, 32617, 32629, 32642, 32653, 32664, 32675, 32685 103 | .dc.w 32694, 32703, 32711, 32719, 32726, 32732, 32738, 32744, 32748, 32753, 32756, 32759, 32762, 32764, 32765, 32766 104 | .dc.w 32766, 32766, 32765, 32764, 32762, 32759, 32756, 32753, 32748, 32744, 32738, 32732, 32726, 32719, 32711, 32703 105 | .dc.w 32694, 32685, 32675, 32664, 32653, 32642, 32629, 32617, 32603, 32590, 32575, 32560, 32545, 32529, 32512, 32495 106 | .dc.w 32477, 32459, 32440, 32420, 32400, 32380, 32359, 32337, 32315, 32292, 32269, 32245, 32221, 32196, 32170, 32144 107 | .dc.w 32117, 32090, 32063, 32035, 32006, 31976, 31947, 31916, 31885, 31854, 31822, 31790, 31757, 31723, 31689, 31654 108 | .dc.w 31619, 31584, 31547, 31511, 31473, 31436, 31397, 31359, 31319, 31280, 31239, 31198, 31157, 31115, 31073, 31030 109 | .dc.w 30987, 30943, 30899, 30854, 30808, 30763, 30716, 30669, 30622, 30574, 30526, 30477, 30428, 30378, 30328, 30277 110 | .dc.w 30226, 30175, 30123, 30070, 30017, 29964, 29910, 29855, 29800, 29745, 29689, 29633, 29576, 29519, 29462, 29404 111 | .dc.w 29345, 29286, 29227, 29167, 29107, 29046, 28985, 28924, 28862, 28800, 28737, 28674, 28610, 28546, 28482, 28417 112 | .dc.w 28352, 28286, 28220, 28154, 28087, 28020, 27952, 27884, 27816, 27747, 27678, 27609, 27539, 27469, 27398, 27327 113 | .dc.w 27256, 27184, 27112, 27040, 26967, 26894, 26820, 26747, 26673, 26598, 26523, 26448, 26373, 26297, 26221, 26144 114 | .dc.w 26068, 25991, 25913, 25836, 25758, 25679, 25601, 25522, 25443, 25363, 25283, 25203, 25123, 25042, 24962, 24880 115 | .dc.w 24799, 24717, 24635, 24553, 24471, 24388, 24305, 24222, 24138, 24054, 23970, 23886, 23802, 23717, 23632, 23547 116 | .dc.w 23462, 23376, 23291, 23205, 23118, 23032, 22945, 22859, 22772, 22684, 22597, 22510, 22422, 22334, 22246, 22158 117 | .dc.w 22069, 21981, 21892, 21803, 21714, 21625, 21535, 21446, 21356, 21266, 21176, 21086, 20996, 20906, 20815, 20725 118 | .dc.w 20634, 20544, 20453, 20362, 20271, 20179, 20088, 19997, 19905, 19814, 19722, 19631, 19539, 19447, 19355, 19263 119 | .dc.w 19171, 19079, 18987, 18895, 18803, 18710, 18618, 18526, 18433, 18341, 18249, 18156, 18064, 17971, 17879, 17786 120 | .dc.w 17694, 17601, 17509, 17416, 17324, 17231, 17139, 17047, 16954, 16862, 16769, 16677, 16585, 16493, 16401, 16308 121 | .dc.w 16216, 16124, 16032, 15940, 15849, 15757, 15665, 15574, 15482, 15391, 15299, 15208, 15117, 15026, 14935, 14844 122 | .dc.w 14753, 14663, 14572, 14482, 14391, 14301, 14211, 14121, 14031, 13942, 13852, 13763, 13674, 13585, 13496, 13407 123 | .dc.w 13318, 13230, 13142, 13054, 12966, 12878, 12790, 12703, 12616, 12529, 12442, 12355, 12269, 12183, 12097, 12011 124 | .dc.w 11926, 11840, 11755, 11670, 11586, 11501, 11417, 11333, 11249, 11166, 11083, 11000, 10917, 10834, 10752, 10670 125 | .dc.w 10588, 10507, 10426, 10345, 10264, 10184, 10104, 10024, 9945, 9866, 9787, 9708, 9630, 9552, 9474, 9397 126 | .dc.w 9320, 9243, 9167, 9090, 9015, 8939, 8864, 8789, 8715, 8641, 8567, 8494, 8420, 8348, 8275, 8203 127 | .dc.w 8132, 8060, 7989, 7919, 7849, 7779, 7709, 7640, 7571, 7503, 7435, 7368, 7300, 7234, 7167, 7101 128 | .dc.w 7036, 6970, 6906, 6841, 6777, 6714, 6651, 6588, 6526, 6464, 6402, 6341, 6280, 6220, 6160, 6101 129 | .dc.w 6042, 5984, 5926, 5868, 5811, 5754, 5698, 5642, 5587, 5532, 5478, 5424, 5370, 5317, 5265, 5213 130 | .dc.w 5161, 5110, 5059, 5009, 4959, 4910, 4861, 4813, 4765, 4718, 4671, 4625, 4579, 4534, 4489, 4445 131 | .dc.w 4401, 4357, 4314, 4272, 4230, 4189, 4148, 4108, 4068, 4029, 3990, 3952, 3914, 3877, 3840, 3804 132 | .dc.w 3768, 3733, 3699, 3664, 3631, 3598, 3565, 3533, 3502, 3471, 3441, 3411, 3382, 3353, 3325, 3297 133 | .dc.w 3270, 3243, 3217, 3192, 3167, 3142, 3119, 3095, 3073, 3050, 3029, 3008, 2987, 2967, 2948, 2929 134 | .dc.w 2910, 2893, 2876, 2859, 2843, 2827, 2812, 2798, 2784, 2771, 2758, 2746, 2734, 2723, 2713, 2703 135 | .dc.w 2693, 2685, 2676, 2669, 2662, 2655, 2649, 2644, 2639, 2635, 2631, 2628, 2625, 2623, 2622, 2621 136 | 137 | #elif FFT_N == 512 138 | .dc.w 2621, 2622, 2625, 2631, 2639, 2649, 2662, 2676, 2693, 2713, 2734, 2758, 2784, 2812, 2843, 2876 139 | .dc.w 2910, 2948, 2987, 3029, 3073, 3119, 3167, 3217, 3270, 3325, 3382, 3441, 3502, 3565, 3631, 3698 140 | .dc.w 3768, 3840, 3914, 3990, 4068, 4148, 4230, 4314, 4401, 4489, 4579, 4671, 4765, 4861, 4959, 5059 141 | .dc.w 5161, 5265, 5370, 5478, 5587, 5698, 5811, 5926, 6042, 6160, 6280, 6402, 6525, 6651, 6777, 6906 142 | .dc.w 7036, 7167, 7300, 7435, 7571, 7709, 7849, 7989, 8132, 8275, 8420, 8567, 8715, 8864, 9015, 9166 143 | .dc.w 9320, 9474, 9630, 9787, 9945, 10104, 10264, 10426, 10588, 10752, 10917, 11082, 11249, 11417, 11586, 11755 144 | .dc.w 11926, 12097, 12269, 12442, 12616, 12790, 12966, 13142, 13318, 13496, 13674, 13852, 14031, 14211, 14391, 14572 145 | .dc.w 14753, 14935, 15117, 15299, 15482, 15665, 15849, 16032, 16216, 16400, 16585, 16769, 16954, 17139, 17324, 17509 146 | .dc.w 17694, 17879, 18064, 18248, 18433, 18618, 18802, 18987, 19171, 19355, 19539, 19722, 19905, 20088, 20271, 20453 147 | .dc.w 20634, 20815, 20996, 21176, 21356, 21535, 21714, 21892, 22069, 22246, 22422, 22597, 22772, 22945, 23118, 23290 148 | .dc.w 23462, 23632, 23802, 23970, 24138, 24305, 24471, 24635, 24799, 24962, 25123, 25283, 25443, 25601, 25758, 25913 149 | .dc.w 26068, 26221, 26373, 26523, 26673, 26820, 26967, 27112, 27256, 27398, 27539, 27678, 27816, 27952, 28087, 28220 150 | .dc.w 28352, 28482, 28610, 28737, 28862, 28985, 29107, 29227, 29345, 29462, 29576, 29689, 29800, 29910, 30017, 30123 151 | .dc.w 30226, 30328, 30428, 30526, 30622, 30716, 30808, 30899, 30987, 31073, 31157, 31239, 31319, 31397, 31473, 31547 152 | .dc.w 31619, 31689, 31756, 31822, 31885, 31947, 32006, 32063, 32117, 32170, 32220, 32269, 32315, 32359, 32400, 32440 153 | .dc.w 32477, 32512, 32545, 32575, 32603, 32629, 32653, 32675, 32694, 32711, 32726, 32738, 32748, 32756, 32762, 32765 154 | .dc.w 32766, 32765, 32762, 32756, 32748, 32738, 32726, 32711, 32694, 32675, 32653, 32629, 32603, 32575, 32545, 32512 155 | .dc.w 32477, 32440, 32400, 32359, 32315, 32269, 32221, 32170, 32117, 32063, 32006, 31947, 31885, 31822, 31757, 31689 156 | .dc.w 31619, 31547, 31473, 31397, 31319, 31239, 31157, 31073, 30987, 30899, 30808, 30716, 30622, 30526, 30428, 30328 157 | .dc.w 30226, 30123, 30017, 29910, 29800, 29689, 29576, 29462, 29345, 29227, 29107, 28985, 28862, 28737, 28610, 28482 158 | .dc.w 28352, 28220, 28087, 27952, 27816, 27678, 27539, 27398, 27256, 27112, 26967, 26820, 26673, 26523, 26373, 26221 159 | .dc.w 26068, 25913, 25758, 25601, 25443, 25283, 25123, 24962, 24799, 24635, 24471, 24305, 24138, 23970, 23802, 23632 160 | .dc.w 23462, 23291, 23118, 22945, 22772, 22597, 22422, 22246, 22069, 21892, 21714, 21535, 21356, 21176, 20996, 20815 161 | .dc.w 20634, 20453, 20271, 20088, 19905, 19722, 19539, 19355, 19171, 18987, 18803, 18618, 18433, 18249, 18064, 17879 162 | .dc.w 17694, 17509, 17324, 17139, 16954, 16769, 16585, 16401, 16216, 16032, 15849, 15665, 15482, 15299, 15117, 14935 163 | .dc.w 14753, 14572, 14391, 14211, 14031, 13852, 13674, 13496, 13318, 13142, 12966, 12790, 12616, 12442, 12269, 12097 164 | .dc.w 11926, 11755, 11586, 11417, 11249, 11083, 10917, 10752, 10588, 10426, 10264, 10104, 9945, 9787, 9630, 9474 165 | .dc.w 9320, 9167, 9015, 8864, 8715, 8567, 8420, 8275, 8132, 7989, 7849, 7709, 7571, 7435, 7300, 7167 166 | .dc.w 7036, 6906, 6777, 6651, 6526, 6402, 6280, 6160, 6042, 5926, 5811, 5698, 5587, 5478, 5370, 5265 167 | .dc.w 5161, 5059, 4959, 4861, 4765, 4671, 4579, 4489, 4401, 4314, 4230, 4148, 4068, 3990, 3914, 3840 168 | .dc.w 3768, 3699, 3631, 3565, 3502, 3441, 3382, 3325, 3270, 3217, 3167, 3119, 3073, 3029, 2987, 2948 169 | .dc.w 2910, 2876, 2843, 2812, 2784, 2758, 2734, 2713, 2693, 2676, 2662, 2649, 2639, 2631, 2625, 2622 170 | 171 | #elif FFT_N == 256 172 | .dc.w 2621, 2625, 2639, 2662, 2693, 2734, 2784, 2843, 2910, 2987, 3073, 3167, 3270, 3382, 3502, 3631 173 | .dc.w 3768, 3914, 4068, 4230, 4401, 4579, 4765, 4959, 5161, 5370, 5587, 5811, 6042, 6280, 6525, 6777 174 | .dc.w 7036, 7300, 7571, 7849, 8132, 8420, 8715, 9015, 9320, 9630, 9945, 10264, 10588, 10917, 11249, 11586 175 | .dc.w 11926, 12269, 12616, 12966, 13318, 13674, 14031, 14391, 14753, 15117, 15482, 15849, 16216, 16585, 16954, 17324 176 | .dc.w 17694, 18064, 18433, 18802, 19171, 19539, 19905, 20271, 20634, 20996, 21356, 21714, 22069, 22422, 22772, 23118 177 | .dc.w 23462, 23802, 24138, 24471, 24799, 25123, 25443, 25758, 26068, 26373, 26673, 26967, 27256, 27539, 27816, 28087 178 | .dc.w 28352, 28610, 28862, 29107, 29345, 29576, 29800, 30017, 30226, 30428, 30622, 30808, 30987, 31157, 31319, 31473 179 | .dc.w 31619, 31756, 31885, 32006, 32117, 32220, 32315, 32400, 32477, 32545, 32603, 32653, 32694, 32726, 32748, 32762 180 | .dc.w 32766, 32762, 32748, 32726, 32694, 32653, 32603, 32545, 32477, 32400, 32315, 32221, 32117, 32006, 31885, 31757 181 | .dc.w 31619, 31473, 31319, 31157, 30987, 30808, 30622, 30428, 30226, 30017, 29800, 29576, 29345, 29107, 28862, 28610 182 | .dc.w 28352, 28087, 27816, 27539, 27256, 26967, 26673, 26373, 26068, 25758, 25443, 25123, 24799, 24471, 24138, 23802 183 | .dc.w 23462, 23118, 22772, 22422, 22069, 21714, 21356, 20996, 20634, 20271, 19905, 19539, 19171, 18803, 18433, 18064 184 | .dc.w 17694, 17324, 16954, 16585, 16216, 15849, 15482, 15117, 14753, 14391, 14031, 13674, 13318, 12966, 12616, 12269 185 | .dc.w 11926, 11586, 11249, 10917, 10588, 10264, 9945, 9630, 9320, 9015, 8715, 8420, 8132, 7849, 7571, 7300 186 | .dc.w 7036, 6777, 6526, 6280, 6042, 5811, 5587, 5370, 5161, 4959, 4765, 4579, 4401, 4230, 4068, 3914 187 | .dc.w 3768, 3631, 3502, 3382, 3270, 3167, 3073, 2987, 2910, 2843, 2784, 2734, 2693, 2662, 2639, 2625 188 | 189 | #elif FFT_N == 128 190 | .dc.w 2621, 2639, 2693, 2784, 2910, 3073, 3270, 3502, 3768, 4068, 4401, 4765, 5161, 5587, 6042, 6525 191 | .dc.w 7036, 7571, 8132, 8715, 9320, 9945, 10588, 11249, 11926, 12616, 13318, 14031, 14753, 15482, 16216, 16954 192 | .dc.w 17694, 18433, 19171, 19905, 20634, 21356, 22069, 22772, 23462, 24138, 24799, 25443, 26068, 26673, 27256, 27816 193 | .dc.w 28352, 28862, 29345, 29800, 30226, 30622, 30987, 31319, 31619, 31885, 32117, 32315, 32477, 32603, 32694, 32748 194 | .dc.w 32766, 32748, 32694, 32603, 32477, 32315, 32117, 31885, 31619, 31319, 30987, 30622, 30226, 29800, 29345, 28862 195 | .dc.w 28352, 27816, 27256, 26673, 26068, 25443, 24799, 24138, 23462, 22772, 22069, 21356, 20634, 19905, 19171, 18433 196 | .dc.w 17694, 16954, 16216, 15482, 14753, 14031, 13318, 12616, 11926, 11249, 10588, 9945, 9320, 8715, 8132, 7571 197 | .dc.w 7036, 6526, 6042, 5587, 5161, 4765, 4401, 4068, 3768, 3502, 3270, 3073, 2910, 2784, 2693, 2639 198 | 199 | #elif FFT_N == 64 200 | .dc.w 2621, 2693, 2910, 3270, 3768, 4401, 5161, 6042, 7036, 8132, 9320, 10588, 11926, 13318, 14753, 16216 201 | .dc.w 17694, 19171, 20634, 22069, 23462, 24799, 26068, 27256, 28352, 29345, 30226, 30987, 31619, 32117, 32477, 32694 202 | .dc.w 32766, 32694, 32477, 32117, 31619, 30987, 30226, 29345, 28352, 27256, 26068, 24799, 23462, 22069, 20634, 19171 203 | .dc.w 17694, 16216, 14753, 13318, 11926, 10588, 9320, 8132, 7036, 6042, 5161, 4401, 3768, 3270, 2910, 2693 204 | #endif 205 | 206 | 207 | tbl_cos_sin: ; Table of {cos(x),sin(x)}, (0 <= x < pi, in FFT_N/2 steps) 208 | #if FFT_N == 1024 209 | .dc.w 32767, 0, 32766, 201, 32764, 402, 32761, 603, 32757, 804, 32751, 1005, 32744, 1206, 32736, 1406 210 | .dc.w 32727, 1607, 32717, 1808, 32705, 2009, 32692, 2209, 32678, 2410, 32662, 2610, 32646, 2811, 32628, 3011 211 | .dc.w 32609, 3211, 32588, 3411, 32567, 3611, 32544, 3811, 32520, 4011, 32495, 4210, 32468, 4409, 32441, 4608 212 | .dc.w 32412, 4807, 32382, 5006, 32350, 5205, 32318, 5403, 32284, 5601, 32249, 5799, 32213, 5997, 32176, 6195 213 | .dc.w 32137, 6392, 32097, 6589, 32056, 6786, 32014, 6982, 31970, 7179, 31926, 7375, 31880, 7571, 31833, 7766 214 | .dc.w 31785, 7961, 31735, 8156, 31684, 8351, 31633, 8545, 31580, 8739, 31525, 8932, 31470, 9126, 31413, 9319 215 | .dc.w 31356, 9511, 31297, 9703, 31236, 9895, 31175, 10087, 31113, 10278, 31049, 10469, 30984, 10659, 30918, 10849 216 | .dc.w 30851, 11038, 30783, 11227, 30713, 11416, 30643, 11604, 30571, 11792, 30498, 11980, 30424, 12166, 30349, 12353 217 | .dc.w 30272, 12539, 30195, 12724, 30116, 12909, 30036, 13094, 29955, 13278, 29873, 13462, 29790, 13645, 29706, 13827 218 | .dc.w 29621, 14009, 29534, 14191, 29446, 14372, 29358, 14552, 29268, 14732, 29177, 14911, 29085, 15090, 28992, 15268 219 | .dc.w 28897, 15446, 28802, 15623, 28706, 15799, 28608, 15975, 28510, 16150, 28410, 16325, 28309, 16499, 28208, 16672 220 | .dc.w 28105, 16845, 28001, 17017, 27896, 17189, 27790, 17360, 27683, 17530, 27575, 17699, 27466, 17868, 27355, 18036 221 | .dc.w 27244, 18204, 27132, 18371, 27019, 18537, 26905, 18702, 26789, 18867, 26673, 19031, 26556, 19194, 26437, 19357 222 | .dc.w 26318, 19519, 26198, 19680, 26077, 19840, 25954, 20000, 25831, 20159, 25707, 20317, 25582, 20474, 25456, 20631 223 | .dc.w 25329, 20787, 25201, 20942, 25072, 21096, 24942, 21249, 24811, 21402, 24679, 21554, 24546, 21705, 24413, 21855 224 | .dc.w 24278, 22004, 24143, 22153, 24006, 22301, 23869, 22448, 23731, 22594, 23592, 22739, 23452, 22883, 23311, 23027 225 | .dc.w 23169, 23169, 23027, 23311, 22883, 23452, 22739, 23592, 22594, 23731, 22448, 23869, 22301, 24006, 22153, 24143 226 | .dc.w 22004, 24278, 21855, 24413, 21705, 24546, 21554, 24679, 21402, 24811, 21249, 24942, 21096, 25072, 20942, 25201 227 | .dc.w 20787, 25329, 20631, 25456, 20474, 25582, 20317, 25707, 20159, 25831, 20000, 25954, 19840, 26077, 19680, 26198 228 | .dc.w 19519, 26318, 19357, 26437, 19194, 26556, 19031, 26673, 18867, 26789, 18702, 26905, 18537, 27019, 18371, 27132 229 | .dc.w 18204, 27244, 18036, 27355, 17868, 27466, 17699, 27575, 17530, 27683, 17360, 27790, 17189, 27896, 17017, 28001 230 | .dc.w 16845, 28105, 16672, 28208, 16499, 28309, 16325, 28410, 16150, 28510, 15975, 28608, 15799, 28706, 15623, 28802 231 | .dc.w 15446, 28897, 15268, 28992, 15090, 29085, 14911, 29177, 14732, 29268, 14552, 29358, 14372, 29446, 14191, 29534 232 | .dc.w 14009, 29621, 13827, 29706, 13645, 29790, 13462, 29873, 13278, 29955, 13094, 30036, 12909, 30116, 12724, 30195 233 | .dc.w 12539, 30272, 12353, 30349, 12166, 30424, 11980, 30498, 11792, 30571, 11604, 30643, 11416, 30713, 11227, 30783 234 | .dc.w 11038, 30851, 10849, 30918, 10659, 30984, 10469, 31049, 10278, 31113, 10087, 31175, 9895, 31236, 9704, 31297 235 | .dc.w 9511, 31356, 9319, 31413, 9126, 31470, 8933, 31525, 8739, 31580, 8545, 31633, 8351, 31684, 8156, 31735 236 | .dc.w 7961, 31785, 7766, 31833, 7571, 31880, 7375, 31926, 7179, 31970, 6983, 32014, 6786, 32056, 6589, 32097 237 | .dc.w 6392, 32137, 6195, 32176, 5997, 32213, 5799, 32249, 5601, 32284, 5403, 32318, 5205, 32350, 5006, 32382 238 | .dc.w 4807, 32412, 4608, 32441, 4409, 32468, 4210, 32495, 4011, 32520, 3811, 32544, 3611, 32567, 3411, 32588 239 | .dc.w 3211, 32609, 3011, 32628, 2811, 32646, 2610, 32662, 2410, 32678, 2209, 32692, 2009, 32705, 1808, 32717 240 | .dc.w 1607, 32727, 1407, 32736, 1206, 32744, 1005, 32751, 804, 32757, 603, 32761, 402, 32764, 201, 32766 241 | .dc.w 0, 32766, -201, 32766, -402, 32764, -603, 32761, -804, 32757, -1005, 32751, -1206, 32744, -1406, 32736 242 | .dc.w -1607, 32727, -1808, 32717, -2009, 32705, -2209, 32692, -2410, 32678, -2610, 32662, -2811, 32646, -3011, 32628 243 | .dc.w -3211, 32609, -3411, 32588, -3611, 32567, -3811, 32544, -4010, 32520, -4210, 32495, -4409, 32468, -4608, 32441 244 | .dc.w -4807, 32412, -5006, 32382, -5205, 32350, -5403, 32318, -5601, 32284, -5799, 32249, -5997, 32213, -6195, 32176 245 | .dc.w -6392, 32137, -6589, 32097, -6786, 32056, -6982, 32014, -7179, 31970, -7375, 31926, -7571, 31880, -7766, 31833 246 | .dc.w -7961, 31785, -8156, 31735, -8351, 31684, -8545, 31633, -8739, 31580, -8932, 31525, -9126, 31470, -9319, 31413 247 | .dc.w -9511, 31356, -9703, 31297, -9895, 31236, -10087, 31175, -10278, 31113, -10469, 31049, -10659, 30984, -10849, 30918 248 | .dc.w -11038, 30851, -11227, 30783, -11416, 30713, -11604, 30643, -11792, 30571, -11979, 30498, -12166, 30424, -12353, 30349 249 | .dc.w -12539, 30272, -12724, 30195, -12909, 30116, -13094, 30036, -13278, 29955, -13462, 29873, -13645, 29790, -13827, 29706 250 | .dc.w -14009, 29621, -14191, 29534, -14372, 29446, -14552, 29358, -14732, 29268, -14911, 29177, -15090, 29085, -15268, 28992 251 | .dc.w -15446, 28897, -15623, 28802, -15799, 28706, -15975, 28608, -16150, 28510, -16325, 28410, -16499, 28309, -16672, 28208 252 | .dc.w -16845, 28105, -17017, 28001, -17189, 27896, -17360, 27790, -17530, 27683, -17699, 27575, -17868, 27466, -18036, 27355 253 | .dc.w -18204, 27244, -18371, 27132, -18537, 27019, -18702, 26905, -18867, 26789, -19031, 26673, -19194, 26556, -19357, 26438 254 | .dc.w -19519, 26318, -19680, 26198, -19840, 26077, -20000, 25954, -20159, 25831, -20317, 25707, -20474, 25582, -20631, 25456 255 | .dc.w -20787, 25329, -20942, 25201, -21096, 25072, -21249, 24942, -21402, 24811, -21554, 24679, -21705, 24546, -21855, 24413 256 | .dc.w -22004, 24278, -22153, 24143, -22301, 24006, -22448, 23869, -22594, 23731, -22739, 23592, -22883, 23452, -23027, 23311 257 | .dc.w -23169, 23169, -23311, 23027, -23452, 22883, -23592, 22739, -23731, 22594, -23869, 22448, -24006, 22301, -24143, 22153 258 | .dc.w -24278, 22005, -24413, 21855, -24546, 21705, -24679, 21554, -24811, 21402, -24942, 21249, -25072, 21096, -25201, 20942 259 | .dc.w -25329, 20787, -25456, 20631, -25582, 20474, -25707, 20317, -25831, 20159, -25954, 20000, -26077, 19840, -26198, 19680 260 | .dc.w -26318, 19519, -26437, 19357, -26556, 19194, -26673, 19031, -26789, 18867, -26905, 18702, -27019, 18537, -27132, 18371 261 | .dc.w -27244, 18204, -27355, 18036, -27466, 17868, -27575, 17699, -27683, 17530, -27790, 17360, -27896, 17189, -28001, 17017 262 | .dc.w -28105, 16845, -28207, 16672, -28309, 16499, -28410, 16325, -28510, 16150, -28608, 15975, -28706, 15799, -28802, 15623 263 | .dc.w -28897, 15446, -28992, 15268, -29085, 15090, -29177, 14911, -29268, 14732, -29358, 14552, -29446, 14372, -29534, 14191 264 | .dc.w -29620, 14009, -29706, 13827, -29790, 13645, -29873, 13462, -29955, 13278, -30036, 13094, -30116, 12910, -30195, 12724 265 | .dc.w -30272, 12539, -30349, 12353, -30424, 12167, -30498, 11980, -30571, 11792, -30643, 11604, -30713, 11416, -30783, 11228 266 | .dc.w -30851, 11038, -30918, 10849, -30984, 10659, -31049, 10469, -31113, 10278, -31175, 10087, -31236, 9895, -31297, 9704 267 | .dc.w -31356, 9511, -31413, 9319, -31470, 9126, -31525, 8933, -31580, 8739, -31633, 8545, -31684, 8351, -31735, 8156 268 | .dc.w -31784, 7961, -31833, 7766, -31880, 7571, -31926, 7375, -31970, 7179, -32014, 6983, -32056, 6786, -32097, 6589 269 | .dc.w -32137, 6392, -32175, 6195, -32213, 5997, -32249, 5799, -32284, 5601, -32318, 5403, -32350, 5205, -32382, 5006 270 | .dc.w -32412, 4807, -32441, 4609, -32468, 4409, -32495, 4210, -32520, 4011, -32544, 3811, -32567, 3611, -32588, 3411 271 | .dc.w -32609, 3211, -32628, 3011, -32646, 2811, -32662, 2611, -32678, 2410, -32692, 2210, -32705, 2009, -32717, 1808 272 | .dc.w -32727, 1607, -32736, 1407, -32744, 1206, -32751, 1005, -32757, 804, -32761, 603, -32764, 402, -32766, 201 273 | 274 | #elif FFT_N == 512 275 | .dc.w 32767, 0, 32764, 402, 32757, 804, 32744, 1206, 32727, 1607, 32705, 2009, 32678, 2410, 32646, 2811 276 | .dc.w 32609, 3211, 32567, 3611, 32520, 4011, 32468, 4409, 32412, 4807, 32350, 5205, 32284, 5601, 32213, 5997 277 | .dc.w 32137, 6392, 32056, 6786, 31970, 7179, 31880, 7571, 31785, 7961, 31684, 8351, 31580, 8739, 31470, 9126 278 | .dc.w 31356, 9511, 31236, 9895, 31113, 10278, 30984, 10659, 30851, 11038, 30713, 11416, 30571, 11792, 30424, 12166 279 | .dc.w 30272, 12539, 30116, 12909, 29955, 13278, 29790, 13645, 29621, 14009, 29446, 14372, 29268, 14732, 29085, 15090 280 | .dc.w 28897, 15446, 28706, 15799, 28510, 16150, 28309, 16499, 28105, 16845, 27896, 17189, 27683, 17530, 27466, 17868 281 | .dc.w 27244, 18204, 27019, 18537, 26789, 18867, 26556, 19194, 26318, 19519, 26077, 19840, 25831, 20159, 25582, 20474 282 | .dc.w 25329, 20787, 25072, 21096, 24811, 21402, 24546, 21705, 24278, 22004, 24006, 22301, 23731, 22594, 23452, 22883 283 | .dc.w 23169, 23169, 22883, 23452, 22594, 23731, 22301, 24006, 22004, 24278, 21705, 24546, 21402, 24811, 21096, 25072 284 | .dc.w 20787, 25329, 20474, 25582, 20159, 25831, 19840, 26077, 19519, 26318, 19194, 26556, 18867, 26789, 18537, 27019 285 | .dc.w 18204, 27244, 17868, 27466, 17530, 27683, 17189, 27896, 16845, 28105, 16499, 28309, 16150, 28510, 15799, 28706 286 | .dc.w 15446, 28897, 15090, 29085, 14732, 29268, 14372, 29446, 14009, 29621, 13645, 29790, 13278, 29955, 12909, 30116 287 | .dc.w 12539, 30272, 12166, 30424, 11792, 30571, 11416, 30713, 11038, 30851, 10659, 30984, 10278, 31113, 9895, 31236 288 | .dc.w 9511, 31356, 9126, 31470, 8739, 31580, 8351, 31684, 7961, 31785, 7571, 31880, 7179, 31970, 6786, 32056 289 | .dc.w 6392, 32137, 5997, 32213, 5601, 32284, 5205, 32350, 4807, 32412, 4409, 32468, 4011, 32520, 3611, 32567 290 | .dc.w 3211, 32609, 2811, 32646, 2410, 32678, 2009, 32705, 1607, 32727, 1206, 32744, 804, 32757, 402, 32764 291 | .dc.w 0, 32766, -402, 32764, -804, 32757, -1206, 32744, -1607, 32727, -2009, 32705, -2410, 32678, -2811, 32646 292 | .dc.w -3211, 32609, -3611, 32567, -4010, 32520, -4409, 32468, -4807, 32412, -5205, 32350, -5601, 32284, -5997, 32213 293 | .dc.w -6392, 32137, -6786, 32056, -7179, 31970, -7571, 31880, -7961, 31785, -8351, 31684, -8739, 31580, -9126, 31470 294 | .dc.w -9511, 31356, -9895, 31236, -10278, 31113, -10659, 30984, -11038, 30851, -11416, 30713, -11792, 30571, -12166, 30424 295 | .dc.w -12539, 30272, -12909, 30116, -13278, 29955, -13645, 29790, -14009, 29621, -14372, 29446, -14732, 29268, -15090, 29085 296 | .dc.w -15446, 28897, -15799, 28706, -16150, 28510, -16499, 28309, -16845, 28105, -17189, 27896, -17530, 27683, -17868, 27466 297 | .dc.w -18204, 27244, -18537, 27019, -18867, 26789, -19194, 26556, -19519, 26318, -19840, 26077, -20159, 25831, -20474, 25582 298 | .dc.w -20787, 25329, -21096, 25072, -21402, 24811, -21705, 24546, -22004, 24278, -22301, 24006, -22594, 23731, -22883, 23452 299 | .dc.w -23169, 23169, -23452, 22883, -23731, 22594, -24006, 22301, -24278, 22005, -24546, 21705, -24811, 21402, -25072, 21096 300 | .dc.w -25329, 20787, -25582, 20474, -25831, 20159, -26077, 19840, -26318, 19519, -26556, 19194, -26789, 18867, -27019, 18537 301 | .dc.w -27244, 18204, -27466, 17868, -27683, 17530, -27896, 17189, -28105, 16845, -28309, 16499, -28510, 16150, -28706, 15799 302 | .dc.w -28897, 15446, -29085, 15090, -29268, 14732, -29446, 14372, -29620, 14009, -29790, 13645, -29955, 13278, -30116, 12910 303 | .dc.w -30272, 12539, -30424, 12167, -30571, 11792, -30713, 11416, -30851, 11038, -30984, 10659, -31113, 10278, -31236, 9895 304 | .dc.w -31356, 9511, -31470, 9126, -31580, 8739, -31684, 8351, -31784, 7961, -31880, 7571, -31970, 7179, -32056, 6786 305 | .dc.w -32137, 6392, -32213, 5997, -32284, 5601, -32350, 5205, -32412, 4807, -32468, 4409, -32520, 4011, -32567, 3611 306 | .dc.w -32609, 3211, -32646, 2811, -32678, 2410, -32705, 2009, -32727, 1607, -32744, 1206, -32757, 804, -32764, 402 307 | 308 | #elif FFT_N == 256 309 | .dc.w 32767, 0, 32757, 804, 32727, 1607, 32678, 2410, 32609, 3211, 32520, 4011, 32412, 4807, 32284, 5601 310 | .dc.w 32137, 6392, 31970, 7179, 31785, 7961, 31580, 8739, 31356, 9511, 31113, 10278, 30851, 11038, 30571, 11792 311 | .dc.w 30272, 12539, 29955, 13278, 29621, 14009, 29268, 14732, 28897, 15446, 28510, 16150, 28105, 16845, 27683, 17530 312 | .dc.w 27244, 18204, 26789, 18867, 26318, 19519, 25831, 20159, 25329, 20787, 24811, 21402, 24278, 22004, 23731, 22594 313 | .dc.w 23169, 23169, 22594, 23731, 22004, 24278, 21402, 24811, 20787, 25329, 20159, 25831, 19519, 26318, 18867, 26789 314 | .dc.w 18204, 27244, 17530, 27683, 16845, 28105, 16150, 28510, 15446, 28897, 14732, 29268, 14009, 29621, 13278, 29955 315 | .dc.w 12539, 30272, 11792, 30571, 11038, 30851, 10278, 31113, 9511, 31356, 8739, 31580, 7961, 31785, 7179, 31970 316 | .dc.w 6392, 32137, 5601, 32284, 4807, 32412, 4011, 32520, 3211, 32609, 2410, 32678, 1607, 32727, 804, 32757 317 | .dc.w 0, 32766, -804, 32757, -1607, 32727, -2410, 32678, -3211, 32609, -4010, 32520, -4807, 32412, -5601, 32284 318 | .dc.w -6392, 32137, -7179, 31970, -7961, 31785, -8739, 31580, -9511, 31356, -10278, 31113, -11038, 30851, -11792, 30571 319 | .dc.w -12539, 30272, -13278, 29955, -14009, 29621, -14732, 29268, -15446, 28897, -16150, 28510, -16845, 28105, -17530, 27683 320 | .dc.w -18204, 27244, -18867, 26789, -19519, 26318, -20159, 25831, -20787, 25329, -21402, 24811, -22004, 24278, -22594, 23731 321 | .dc.w -23169, 23169, -23731, 22594, -24278, 22005, -24811, 21402, -25329, 20787, -25831, 20159, -26318, 19519, -26789, 18867 322 | .dc.w -27244, 18204, -27683, 17530, -28105, 16845, -28510, 16150, -28897, 15446, -29268, 14732, -29620, 14009, -29955, 13278 323 | .dc.w -30272, 12539, -30571, 11792, -30851, 11038, -31113, 10278, -31356, 9511, -31580, 8739, -31784, 7961, -31970, 7179 324 | .dc.w -32137, 6392, -32284, 5601, -32412, 4807, -32520, 4011, -32609, 3211, -32678, 2410, -32727, 1607, -32757, 804 325 | 326 | #elif FFT_N == 128 327 | .dc.w 32767, 0, 32727, 1607, 32609, 3211, 32412, 4807, 32137, 6392, 31785, 7961, 31356, 9511, 30851, 11038 328 | .dc.w 30272, 12539, 29621, 14009, 28897, 15446, 28105, 16845, 27244, 18204, 26318, 19519, 25329, 20787, 24278, 22004 329 | .dc.w 23169, 23169, 22004, 24278, 20787, 25329, 19519, 26318, 18204, 27244, 16845, 28105, 15446, 28897, 14009, 29621 330 | .dc.w 12539, 30272, 11038, 30851, 9511, 31356, 7961, 31785, 6392, 32137, 4807, 32412, 3211, 32609, 1607, 32727 331 | .dc.w 0, 32766, -1607, 32727, -3211, 32609, -4807, 32412, -6392, 32137, -7961, 31785, -9511, 31356, -11038, 30851 332 | .dc.w -12539, 30272, -14009, 29621, -15446, 28897, -16845, 28105, -18204, 27244, -19519, 26318, -20787, 25329, -22004, 24278 333 | .dc.w -23169, 23169, -24278, 22005, -25329, 20787, -26318, 19519, -27244, 18204, -28105, 16845, -28897, 15446, -29620, 14009 334 | .dc.w -30272, 12539, -30851, 11038, -31356, 9511, -31784, 7961, -32137, 6392, -32412, 4807, -32609, 3211, -32727, 1607 335 | 336 | #elif FFT_N == 64 337 | .dc.w 32767, 0, 32609, 3211, 32137, 6392, 31356, 9511, 30272, 12539, 28897, 15446, 27244, 18204, 25329, 20787 338 | .dc.w 23169, 23169, 20787, 25329, 18204, 27244, 15446, 28897, 12539, 30272, 9511, 31356, 6392, 32137, 3211, 32609 339 | .dc.w 0, 32766, -3211, 32609, -6392, 32137, -9511, 31356, -12539, 30272, -15446, 28897, -18204, 27244, -20787, 25329 340 | .dc.w -23169, 23169, -25329, 20787, -27244, 18204, -28897, 15446, -30272, 12539, -31356, 9511, -32137, 6392, -32609, 3211 341 | #endif 342 | 343 | 344 | 345 | tbl_bitrev: ; tbl_bitrev[] = ... 346 | #if FFT_N == 1024 347 | #ifdef INPUT_IQ 348 | .dc.w 1*4, 513*4, 257*4, 769*4, 129*4, 641*4, 385*4, 897*4, 65*4, 577*4, 321*4, 833*4, 193*4, 705*4, 449*4, 961*4 349 | .dc.w 33*4, 545*4, 289*4, 801*4, 161*4, 673*4, 417*4, 929*4, 97*4, 609*4, 353*4, 865*4, 225*4, 737*4, 481*4, 993*4 350 | .dc.w 17*4, 529*4, 273*4, 785*4, 145*4, 657*4, 401*4, 913*4, 81*4, 593*4, 337*4, 849*4, 209*4, 721*4, 465*4, 977*4 351 | .dc.w 49*4, 561*4, 305*4, 817*4, 177*4, 689*4, 433*4, 945*4, 113*4, 625*4, 369*4, 881*4, 241*4, 753*4, 497*4, 1009*4 352 | .dc.w 9*4, 521*4, 265*4, 777*4, 137*4, 649*4, 393*4, 905*4, 73*4, 585*4, 329*4, 841*4, 201*4, 713*4, 457*4, 969*4 353 | .dc.w 41*4, 553*4, 297*4, 809*4, 169*4, 681*4, 425*4, 937*4, 105*4, 617*4, 361*4, 873*4, 233*4, 745*4, 489*4, 1001*4 354 | .dc.w 25*4, 537*4, 281*4, 793*4, 153*4, 665*4, 409*4, 921*4, 89*4, 601*4, 345*4, 857*4, 217*4, 729*4, 473*4, 985*4 355 | .dc.w 57*4, 569*4, 313*4, 825*4, 185*4, 697*4, 441*4, 953*4, 121*4, 633*4, 377*4, 889*4, 249*4, 761*4, 505*4, 1017*4 356 | .dc.w 5*4, 517*4, 261*4, 773*4, 133*4, 645*4, 389*4, 901*4, 69*4, 581*4, 325*4, 837*4, 197*4, 709*4, 453*4, 965*4 357 | .dc.w 37*4, 549*4, 293*4, 805*4, 165*4, 677*4, 421*4, 933*4, 101*4, 613*4, 357*4, 869*4, 229*4, 741*4, 485*4, 997*4 358 | .dc.w 21*4, 533*4, 277*4, 789*4, 149*4, 661*4, 405*4, 917*4, 85*4, 597*4, 341*4, 853*4, 213*4, 725*4, 469*4, 981*4 359 | .dc.w 53*4, 565*4, 309*4, 821*4, 181*4, 693*4, 437*4, 949*4, 117*4, 629*4, 373*4, 885*4, 245*4, 757*4, 501*4, 1013*4 360 | .dc.w 13*4, 525*4, 269*4, 781*4, 141*4, 653*4, 397*4, 909*4, 77*4, 589*4, 333*4, 845*4, 205*4, 717*4, 461*4, 973*4 361 | .dc.w 45*4, 557*4, 301*4, 813*4, 173*4, 685*4, 429*4, 941*4, 109*4, 621*4, 365*4, 877*4, 237*4, 749*4, 493*4, 1005*4 362 | .dc.w 29*4, 541*4, 285*4, 797*4, 157*4, 669*4, 413*4, 925*4, 93*4, 605*4, 349*4, 861*4, 221*4, 733*4, 477*4, 989*4 363 | .dc.w 61*4, 573*4, 317*4, 829*4, 189*4, 701*4, 445*4, 957*4, 125*4, 637*4, 381*4, 893*4, 253*4, 765*4, 509*4, 1021*4 364 | .dc.w 3*4, 515*4, 259*4, 771*4, 131*4, 643*4, 387*4, 899*4, 67*4, 579*4, 323*4, 835*4, 195*4, 707*4, 451*4, 963*4 365 | .dc.w 35*4, 547*4, 291*4, 803*4, 163*4, 675*4, 419*4, 931*4, 99*4, 611*4, 355*4, 867*4, 227*4, 739*4, 483*4, 995*4 366 | .dc.w 19*4, 531*4, 275*4, 787*4, 147*4, 659*4, 403*4, 915*4, 83*4, 595*4, 339*4, 851*4, 211*4, 723*4, 467*4, 979*4 367 | .dc.w 51*4, 563*4, 307*4, 819*4, 179*4, 691*4, 435*4, 947*4, 115*4, 627*4, 371*4, 883*4, 243*4, 755*4, 499*4, 1011*4 368 | .dc.w 11*4, 523*4, 267*4, 779*4, 139*4, 651*4, 395*4, 907*4, 75*4, 587*4, 331*4, 843*4, 203*4, 715*4, 459*4, 971*4 369 | .dc.w 43*4, 555*4, 299*4, 811*4, 171*4, 683*4, 427*4, 939*4, 107*4, 619*4, 363*4, 875*4, 235*4, 747*4, 491*4, 1003*4 370 | .dc.w 27*4, 539*4, 283*4, 795*4, 155*4, 667*4, 411*4, 923*4, 91*4, 603*4, 347*4, 859*4, 219*4, 731*4, 475*4, 987*4 371 | .dc.w 59*4, 571*4, 315*4, 827*4, 187*4, 699*4, 443*4, 955*4, 123*4, 635*4, 379*4, 891*4, 251*4, 763*4, 507*4, 1019*4 372 | .dc.w 7*4, 519*4, 263*4, 775*4, 135*4, 647*4, 391*4, 903*4, 71*4, 583*4, 327*4, 839*4, 199*4, 711*4, 455*4, 967*4 373 | .dc.w 39*4, 551*4, 295*4, 807*4, 167*4, 679*4, 423*4, 935*4, 103*4, 615*4, 359*4, 871*4, 231*4, 743*4, 487*4, 999*4 374 | .dc.w 23*4, 535*4, 279*4, 791*4, 151*4, 663*4, 407*4, 919*4, 87*4, 599*4, 343*4, 855*4, 215*4, 727*4, 471*4, 983*4 375 | .dc.w 55*4, 567*4, 311*4, 823*4, 183*4, 695*4, 439*4, 951*4, 119*4, 631*4, 375*4, 887*4, 247*4, 759*4, 503*4, 1015*4 376 | .dc.w 15*4, 527*4, 271*4, 783*4, 143*4, 655*4, 399*4, 911*4, 79*4, 591*4, 335*4, 847*4, 207*4, 719*4, 463*4, 975*4 377 | .dc.w 47*4, 559*4, 303*4, 815*4, 175*4, 687*4, 431*4, 943*4, 111*4, 623*4, 367*4, 879*4, 239*4, 751*4, 495*4, 1007*4 378 | .dc.w 31*4, 543*4, 287*4, 799*4, 159*4, 671*4, 415*4, 927*4, 95*4, 607*4, 351*4, 863*4, 223*4, 735*4, 479*4, 991*4 379 | .dc.w 63*4, 575*4, 319*4, 831*4, 191*4, 703*4, 447*4, 959*4, 127*4, 639*4, 383*4, 895*4, 255*4, 767*4, 511*4, 1023*4 380 | #endif 381 | .dc.w 0*4, 512*4, 256*4, 768*4, 128*4, 640*4, 384*4, 896*4, 64*4, 576*4, 320*4, 832*4, 192*4, 704*4, 448*4, 960*4 382 | .dc.w 32*4, 544*4, 288*4, 800*4, 160*4, 672*4, 416*4, 928*4, 96*4, 608*4, 352*4, 864*4, 224*4, 736*4, 480*4, 992*4 383 | .dc.w 16*4, 528*4, 272*4, 784*4, 144*4, 656*4, 400*4, 912*4, 80*4, 592*4, 336*4, 848*4, 208*4, 720*4, 464*4, 976*4 384 | .dc.w 48*4, 560*4, 304*4, 816*4, 176*4, 688*4, 432*4, 944*4, 112*4, 624*4, 368*4, 880*4, 240*4, 752*4, 496*4, 1008*4 385 | .dc.w 8*4, 520*4, 264*4, 776*4, 136*4, 648*4, 392*4, 904*4, 72*4, 584*4, 328*4, 840*4, 200*4, 712*4, 456*4, 968*4 386 | .dc.w 40*4, 552*4, 296*4, 808*4, 168*4, 680*4, 424*4, 936*4, 104*4, 616*4, 360*4, 872*4, 232*4, 744*4, 488*4, 1000*4 387 | .dc.w 24*4, 536*4, 280*4, 792*4, 152*4, 664*4, 408*4, 920*4, 88*4, 600*4, 344*4, 856*4, 216*4, 728*4, 472*4, 984*4 388 | .dc.w 56*4, 568*4, 312*4, 824*4, 184*4, 696*4, 440*4, 952*4, 120*4, 632*4, 376*4, 888*4, 248*4, 760*4, 504*4, 1016*4 389 | .dc.w 4*4, 516*4, 260*4, 772*4, 132*4, 644*4, 388*4, 900*4, 68*4, 580*4, 324*4, 836*4, 196*4, 708*4, 452*4, 964*4 390 | .dc.w 36*4, 548*4, 292*4, 804*4, 164*4, 676*4, 420*4, 932*4, 100*4, 612*4, 356*4, 868*4, 228*4, 740*4, 484*4, 996*4 391 | .dc.w 20*4, 532*4, 276*4, 788*4, 148*4, 660*4, 404*4, 916*4, 84*4, 596*4, 340*4, 852*4, 212*4, 724*4, 468*4, 980*4 392 | .dc.w 52*4, 564*4, 308*4, 820*4, 180*4, 692*4, 436*4, 948*4, 116*4, 628*4, 372*4, 884*4, 244*4, 756*4, 500*4, 1012*4 393 | .dc.w 12*4, 524*4, 268*4, 780*4, 140*4, 652*4, 396*4, 908*4, 76*4, 588*4, 332*4, 844*4, 204*4, 716*4, 460*4, 972*4 394 | .dc.w 44*4, 556*4, 300*4, 812*4, 172*4, 684*4, 428*4, 940*4, 108*4, 620*4, 364*4, 876*4, 236*4, 748*4, 492*4, 1004*4 395 | .dc.w 28*4, 540*4, 284*4, 796*4, 156*4, 668*4, 412*4, 924*4, 92*4, 604*4, 348*4, 860*4, 220*4, 732*4, 476*4, 988*4 396 | .dc.w 60*4, 572*4, 316*4, 828*4, 188*4, 700*4, 444*4, 956*4, 124*4, 636*4, 380*4, 892*4, 252*4, 764*4, 508*4, 1020*4 397 | .dc.w 2*4, 514*4, 258*4, 770*4, 130*4, 642*4, 386*4, 898*4, 66*4, 578*4, 322*4, 834*4, 194*4, 706*4, 450*4, 962*4 398 | .dc.w 34*4, 546*4, 290*4, 802*4, 162*4, 674*4, 418*4, 930*4, 98*4, 610*4, 354*4, 866*4, 226*4, 738*4, 482*4, 994*4 399 | .dc.w 18*4, 530*4, 274*4, 786*4, 146*4, 658*4, 402*4, 914*4, 82*4, 594*4, 338*4, 850*4, 210*4, 722*4, 466*4, 978*4 400 | .dc.w 50*4, 562*4, 306*4, 818*4, 178*4, 690*4, 434*4, 946*4, 114*4, 626*4, 370*4, 882*4, 242*4, 754*4, 498*4, 1010*4 401 | .dc.w 10*4, 522*4, 266*4, 778*4, 138*4, 650*4, 394*4, 906*4, 74*4, 586*4, 330*4, 842*4, 202*4, 714*4, 458*4, 970*4 402 | .dc.w 42*4, 554*4, 298*4, 810*4, 170*4, 682*4, 426*4, 938*4, 106*4, 618*4, 362*4, 874*4, 234*4, 746*4, 490*4, 1002*4 403 | .dc.w 26*4, 538*4, 282*4, 794*4, 154*4, 666*4, 410*4, 922*4, 90*4, 602*4, 346*4, 858*4, 218*4, 730*4, 474*4, 986*4 404 | .dc.w 58*4, 570*4, 314*4, 826*4, 186*4, 698*4, 442*4, 954*4, 122*4, 634*4, 378*4, 890*4, 250*4, 762*4, 506*4, 1018*4 405 | .dc.w 6*4, 518*4, 262*4, 774*4, 134*4, 646*4, 390*4, 902*4, 70*4, 582*4, 326*4, 838*4, 198*4, 710*4, 454*4, 966*4 406 | .dc.w 38*4, 550*4, 294*4, 806*4, 166*4, 678*4, 422*4, 934*4, 102*4, 614*4, 358*4, 870*4, 230*4, 742*4, 486*4, 998*4 407 | .dc.w 22*4, 534*4, 278*4, 790*4, 150*4, 662*4, 406*4, 918*4, 86*4, 598*4, 342*4, 854*4, 214*4, 726*4, 470*4, 982*4 408 | .dc.w 54*4, 566*4, 310*4, 822*4, 182*4, 694*4, 438*4, 950*4, 118*4, 630*4, 374*4, 886*4, 246*4, 758*4, 502*4, 1014*4 409 | .dc.w 14*4, 526*4, 270*4, 782*4, 142*4, 654*4, 398*4, 910*4, 78*4, 590*4, 334*4, 846*4, 206*4, 718*4, 462*4, 974*4 410 | .dc.w 46*4, 558*4, 302*4, 814*4, 174*4, 686*4, 430*4, 942*4, 110*4, 622*4, 366*4, 878*4, 238*4, 750*4, 494*4, 1006*4 411 | .dc.w 30*4, 542*4, 286*4, 798*4, 158*4, 670*4, 414*4, 926*4, 94*4, 606*4, 350*4, 862*4, 222*4, 734*4, 478*4, 990*4 412 | .dc.w 62*4, 574*4, 318*4, 830*4, 190*4, 702*4, 446*4, 958*4, 126*4, 638*4, 382*4, 894*4, 254*4, 766*4, 510*4, 1022*4 413 | 414 | #elif FFT_N == 512 415 | #ifdef INPUT_IQ 416 | .dc.w 1*4, 257*4, 129*4, 385*4, 65*4, 321*4, 193*4, 449*4, 33*4, 289*4, 161*4, 417*4, 97*4, 353*4, 225*4, 481*4 417 | .dc.w 17*4, 273*4, 145*4, 401*4, 81*4, 337*4, 209*4, 465*4, 49*4, 305*4, 177*4, 433*4, 113*4, 369*4, 241*4, 497*4 418 | .dc.w 9*4, 265*4, 137*4, 393*4, 73*4, 329*4, 201*4, 457*4, 41*4, 297*4, 169*4, 425*4, 105*4, 361*4, 233*4, 489*4 419 | .dc.w 25*4, 281*4, 153*4, 409*4, 89*4, 345*4, 217*4, 473*4, 57*4, 313*4, 185*4, 441*4, 121*4, 377*4, 249*4, 505*4 420 | .dc.w 5*4, 261*4, 133*4, 389*4, 69*4, 325*4, 197*4, 453*4, 37*4, 293*4, 165*4, 421*4, 101*4, 357*4, 229*4, 485*4 421 | .dc.w 21*4, 277*4, 149*4, 405*4, 85*4, 341*4, 213*4, 469*4, 53*4, 309*4, 181*4, 437*4, 117*4, 373*4, 245*4, 501*4 422 | .dc.w 13*4, 269*4, 141*4, 397*4, 77*4, 333*4, 205*4, 461*4, 45*4, 301*4, 173*4, 429*4, 109*4, 365*4, 237*4, 493*4 423 | .dc.w 29*4, 285*4, 157*4, 413*4, 93*4, 349*4, 221*4, 477*4, 61*4, 317*4, 189*4, 445*4, 125*4, 381*4, 253*4, 509*4 424 | .dc.w 3*4, 259*4, 131*4, 387*4, 67*4, 323*4, 195*4, 451*4, 35*4, 291*4, 163*4, 419*4, 99*4, 355*4, 227*4, 483*4 425 | .dc.w 19*4, 275*4, 147*4, 403*4, 83*4, 339*4, 211*4, 467*4, 51*4, 307*4, 179*4, 435*4, 115*4, 371*4, 243*4, 499*4 426 | .dc.w 11*4, 267*4, 139*4, 395*4, 75*4, 331*4, 203*4, 459*4, 43*4, 299*4, 171*4, 427*4, 107*4, 363*4, 235*4, 491*4 427 | .dc.w 27*4, 283*4, 155*4, 411*4, 91*4, 347*4, 219*4, 475*4, 59*4, 315*4, 187*4, 443*4, 123*4, 379*4, 251*4, 507*4 428 | .dc.w 7*4, 263*4, 135*4, 391*4, 71*4, 327*4, 199*4, 455*4, 39*4, 295*4, 167*4, 423*4, 103*4, 359*4, 231*4, 487*4 429 | .dc.w 23*4, 279*4, 151*4, 407*4, 87*4, 343*4, 215*4, 471*4, 55*4, 311*4, 183*4, 439*4, 119*4, 375*4, 247*4, 503*4 430 | .dc.w 15*4, 271*4, 143*4, 399*4, 79*4, 335*4, 207*4, 463*4, 47*4, 303*4, 175*4, 431*4, 111*4, 367*4, 239*4, 495*4 431 | .dc.w 31*4, 287*4, 159*4, 415*4, 95*4, 351*4, 223*4, 479*4, 63*4, 319*4, 191*4, 447*4, 127*4, 383*4, 255*4, 511*4 432 | #endif 433 | .dc.w 0*4, 256*4, 128*4, 384*4, 64*4, 320*4, 192*4, 448*4, 32*4, 288*4, 160*4, 416*4, 96*4, 352*4, 224*4, 480*4 434 | .dc.w 16*4, 272*4, 144*4, 400*4, 80*4, 336*4, 208*4, 464*4, 48*4, 304*4, 176*4, 432*4, 112*4, 368*4, 240*4, 496*4 435 | .dc.w 8*4, 264*4, 136*4, 392*4, 72*4, 328*4, 200*4, 456*4, 40*4, 296*4, 168*4, 424*4, 104*4, 360*4, 232*4, 488*4 436 | .dc.w 24*4, 280*4, 152*4, 408*4, 88*4, 344*4, 216*4, 472*4, 56*4, 312*4, 184*4, 440*4, 120*4, 376*4, 248*4, 504*4 437 | .dc.w 4*4, 260*4, 132*4, 388*4, 68*4, 324*4, 196*4, 452*4, 36*4, 292*4, 164*4, 420*4, 100*4, 356*4, 228*4, 484*4 438 | .dc.w 20*4, 276*4, 148*4, 404*4, 84*4, 340*4, 212*4, 468*4, 52*4, 308*4, 180*4, 436*4, 116*4, 372*4, 244*4, 500*4 439 | .dc.w 12*4, 268*4, 140*4, 396*4, 76*4, 332*4, 204*4, 460*4, 44*4, 300*4, 172*4, 428*4, 108*4, 364*4, 236*4, 492*4 440 | .dc.w 28*4, 284*4, 156*4, 412*4, 92*4, 348*4, 220*4, 476*4, 60*4, 316*4, 188*4, 444*4, 124*4, 380*4, 252*4, 508*4 441 | .dc.w 2*4, 258*4, 130*4, 386*4, 66*4, 322*4, 194*4, 450*4, 34*4, 290*4, 162*4, 418*4, 98*4, 354*4, 226*4, 482*4 442 | .dc.w 18*4, 274*4, 146*4, 402*4, 82*4, 338*4, 210*4, 466*4, 50*4, 306*4, 178*4, 434*4, 114*4, 370*4, 242*4, 498*4 443 | .dc.w 10*4, 266*4, 138*4, 394*4, 74*4, 330*4, 202*4, 458*4, 42*4, 298*4, 170*4, 426*4, 106*4, 362*4, 234*4, 490*4 444 | .dc.w 26*4, 282*4, 154*4, 410*4, 90*4, 346*4, 218*4, 474*4, 58*4, 314*4, 186*4, 442*4, 122*4, 378*4, 250*4, 506*4 445 | .dc.w 6*4, 262*4, 134*4, 390*4, 70*4, 326*4, 198*4, 454*4, 38*4, 294*4, 166*4, 422*4, 102*4, 358*4, 230*4, 486*4 446 | .dc.w 22*4, 278*4, 150*4, 406*4, 86*4, 342*4, 214*4, 470*4, 54*4, 310*4, 182*4, 438*4, 118*4, 374*4, 246*4, 502*4 447 | .dc.w 14*4, 270*4, 142*4, 398*4, 78*4, 334*4, 206*4, 462*4, 46*4, 302*4, 174*4, 430*4, 110*4, 366*4, 238*4, 494*4 448 | .dc.w 30*4, 286*4, 158*4, 414*4, 94*4, 350*4, 222*4, 478*4, 62*4, 318*4, 190*4, 446*4, 126*4, 382*4, 254*4, 510*4 449 | 450 | #elif FFT_N == 256 451 | #ifdef INPUT_IQ 452 | .dc.w 1*4, 129*4, 65*4, 193*4, 33*4, 161*4, 97*4, 225*4, 17*4, 145*4, 81*4, 209*4, 49*4, 177*4, 113*4, 241*4 453 | .dc.w 9*4, 137*4, 73*4, 201*4, 41*4, 169*4, 105*4, 233*4, 25*4, 153*4, 89*4, 217*4, 57*4, 185*4, 121*4, 249*4 454 | .dc.w 5*4, 133*4, 69*4, 197*4, 37*4, 165*4, 101*4, 229*4, 21*4, 149*4, 85*4, 213*4, 53*4, 181*4, 117*4, 245*4 455 | .dc.w 13*4, 141*4, 77*4, 205*4, 45*4, 173*4, 109*4, 237*4, 29*4, 157*4, 93*4, 221*4, 61*4, 189*4, 125*4, 253*4 456 | .dc.w 3*4, 131*4, 67*4, 195*4, 35*4, 163*4, 99*4, 227*4, 19*4, 147*4, 83*4, 211*4, 51*4, 179*4, 115*4, 243*4 457 | .dc.w 11*4, 139*4, 75*4, 203*4, 43*4, 171*4, 107*4, 235*4, 27*4, 155*4, 91*4, 219*4, 59*4, 187*4, 123*4, 251*4 458 | .dc.w 7*4, 135*4, 71*4, 199*4, 39*4, 167*4, 103*4, 231*4, 23*4, 151*4, 87*4, 215*4, 55*4, 183*4, 119*4, 247*4 459 | .dc.w 15*4, 143*4, 79*4, 207*4, 47*4, 175*4, 111*4, 239*4, 31*4, 159*4, 95*4, 223*4, 63*4, 191*4, 127*4, 255*4 460 | #endif 461 | .dc.w 0*4, 128*4, 64*4, 192*4, 32*4, 160*4, 96*4, 224*4, 16*4, 144*4, 80*4, 208*4, 48*4, 176*4, 112*4, 240*4 462 | .dc.w 8*4, 136*4, 72*4, 200*4, 40*4, 168*4, 104*4, 232*4, 24*4, 152*4, 88*4, 216*4, 56*4, 184*4, 120*4, 248*4 463 | .dc.w 4*4, 132*4, 68*4, 196*4, 36*4, 164*4, 100*4, 228*4, 20*4, 148*4, 84*4, 212*4, 52*4, 180*4, 116*4, 244*4 464 | .dc.w 12*4, 140*4, 76*4, 204*4, 44*4, 172*4, 108*4, 236*4, 28*4, 156*4, 92*4, 220*4, 60*4, 188*4, 124*4, 252*4 465 | .dc.w 2*4, 130*4, 66*4, 194*4, 34*4, 162*4, 98*4, 226*4, 18*4, 146*4, 82*4, 210*4, 50*4, 178*4, 114*4, 242*4 466 | .dc.w 10*4, 138*4, 74*4, 202*4, 42*4, 170*4, 106*4, 234*4, 26*4, 154*4, 90*4, 218*4, 58*4, 186*4, 122*4, 250*4 467 | .dc.w 6*4, 134*4, 70*4, 198*4, 38*4, 166*4, 102*4, 230*4, 22*4, 150*4, 86*4, 214*4, 54*4, 182*4, 118*4, 246*4 468 | .dc.w 14*4, 142*4, 78*4, 206*4, 46*4, 174*4, 110*4, 238*4, 30*4, 158*4, 94*4, 222*4, 62*4, 190*4, 126*4, 254*4 469 | 470 | #elif FFT_N == 128 471 | #ifdef INPUT_IQ 472 | .dc.w 1*4, 65*4, 33*4, 97*4, 17*4, 81*4, 49*4, 113*4, 9*4, 73*4, 41*4, 105*4, 25*4, 89*4, 57*4, 121*4 473 | .dc.w 5*4, 69*4, 37*4, 101*4, 21*4, 85*4, 53*4, 117*4, 13*4, 77*4, 45*4, 109*4, 29*4, 93*4, 61*4, 125*4 474 | .dc.w 3*4, 67*4, 35*4, 99*4, 19*4, 83*4, 51*4, 115*4, 11*4, 75*4, 43*4, 107*4, 27*4, 91*4, 59*4, 123*4 475 | .dc.w 7*4, 71*4, 39*4, 103*4, 23*4, 87*4, 55*4, 119*4, 15*4, 79*4, 47*4, 111*4, 31*4, 95*4, 63*4, 127*4 476 | #endif 477 | .dc.w 0*4, 64*4, 32*4, 96*4, 16*4, 80*4, 48*4, 112*4, 8*4, 72*4, 40*4, 104*4, 24*4, 88*4, 56*4, 120*4 478 | .dc.w 4*4, 68*4, 36*4, 100*4, 20*4, 84*4, 52*4, 116*4, 12*4, 76*4, 44*4, 108*4, 28*4, 92*4, 60*4, 124*4 479 | .dc.w 2*4, 66*4, 34*4, 98*4, 18*4, 82*4, 50*4, 114*4, 10*4, 74*4, 42*4, 106*4, 26*4, 90*4, 58*4, 122*4 480 | .dc.w 6*4, 70*4, 38*4, 102*4, 22*4, 86*4, 54*4, 118*4, 14*4, 78*4, 46*4, 110*4, 30*4, 94*4, 62*4, 126*4 481 | 482 | #elif FFT_N == 64 483 | #ifdef INPUT_IQ 484 | .dc.w 1*4, 33*4, 17*4, 49*4, 9*4, 41*4, 25*4, 57*4, 5*4, 37*4, 21*4, 53*4, 13*4, 45*4, 29*4, 61*4 485 | .dc.w 3*4, 35*4, 19*4, 51*4, 11*4, 43*4, 27*4, 59*4, 7*4, 39*4, 23*4, 55*4, 15*4, 47*4, 31*4, 63*4 486 | #endif 487 | .dc.w 0*4, 32*4, 16*4, 48*4, 8*4, 40*4, 24*4, 56*4, 4*4, 36*4, 20*4, 52*4, 12*4, 44*4, 28*4, 60*4 488 | .dc.w 2*4, 34*4, 18*4, 50*4, 10*4, 42*4, 26*4, 58*4, 6*4, 38*4, 22*4, 54*4, 14*4, 46*4, 30*4, 62*4 489 | #endif 490 | 491 | 492 | 493 | ;----------------------------------------------------------------------------; 494 | #ifndef INPUT_NOUSE 495 | .global fft_input 496 | .func fft_input 497 | fft_input: 498 | pushw T2H,T2L 499 | pushw AH,AL 500 | pushw YH,YL 501 | 502 | movw XL, EL ;X = array_src; 503 | movw YL, DL ;Y = array_bfly; 504 | clr EH ;Zero 505 | ldiw ZH,ZL, tbl_window ;Z = &tbl_window[0]; 506 | ldiw AH,AL, FFT_N ;A = FFT_N; 507 | 1: lpmw BH,BL, Z+ ;B = *Z++; (window) 508 | ldw CH,CL, X+ ;C = *X++; (I-axis) 509 | FMULS16 DH,DL,T2H,T2L, BH,BL, CH,CL ;D = B * C; 510 | stw Y+, DH,DL ;*Y++ = D; 511 | #ifdef INPUT_IQ 512 | ldw CH,CL, X+ ;C = *X++; (Q-axis) 513 | FMULS16 DH,DL,T2H,T2L, BH,BL, CH,CL ;D = B * C; 514 | #endif 515 | stw Y+, DH,DL ;*Y++ = D; 516 | subiw AH,AL, 1 ;while(--A) 517 | brne 1b ;/ 518 | 519 | popw YH,YL 520 | popw AH,AL 521 | popw T2H,T2L 522 | clr r1 523 | ret 524 | .endfunc 525 | #endif /* INPUT_NOUSE */ 526 | 527 | 528 | 529 | ;----------------------------------------------------------------------------; 530 | .global fft_execute 531 | .func fft_execute 532 | fft_execute: 533 | pushw T2H,T2L 534 | pushw T4H,T4L 535 | pushw T6H,T6L 536 | pushw T8H,T8L 537 | pushw T10H,T10L 538 | pushw T12H,T12L 539 | pushw T14H,T14L 540 | pushw AH,AL 541 | pushw YH,YL 542 | 543 | movw ZL, EL ;Z = array_bfly; 544 | ldiw EH,EL, 1 ;E = 1; 545 | ldiw XH,XL, FFT_N/2 ;X = FFT_N/2; 546 | 1: ldi AL, 4 ;T12 = E; (angular speed) 547 | mul EL, AL ; 548 | movw T12L, T0L ; 549 | mul EH, AL ; 550 | add T12H, T0L ;/ 551 | movw T14L, EL ;T14 = E; 552 | pushw EH,EL 553 | movw YL, ZL ;Z = &array_bfly[0]; 554 | mul XL, AL ;Y = &array_bfly[X]; 555 | addw YH,YL, T0H,T0L ; 556 | mul XH, AL ; 557 | add YH, T0L ;/ 558 | pushw ZH,ZL 559 | 2: clrw T10H,T10L ;T10 = 0 (angle) 560 | clr EH ;Zero reg. 561 | 3: lddw AH,AL, Z+0 ;A = *Z - *Y; *Z++ += *Y; 562 | asrw AH,AL ; 563 | lddw DH,DL, Y+0 ; 564 | asrw DH,DL ; 565 | movw CL, AL ; 566 | subw AH,AL, DH,DL ; 567 | addw CH,CL, DH,DL ; 568 | stw Z+, CH,CL ;/ 569 | lddw BH,BL, Z+0 ;B = *Z - *Y; *Z++ += *Y; 570 | asrw BH,BL ; 571 | lddw DH,DL, Y+2 ; 572 | asrw DH,DL ; 573 | movw CL, BL ; 574 | subw BH,BL, DH,DL ; 575 | addw CH,CL, DH,DL ; 576 | stw Z+, CH,CL ;/ 577 | movw T0L, ZL 578 | ldiw ZH,ZL, tbl_cos_sin ;C = cos(T10); D = sin(T10); 579 | addw ZH,ZL, T10H,T10L ; 580 | lpmw CH,CL, Z+ ; 581 | lpmw DH,DL, Z+ ;/ 582 | movw ZL, T0L 583 | FMULS16 T4H,T4L,T2H,T2L, AH,AL, CH,CL ;*Y++ = A * C + B * D; 584 | FMULS16 T8H,T8L,T6H,T6L, BH,BL, DH,DL ; 585 | addd T4H,T4L,T2H,T2L, T8H,T8L,T6H,T6L; 586 | stw Y+, T4H,T4L ;/ 587 | FMULS16 T4H,T4L,T2H,T2L, BH,BL, CH,CL ;*Y++ = B * C - A * D; 588 | FMULS16 T8H,T8L,T6H,T6L, AH,AL, DH,DL ; 589 | subd T4H,T4L,T2H,T2L, T8H,T8L,T6H,T6L; 590 | stw Y+, T4H,T4L ;/ 591 | addw T10H,T10L, T12H,T12L ;T10 += T12; (next angle) 592 | #if FFT_N >= 128 593 | sbrs T10H, FFT_B - 7 ;while(T10 < pi) 594 | #else 595 | sbrs T10L, FFT_B + 1 596 | #endif 597 | rjmp 3b ;/ 598 | ldi AL, 4 ;Y += X; Z += X; (skip split segment) 599 | mul XL, AL 600 | addw YH,YL, T0H,T0L ; 601 | addw ZH,ZL, T0H,T0L ; 602 | mul XH, AL ; 603 | add YH, T0L ; 604 | add ZH, T0L ;/ 605 | ldi EL, 1 ;while(--T14) 606 | subw T14H,T14L, EH,EL ; 607 | rjne 2b ;/ 608 | popw ZH,ZL 609 | popw EH,EL 610 | lslw EH,EL ;E *= 2; 611 | lsrw XH,XL ;while(X /= 2) 612 | adiw XL, 0 ; 613 | rjne 1b ;/ 614 | 615 | popw YH,YL 616 | popw AH,AL 617 | popw T14H,T14L 618 | popw T12H,T12L 619 | popw T10H,T10L 620 | popw T8H,T8L 621 | popw T6H,T6L 622 | popw T4H,T4L 623 | popw T2H,T2L 624 | ; clr r1 625 | ret 626 | .endfunc 627 | 628 | 629 | 630 | ;----------------------------------------------------------------------------; 631 | .global fft_output 632 | .func fft_output 633 | fft_output: 634 | pushw T2H,T2L 635 | pushw T4H,T4L 636 | pushw T6H,T6L 637 | pushw T8H,T8L 638 | pushw T10H,T10L 639 | pushw AH,AL 640 | pushw YH,YL 641 | 642 | movw T10L, EL ;T10 = array_bfly; 643 | movw YL, DL ;Y = array_output; 644 | ldiw ZH,ZL, tbl_bitrev ;Z = tbl_bitrev; 645 | clr EH ;Zero 646 | #ifdef INPUT_IQ 647 | ldiw AH,AL, FFT_N ;A = FFT_N; (plus/minus) 648 | #else 649 | ldiw AH,AL, FFT_N / 2 ;A = FFT_N / 2; (plus only) 650 | #endif 651 | 1: lpmw XH,XL, Z+ ;X = *Z++; 652 | addw XH,XL, T10H,T10L ;X += array_bfly; 653 | ldw BH,BL, X+ ;B = *X++; 654 | ldw CH,CL, X+ ;C = *X++; 655 | FMULS16 T4H,T4L,T2H,T2L, BH,BL, BH,BL ;T4:T2 = B * B; 656 | FMULS16 T8H,T8L,T6H,T6L, CH,CL, CH,CL ;T8:T6 = C * C; 657 | addd T4H,T4L,T2H,T2L, T8H,T8L,T6H,T6L;T4:T2 += T8:T6; 658 | SQRT32 ;B = sqrt(T4:T2); 659 | stw Y+, BH,BL ;*Y++ = B; 660 | subiw AH,AL, 1 ;while(--A) 661 | rjne 1b ;/ 662 | 663 | popw YH,YL 664 | popw AH,AL 665 | popw T10H,T10L 666 | popw T8H,T8L 667 | popw T6H,T6L 668 | popw T4H,T4L 669 | popw T2H,T2L 670 | clr r1 671 | ret 672 | .endfunc 673 | 674 | 675 | 676 | ;----------------------------------------------------------------------------; 677 | .global fmuls_f 678 | .func fmuls_f 679 | fmuls_f: 680 | movw CL, EL ;C = E; 681 | clr EH ;Zero 682 | FMULS16 ZH,ZL,XH,XL, CH,CL, DH,DL ;Z:X = C * D; 683 | movw EL, ZL 684 | clr r1 685 | ret 686 | .endfunc 687 | 688 | -------------------------------------------------------------------------------- /libraries/ffft/ffft.h: -------------------------------------------------------------------------------- 1 | #ifndef FFT_N 2 | #define FFT_N 128 /* Number of samples (64,128,256,512). */ 3 | #endif /* FFT_N */ 4 | 5 | //#define INPUT_NOUSE 6 | //#define INPUT_IQ 7 | 8 | #ifndef FFFT_ASM /* for c modules */ 9 | 10 | typedef struct _tag_complex_t { 11 | int16_t r; 12 | int16_t i; 13 | } complex_t; 14 | 15 | 16 | #ifndef INPUT_NOUSE 17 | #ifdef INPUT_IQ 18 | void fft_input (const complex_t *, complex_t *); 19 | #else 20 | extern "C" { void fft_input (const int16_t *, complex_t *); } 21 | #endif 22 | #endif 23 | extern "C" { 24 | void fft_execute (complex_t *); 25 | void fft_output (complex_t *, uint16_t *); 26 | int16_t fmuls_f (int16_t, int16_t); 27 | } 28 | #include 29 | extern const int16_t PROGMEM tbl_window[]; 30 | 31 | #else /* for asm module */ 32 | 33 | #define T0L r0 34 | #define T0H r1 35 | #define T2L r2 36 | #define T2H r3 37 | #define T4L r4 38 | #define T4H r5 39 | #define T6L r6 40 | #define T6H r7 41 | #define T8L r8 42 | #define T8H r9 43 | #define T10L r10 44 | #define T10H r11 45 | #define T12L r12 46 | #define T12H r13 47 | #define T14L r14 48 | #define T14H r15 49 | #define AL r16 50 | #define AH r17 51 | #define BL r18 52 | #define BH r19 53 | #define CL r20 54 | #define CH r21 55 | #define DL r22 56 | #define DH r23 57 | #define EL r24 58 | #define EH r25 59 | #define XL r26 60 | #define XH r27 61 | #define YL r28 62 | #define YH r29 63 | #define ZL r30 64 | #define ZH r31 65 | 66 | .macro ldiw dh,dl, abs 67 | ldi \dl, lo8(\abs) 68 | ldi \dh, hi8(\abs) 69 | .endm 70 | 71 | .macro subiw dh,dl, abs 72 | subi \dl, lo8(\abs) 73 | sbci \dh, hi8(\abs) 74 | .endm 75 | 76 | .macro addw dh,dl, sh,sl 77 | add \dl, \sl 78 | adc \dh, \sh 79 | .endm 80 | 81 | .macro addd d3,d2,d1,d0, s3,s2,s1,s0 82 | add \d0, \s0 83 | adc \d1, \s1 84 | adc \d2, \s2 85 | adc \d3, \s3 86 | .endm 87 | 88 | .macro subw dh,dl, sh,sl 89 | sub \dl, \sl 90 | sbc \dh, \sh 91 | .endm 92 | 93 | .macro subd d3,d2,d1,d0, s3,s2,s1,s0 94 | sub \d0, \s0 95 | sbc \d1, \s1 96 | sbc \d2, \s2 97 | sbc \d3, \s3 98 | .endm 99 | 100 | .macro lddw dh,dl, src 101 | ldd \dl, \src 102 | ldd \dh, \src+1 103 | .endm 104 | 105 | .macro ldw dh,dl, src 106 | ld \dl, \src 107 | ld \dh, \src 108 | .endm 109 | 110 | .macro stw dst, sh,sl 111 | st \dst, \sl 112 | st \dst, \sh 113 | .endm 114 | 115 | .macro clrw dh, dl 116 | clr \dh 117 | clr \dl 118 | .endm 119 | 120 | .macro lsrw dh, dl 121 | lsr \dh 122 | ror \dl 123 | .endm 124 | 125 | .macro asrw dh, dl 126 | asr \dh 127 | ror \dl 128 | .endm 129 | 130 | .macro lslw dh, dl 131 | lsl \dl 132 | rol \dh 133 | .endm 134 | 135 | .macro pushw dh, dl 136 | push \dh 137 | push \dl 138 | .endm 139 | 140 | .macro popw dh, dl 141 | pop \dl 142 | pop \dh 143 | .endm 144 | 145 | .macro lpmw dh,dl, src 146 | lpm \dl, \src 147 | lpm \dh, \src 148 | .endm 149 | 150 | .macro rjne lbl 151 | breq 99f 152 | rjmp \lbl 153 | 99: 154 | .endm 155 | 156 | 157 | .macro FMULS16 d3,d2,d1,d0 ,s1h,s1l, s2h,s2l ;Fractional Multiply (19clk) 158 | fmuls \s1h, \s2h 159 | movw \d2, T0L 160 | fmul \s1l, \s2l 161 | movw \d0, T0L 162 | adc \d2, EH ;EH: zero reg. 163 | fmulsu \s1h, \s2l 164 | sbc \d3, EH 165 | add \d1, T0L 166 | adc \d2, T0H 167 | adc \d3, EH 168 | fmulsu \s2h, \s1l 169 | sbc \d3, EH 170 | add \d1, T0L 171 | adc \d2, T0H 172 | adc \d3, EH 173 | .endm 174 | 175 | 176 | .macro SQRT32 ; 32bit square root (526..542clk) 177 | clr T6L 178 | clr T6H 179 | clr T8L 180 | clr T8H 181 | ldi BL, 1 182 | ldi BH, 0 183 | clr CL 184 | clr CH 185 | ldi DH, 16 186 | 90: lsl T2L 187 | rol T2H 188 | rol T4L 189 | rol T4H 190 | rol T6L 191 | rol T6H 192 | rol T8L 193 | rol T8H 194 | lsl T2L 195 | rol T2H 196 | rol T4L 197 | rol T4H 198 | rol T6L 199 | rol T6H 200 | rol T8L 201 | rol T8H 202 | brpl 91f 203 | add T6L, BL 204 | adc T6H, BH 205 | adc T8L, CL 206 | adc T8H, CH 207 | rjmp 92f 208 | 91: sub T6L, BL 209 | sbc T6H, BH 210 | sbc T8L, CL 211 | sbc T8H, CH 212 | 92: lsl BL 213 | rol BH 214 | rol CL 215 | andi BL, 0b11111000 216 | ori BL, 0b00000101 217 | sbrc T8H, 7 218 | subi BL, 2 219 | dec DH 220 | brne 90b 221 | lsr CL 222 | ror BH 223 | ror BL 224 | lsr CL 225 | ror BH 226 | ror BL 227 | .endm 228 | 229 | #endif /* FFFT_ASM */ 230 | 231 | --------------------------------------------------------------------------------