-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hacked node-speaker exports and other imports here to get examples working #2
base: main
Are you sure you want to change the base?
Conversation
welcome! I don't quite understand some of the changes you're proposing, I'll add comments |
@@ -6,7 +6,7 @@ | |||
* (SDR - audio card) but it should be functional. | |||
*/ | |||
|
|||
import { open } from '..' | |||
import { open } from '../lib' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing ..
to ../lib
shouldn't be necessary to run the examples, as long as you've ran npm run build
first and you have compiled files in dist
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw! these examples are meant to be run with ts-node
or similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. New to the ecosystem and didn't have any build instructions :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also; opening in vscode is disappointing; that guesses that the build instructions are just to run tsc, so "Start Debugging" doesn't work
package.json
Outdated
"usb": "^1.6.3" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^23.3.14", | ||
"coveralls": "^3.1.0", | ||
"jest": "^26.4.2", | ||
"speaker": "^0.5.2", | ||
"speaker": "https://github.com/cjheath/node-speaker.git", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you explain a bit more what changes you need / made in your fork?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.f. TooTallNate/node-speaker#142 - closed but not fixed, I did this:
https://github.com/cjheath/node-speaker/commit/09377c3544742a32afaa4e8aeff8a6ada33f0205
@@ -17,6 +17,7 @@ | |||
"emitDecoratorMetadata": true | |||
}, | |||
"include": [ | |||
"lib" | |||
"lib", | |||
"examples" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK that would cause examples to be compiled and distributed with the NPM package... I think examples don't need to be published, just the actual library code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, probably not sensible for a library module. But some instructions on building the examples would be good, also the ability to build them without installing. Guess I don't understand why they import from ".." if there's no code there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they import from '..' because that's the module itself :) so according to package.json
, that resolves to dist/index.js
as per running / building examples, you're just supposed to run them with ts-node
rather than building. I'll put a README in the examples folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent idea :) thanks!
Mainly just things to get it compiling. I tried under VSCode, then command line, just saying "tsc" at the top level.
https://github.com/cjheath/node-speaker/commit/09377c3544742a32afaa4e8aeff8a6ada33f0205 |
Also I've just done this:
|
I'm just speculating, but that happened to me too, and it seems to be a loop starvation issue somewhere in my code or usb, which prevents the ^C event from being dispatched. if it happens on fm_tone, your cpu is probably not fast enough to run the code (keep in mind examples aren't optimized in any way) |
I'd be very surprised if my CPU isn't fast enough. 2yo i7 MacBook Pro... BTW, I've developed a new version of HackRF, updating to still-available components. and adding robust protection to the antenna port. It's about to go to batch manufacturing and will be available for purchase on aliexpress (no cash to me, just development sample units) |
that looks nice 💙 let me know when it's available :) |
by the way, I don't know enough TypeScript to understand why in any case, according to the documentation, |
I've added |
I've fetched your latest.
|
have you run |
Ahh, apologies, that fixed it, or would have, if `speaker`` had been fixed already |
perfect! now I just have to fix the loop starvation bug |
Please note I changed package.json to refer to my fork of node-speaker also.
As a newb to the TypeScript ecosystem I don't know if my export/import changes are correct/modern/acceptable, but I got the examples working.
There is still a bug (in usb?) where fm_tone doesn't exit on a ^C interrupt. Have to ^Z and kill it.